From nobody Tue Jun 16 05:18:36 2026 Received: from mail-dl1-f48.google.com (mail-dl1-f48.google.com [74.125.82.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ACE53DE451 for ; Thu, 16 Apr 2026 14:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776349318; cv=none; b=BFlSk6uLJW0m/pvDe0kvpGcgUdy9FgmCF3Em+NaLl0AfzW9Rs9Bn5mYunaw7q7PR04QARNtG0DqeixqpR056nsMyM60pyu/PSqj/kpOBPxoy0odxrMLNigKO02sb5YU8JnaVLj/NeAT73p43Jwq/qJ9Nf2JTKspjZm/2pmhYfjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776349318; c=relaxed/simple; bh=mAjT45WQhnjtVyYVvBf2pQ/QyrbZdt2tiyZOsc7r+ck=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ajRGzsDLbSd3Xf/wjpH8Kb3sC5RmjEq7WCbazM6YBbYWRYmoZ9WFBBQKI+8WqD7fR+L3t1n83bdeHB+xngKpp8wAgmht/q6wQmdnZy0lHq74M7ZfHDhZGOIqALG4VPQ9UhJhtF520LKHpY54LC3ZZvBtqG5oLWFXC3jZL6GEAEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com; spf=pass smtp.mailfrom=arista.com; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b=K235CF+t; arc=none smtp.client-ip=74.125.82.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arista.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="K235CF+t" Received: by mail-dl1-f48.google.com with SMTP id a92af1059eb24-12714f01940so418061c88.0 for ; Thu, 16 Apr 2026 07:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1776349315; x=1776954115; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uFu1DzNio6n1RumPdBhDerBBGIlEwFQJz0L3Q0gtmOw=; b=K235CF+t5eMvvDMUhl9C6BbtmbC7yCWvlzK11XOVOt1y2ghHNdcbvdC2WqBb9XAdq7 U6EuokXEvhkqUGlMRqSup+F0q89Ydqzmn5sA+Up3n2/VUb1qC/CcuCffxvIVqBW/WBB3 KytuiJhyxtUYE+5eVjtyslh80+BbAPX1sUPfuHn39h/jOtGfmLY9azcIpEqsrUH/FkRX kqi6oN40QQPoeumhfuefIayJEO4Qfo6BJ/LNZxhnmHwH8fU5DU3Ymr/Jqg+a/dQHyiCe AYX2Rtgue+sOktyWtWoz2J80eg+Egx6EJPFDvf/6/JKRG7E+TyrM/sAJM5MCszjV7Krn 3wXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776349315; x=1776954115; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uFu1DzNio6n1RumPdBhDerBBGIlEwFQJz0L3Q0gtmOw=; b=kCjiuwVy0+XVcVTKz0fz2MfiHp1os1gRMMjafoVfH9CXQiwBjeZpjPjLU7Ab8UQu8W yutX6pH3vIDTjxkWdAeA1SvtQrJ7juJCYw3HHDTGNoAls4EtWtDdxNGM7WiTzEuzI34/ 7xpXcFAIQi9MV0jOGi/WTpRqVPeHvjzsqZT58z/PXryU44z2ttzIwy0yiX5QwKwP8W7Y H2bhfsgjwQ8J94FcI1RQN7D/3ffnXPcjUOVw0PPgK72ooPCYjnXfWDoNTHtmNQfIPOX9 z41U/TjLO1DyMw5IkI9av7au8fvcG5rr6F24rM3dQoOOpZeh6F/ljC75h27CHDBdqB9t 79fw== X-Forwarded-Encrypted: i=1; AFNElJ+xdvMkLCjl6QhAtGEWE72GXW9JBr3DD5UyOC7EuOEEwmdLWqkpAi3b3i5Bklk+ADE1rRCSQlK03JrKs8M=@vger.kernel.org X-Gm-Message-State: AOJu0YzmkB/60vA7IG1ao+tMK98yy+S4BvvyoOnQv8FhgP802yMa7i4D Y8agzsU1IKUWIlySh5qbVhUnCrajlQrF0fgBrlvRaI7J4NO+uXUGodTi9y913/ZvAw== X-Gm-Gg: AeBDieunSGZ1a1mk66Dgz4ITrKAudZQyrPQSSNqnU7RJyokmJh8zqlXDRl416CmJRH9 TCERnM4UbbM/gSMzEQvKexrLQucAZdQCdon0ybrUzrkCKU3ESRpknYMM4Naox06XS4SyFf1umFk yat58RWBLhp/oXG0xUlNByANy1MXA4zF/ZH/dY1NwKLpx01H9w+fr8mEeZKwY4Zozl3FBOXOX33 OBGuTjvJw8zd5rZFWZRc3/6c1dPkwWeBggSYclq5UBDRAf+8FJM+wPjJGGvqnhrD1512JatsDE5 lGVCpoiPr39Jv0PF0iJOEsjfkXYIOm7QgsHaZHLbj+nXuaFvH+qOHbfZqA0u7EYxfldo3aFMLIk ZM4BXXI0BqwGhjxmB4JTYuA/DTJnJUyf6EzsN1OKWt9UGi9CFaun0wdaFRJ4mW3DPQN1cqKCrvJ Tpydy7r5cHqdIvkum12NYu8j7cfnFmXrNhzI8qnEpHXFycHjzUMvy0hpc3UCA= X-Received: by 2002:a05:7300:7495:b0:2c1:7ca:cec2 with SMTP id 5a478bee46e88-2e193539dd3mr726559eec.8.1776349315133; Thu, 16 Apr 2026 07:21:55 -0700 (PDT) Received: from adriana-schoodic-rtc.sjc.aristanetworks.com ([74.123.28.13]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2de8c605851sm7577478eec.9.2026.04.16.07.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 07:21:54 -0700 (PDT) From: Adriana Stancu To: alexandre.belloni@bootlin.com Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, Adriana Stancu Subject: [PATCH v3] rtc: bq32000: add configurable delay between RTC reads Date: Thu, 16 Apr 2026 07:21:51 -0700 Message-ID: <20260416142151.3385827-1-adriana@arista.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the RTC is used on systems without a interrupt line, userspace tools like `hwclock` fall back to a frequent polling loop to synchronize with the edge of the next second. On the BQ32000, this aggressive polling can temporarly lock the register refresh cycle, because the continuous transfers prevent the hardware from updating the buffer. This results in stale data reads or select() timeouts in userspace. This patch introduces a delay before reading the RTC registers in order to provide a sufficient idle time for the hardware to sync with the register buffer. Signed-off-by: Adriana Stancu --- drivers/rtc/rtc-bq32k.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c index 7ad34539be4d..edce95eb328f 100644 --- a/drivers/rtc/rtc-bq32k.c +++ b/drivers/rtc/rtc-bq32k.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 #define BQ32K_SECONDS 0x00 /* Seconds register address */ #define BQ32K_SECONDS_MASK 0x7F /* Mask over seconds value */ @@ -89,9 +90,17 @@ static int bq32k_write(struct device *dev, void *data, u= int8_t off, uint8_t len) =20 static int bq32k_rtc_read_time(struct device *dev, struct rtc_time *tm) { + struct i2c_client *client =3D to_i2c_client(dev); struct bq32k_regs regs; int error; =20 + /* + * When the device doesn't have the interrupt connected, prevent + * userpace from polling the RTC registers to frequently. + */ + if (client->irq <=3D 0) + usleep_range(2000, 2500); + error =3D bq32k_read(dev, ®s, 0, sizeof(regs)); if (error) return error; --=20 2.51.0