{"id":2223883,"url":"http://patchwork.ozlabs.org/api/patches/2223883/?format=json","web_url":"http://patchwork.ozlabs.org/project/rtc-linux/patch/20260416095706.3212158-3-adriana@arista.com/","project":{"id":9,"url":"http://patchwork.ozlabs.org/api/projects/9/?format=json","name":"Linux RTC development","link_name":"rtc-linux","list_id":"linux-rtc.vger.kernel.org","list_email":"linux-rtc@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260416095706.3212158-3-adriana@arista.com>","list_archive_url":null,"date":"2026-04-16T09:57:06","name":"[v2,2/2] rtc: bq32000: add configurable delay between RTC reads","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d4bf128ccd1e372298537a2a60c1edbd6852c8f5","submitter":{"id":91944,"url":"http://patchwork.ozlabs.org/api/people/91944/?format=json","name":"Adriana Stancu","email":"adriana@arista.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/rtc-linux/patch/20260416095706.3212158-3-adriana@arista.com/mbox/","series":[{"id":500129,"url":"http://patchwork.ozlabs.org/api/series/500129/?format=json","web_url":"http://patchwork.ozlabs.org/project/rtc-linux/list/?series=500129","date":"2026-04-16T09:57:04","name":"rtc: bq32000: Add settle delay for aggressive polling","version":2,"mbox":"http://patchwork.ozlabs.org/series/500129/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223883/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223883/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-rtc+bounces-6352-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-rtc@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=arista.com header.i=@arista.com header.a=rsa-sha256\n header.s=google header.b=A7xhCwCP;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-rtc+bounces-6352-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com\n header.b=\"A7xhCwCP\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=74.125.82.175","smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=arista.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=arista.com"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxD321b1sz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 19:57:50 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 03463309D411\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 09:57:26 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3614439DBEE;\n\tThu, 16 Apr 2026 09:57:17 +0000 (UTC)","from mail-dy1-f175.google.com (mail-dy1-f175.google.com\n [74.125.82.175])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id C497739D6F0\n\tfor <linux-rtc@vger.kernel.org>; Thu, 16 Apr 2026 09:57:15 +0000 (UTC)","by mail-dy1-f175.google.com with SMTP id\n 5a478bee46e88-2dd52990758so268699eec.1\n        for <linux-rtc@vger.kernel.org>; Thu, 16 Apr 2026 02:57:15 -0700 (PDT)","from adriana-schoodic-rtc.sjc.aristanetworks.com ([74.123.28.10])\n        by smtp.gmail.com with ESMTPSA id\n a92af1059eb24-12c5f3f3d93sm4532913c88.15.2026.04.16.02.57.13\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Thu, 16 Apr 2026 02:57:14 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776333437; cv=none;\n b=QQ1wvk7DcvA+gSa39CtohR+WjU9/PiqtYrydRELDBxGLf0aQ/U07bMEaA2wHgihxC9QzpNtBgB2D5InwOyF64NOpRoGuri6+aJNXEacrwShuONuw4PhJKSEGpfEQ9MkqLV9BExqLcXbuNVXV5OHqXxirahHv9ObyScy4nNNoE9Q=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776333437; c=relaxed/simple;\n\tbh=lIJnDyanoQRdooXW+rb4vRnTiHA4NZZ2a5UsiOLgCzQ=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=OXM965C5shWPaMwopDCZf6MbXmAGhjhkq962gtO7btqCP4i6GM8vL9AJYCmSR+TgYLq+d4pSEms4Qzf/LBjt20OVSXb1OTZ3WhK50dcz+Nz/Ys92LsMl/LVOCY32YTqhO4QL3AeIY5eVANpDBZ8G/bJ90W6e8mi7gHQlpEPWqxc=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=arista.com;\n spf=pass smtp.mailfrom=arista.com;\n dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com\n header.b=A7xhCwCP; arc=none smtp.client-ip=74.125.82.175","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=arista.com; s=google; t=1776333435; x=1776938235;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=H/1T705jUCHUuc7zYF9p5WCGH43XsT88FDPreDZ7P4Y=;\n        b=A7xhCwCPhwfdNhXwpyVgqBtP5J7dey86XN3zXBRoSA1zyAn8nrZxohuS1t3a6F4Jye\n         yKzbL7P/odW4m+A6E3OvRcOVfmx+JCgSUhHJtUDlFijLhfjF9GzR+Yy5lU76cAIzmcoh\n         f0meYorTbcBqjlKGRjjWwo2anNpES6Dcy6LeVDLp7D9ljeW8yGVhhayCvzY+2M7IxEMD\n         FZhRFV8WbS5lMyrAtPzl7CunAhIwnxHxPLRDMOHUJNPP6sAxhWwePLeTn6ArcWYBDtpw\n         SWeiPuVan5eO1uTbp8RhROUouxAsW+aZCzg9vm6CiWrdBTLAXBQ4yna6okVS2a8gDa9w\n         AClQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776333435; x=1776938235;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=H/1T705jUCHUuc7zYF9p5WCGH43XsT88FDPreDZ7P4Y=;\n        b=ncKI9gllIHD1bnJ5MbT7S8rWP3cQUldvCbhkoOyOVJps47COCmt0pO7ttXcdAxhnjm\n         0/n/avaCPDqKGKlxqF4KSDhb9bkf0izhi5CUZvNtAYXO4Qi+W6NV9P9rn7Yjowx7kSd3\n         VP2VetSGCdOTh/y6eyYTdiLsmlR0ozCuSX1Ofo9vyBtDXHzYWxxtBn8y/KVdQ7058deb\n         WvDQZQFzJRb0Rdz2kEoFek0CnT9/fUz8iA14mxvH3Zf+nLU8St0E+2s/v530VHt76t+3\n         T3u/Il4ObrC/he7+h8S62PAVuHE9aGhDOmI8HqWTlBS2IiXumTRukosKuKRYLCHvMqCe\n         BNfQ==","X-Gm-Message-State":"AOJu0YzLjPzuu8Zf/dqy6FYM3ZKHlDDP7+OE+MaZ9fysbRCtHsMEaFS6\n\tDp4TP89rV+60QleIr1aJF1RMDMVL7Prnpbb8ELeidz7hnvP3tVl+l9e+EPZ/Onu2Mg==","X-Gm-Gg":"AeBDieuzI7julj+ySxPhuUgC3FVkd+yoCMOBx150mMMd1gddKA+VRIPEW62s2gpG2cX\n\t4d92igkqyu2GMMAoTLTC4f5aOFY0z4ers4luyutFyRO2mBBWAAHse5HVLpPM42/uszcYBqfgpk5\n\t4Kt3mCzYny7az4Gf3QdH7pv0hpoC9KfSlpBOvAkPvqOilprwkKRPrqbAezh6wPKfmP2hHWi/wDh\n\tmxIu7YDS4mNmgHuS/jXIjfoTPntOiF4pEdIogg45X+6dB8lmi+KmuIsEhwTQLu68HGxhbAIAchE\n\t49U7D9Mb/zpammAXl1MgpgTIJQNZnQDhK1HdWELppOuy2lvo/uVhz+GD5mrlGjul7mofwGAq9jk\n\tF5xJ6sX7cSZW1rwRYr5UgxZoqGSdx1pf5+6qu/kXEwCIn5PG+6vhzv/3XUm1gNxC0B4jjxEiNog\n\tEMHd48m4G3Z8/htWI9VhjmhMzTlUpwUWPxuBmawlnnvivc1U2W7nbr8VHHXR8=","X-Received":"by 2002:a05:7022:6888:b0:119:e56b:c3f1 with SMTP id\n a92af1059eb24-12c658ed58cmr333493c88.1.1776333434608;\n        Thu, 16 Apr 2026 02:57:14 -0700 (PDT)","From":"Adriana Stancu <adriana@arista.com>","To":"alexandre.belloni@bootlin.com","Cc":"linux-rtc@vger.kernel.org,\n\tdevicetree@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\trobh@kernel.org,\n\tkrzk+dt@kernel.org,\n\tconor+dt@kernel.org,\n\tAdriana Stancu <adriana@arista.com>","Subject":"[PATCH v2 2/2] rtc: bq32000: add configurable delay between RTC reads","Date":"Thu, 16 Apr 2026 02:57:06 -0700","Message-ID":"<20260416095706.3212158-3-adriana@arista.com>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20260416095706.3212158-1-adriana@arista.com>","References":"<20260416092414.3210383-1-adriana@arista.com>\n <20260416095706.3212158-1-adriana@arista.com>","Precedence":"bulk","X-Mailing-List":"linux-rtc@vger.kernel.org","List-Id":"<linux-rtc.vger.kernel.org>","List-Subscribe":"<mailto:linux-rtc+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-rtc+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"When the RTC is used on systems without a interrupt line, userspace tools\nlike \"hwclock\" fall back to a frequent polling loop to synchronize with\nthe edge of the next second.\n\nOn the BQ32000, this aggressive polling can temporarly lock the register\nrefresh cycle, because the continuous transfers prevent the hardware from\nupdating the buffer. This results in stale data reads or select() timeouts\nin userspace.\n\nThis patch introduces a configurable settle delay via \"ti,read-settle-us\"\nproperty. If this property is specified, the driver uses a delay before\nreading the RTC registers. This provides a sufficient idle time for the\nhardware to sync with the register buffer.\n\nSigned-off-by: Adriana Stancu <adriana@arista.com>\n---\n drivers/rtc/rtc-bq32k.c | 34 ++++++++++++++++++++++++++++------\n 1 file changed, 28 insertions(+), 6 deletions(-)","diff":"diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c\nindex 7ad34539be4d..0cbfa0909732 100644\n--- a/drivers/rtc/rtc-bq32k.c\n+++ b/drivers/rtc/rtc-bq32k.c\n@@ -16,6 +16,7 @@\n #include <linux/kstrtox.h>\n #include <linux/errno.h>\n #include <linux/bcd.h>\n+#include <linux/delay.h>\n \n #define BQ32K_SECONDS\t\t0x00\t/* Seconds register address */\n #define BQ32K_SECONDS_MASK\t0x7F\t/* Mask over seconds value */\n@@ -48,6 +49,11 @@ struct bq32k_regs {\n \tuint8_t\t\tyears;\n };\n \n+struct bq32k_data {\n+\tstruct rtc_device *rtc;\n+\tu32 read_delay_us;\n+};\n+\n static struct i2c_driver bq32k_driver;\n \n static int bq32k_read(struct device *dev, void *data, uint8_t off, uint8_t len)\n@@ -89,9 +95,17 @@ static int bq32k_write(struct device *dev, void *data, uint8_t off, uint8_t len)\n \n static int bq32k_rtc_read_time(struct device *dev, struct rtc_time *tm)\n {\n+\tstruct bq32k_data *bq32k = dev_get_drvdata(dev);\n \tstruct bq32k_regs regs;\n \tint error;\n \n+\t/*\n+\t * When the device doesn't have the interrupt connected, prevent\n+\t * userpace from polling the RTC registers to frequently.\n+\t */\n+\tif (bq32k && bq32k->read_delay_us)\n+\t\tusleep_range(bq32k->read_delay_us, bq32k->read_delay_us + 50);\n+\n \terror = bq32k_read(dev, &regs, 0, sizeof(regs));\n \tif (error)\n \t\treturn error;\n@@ -253,13 +267,18 @@ static void bq32k_sysfs_unregister(struct device *dev)\n static int bq32k_probe(struct i2c_client *client)\n {\n \tstruct device *dev = &client->dev;\n-\tstruct rtc_device *rtc;\n+\tstruct bq32k_data *bq32k;\n \tuint8_t reg;\n \tint error;\n+\tuint32_t settle_us = 0;\n \n \tif (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))\n \t\treturn -ENODEV;\n \n+\tbq32k = devm_kzalloc(dev, sizeof(*bq32k), GFP_KERNEL);\n+\tif (!bq32k)\n+\t\treturn -ENOMEM;\n+\n \t/* Check Oscillator Stop flag */\n \terror = bq32k_read(dev, &reg, BQ32K_SECONDS, 1);\n \tif (!error && (reg & BQ32K_STOP)) {\n@@ -280,10 +299,13 @@ static int bq32k_probe(struct i2c_client *client)\n \tif (client->dev.of_node)\n \t\ttrickle_charger_of_init(dev, client->dev.of_node);\n \n-\trtc = devm_rtc_device_register(&client->dev, bq32k_driver.driver.name,\n-\t\t\t\t\t\t&bq32k_rtc_ops, THIS_MODULE);\n-\tif (IS_ERR(rtc))\n-\t\treturn PTR_ERR(rtc);\n+\tbq32k->rtc = devm_rtc_device_register(&client->dev, bq32k_driver.driver.name,\n+\t\t\t\t\t      &bq32k_rtc_ops, THIS_MODULE);\n+\tif (IS_ERR(bq32k->rtc))\n+\t\treturn PTR_ERR(bq32k->rtc);\n+\n+\tdevice_property_read_u32(dev, \"ti,read-settle-us\", &settle_us);\n+\tbq32k->read_delay_us = settle_us;\n \n \terror = bq32k_sysfs_register(&client->dev);\n \tif (error) {\n@@ -293,7 +315,7 @@ static int bq32k_probe(struct i2c_client *client)\n \t}\n \n \n-\ti2c_set_clientdata(client, rtc);\n+\ti2c_set_clientdata(client, bq32k);\n \n \treturn 0;\n }\n","prefixes":["v2","2/2"]}