From: "Michael Walle" <mwalle@kernel.org>
To: <sashiko-reviews@lists.linux.dev>
Cc: <linux-rtc@vger.kernel.org>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH] rtc: pcf8563: add SMBus support
Date: Wed, 30 Sep 2026 14:06:44 +0200 [thread overview]
Message-ID: <DLSMZIXCSAAK.ZBI487G8BST7@kernel.org> (raw)
In-Reply-To: <20260930114005.2C6661F000FF@smtp.kernel.org>
On Wed Sep 30, 2026 at 1:40 PM CEST, sashiko-bot wrote:
> [Severity: High]
> Could removing this check lead to time tearing on restricted SMBus adapters?
>
> While the commit message mentions SMBus controllers supporting block
> accesses, removing the check entirely delegates bus validation to regmap. If
> the adapter only supports I2C_FUNC_SMBUS_BYTE_DATA and lacks block transfer
> capabilities, regmap silently falls back to regmap_smbus_byte:
That is actually correct. But I'm not sure how this is handled in
the RTC subsystem (?). I've looked at other drivers (e.g. ds1307,
rv3028), which are using regmap and there seems to be no check
either.
-michael
> drivers/base/regmap/regmap-i2c.c:regmap_get_i2c_bus() {
> ...
> else if (config->val_bits == 8 && config->reg_bits == 8 &&
> i2c_check_functionality(i2c->adapter,
> I2C_FUNC_SMBUS_BYTE_DATA))
> bus = ®map_smbus_byte;
> ...
> }
>
> Because of this fallback, when pcf8563_rtc_read_time() reads the time:
>
> drivers/rtc/rtc-pcf8563.c:pcf8563_rtc_read_time() {
> ...
> err = regmap_bulk_read(pcf8563->regmap, PCF8563_REG_ST1, buf,
> sizeof(buf));
> ...
> }
>
> The bulk read executes as a loop of separate single-byte SMBus reads instead
> of an atomic transaction. Since each SMBus byte transaction issues its own
> STOP condition, the RTC's internal register latch is released between reads.
>
> Does this allow the hardware time to roll over mid-read and result in
> corrupt time data?
>
>> pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563),
>> GFP_KERNEL);
>> if (!pcf8563)
next prev parent reply other threads:[~2026-09-30 12:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 11:30 [PATCH] rtc: pcf8563: add SMBus support Michael Walle
2026-09-30 11:40 ` sashiko-bot
2026-09-30 12:06 ` Michael Walle [this message]
2026-09-30 15:25 ` Alexandre Belloni
2026-10-01 13:24 ` Michael Walle
2026-10-01 21:44 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DLSMZIXCSAAK.ZBI487G8BST7@kernel.org \
--to=mwalle@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-rtc@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox