From: sashiko-bot@kernel.org
To: "Antoni Pokusinski" <apokusinski01@gmail.com>
Cc: linux-rtc@vger.kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 7/9] rtc: abx80x: replace read-modify-write pattern with regmap helpers
Date: Fri, 14 Aug 2026 02:07:00 +0000 [thread overview]
Message-ID: <20260814020700.D9CE51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810193826.210683-8-apokusinski01@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Using regmap_update_bits() or regmap_write_bits() breaks the hardware Configuration Key unlock sequence by injecting an I2C read between the unlock write and the protected register write.
--
--- Patch [7]: [PATCH v4 7/9] rtc: abx80x: replace read-modify-write pattern with regmap helpers ---
commit 9a313450ff6d4e2395638f901f9fccf926bd1dda
Author: Antoni Pokusinski <apokusinski01@gmail.com>
rtc: abx80x: replace read-modify-write pattern with regmap helpers
This commit replaces manual read-modify-write sequences with
regmap_update_bits() and regmap_write_bits() to simplify the code.
> diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> index 5d41882f3c704..ab88af43b4fa0 100644
> --- a/drivers/rtc/rtc-abx80x.c
> +++ b/drivers/rtc/rtc-abx80x.c
[ ... ]
> @@ -403,13 +389,15 @@ static int abx80x_rtc_set_autocalibration(struct device *dev,
> flags |= (ABX8XX_OSC_ACAL_1024 | ABX8XX_OSC_ACAL_512);
> }
>
> + guard(mutex)(&priv->lock);
> +
> /* Unlock write access to Oscillator Control Register */
> if (abx80x_write_config_key(dev, ABX8XX_CFG_KEY_OSC) < 0)
> return -EIO;
>
> - retval = regmap_write(priv->regmap, ABX8XX_REG_OSC, flags);
> -
> - return retval;
> + return regmap_write_bits(priv->regmap, ABX8XX_REG_OSC,
> + ABX8XX_OSC_ACAL_1024 | ABX8XX_OSC_ACAL_512,
> + flags);
> }
[Severity: High]
Does using regmap_write_bits() here break the hardware Configuration Key unlock
sequence?
Since regmap_write_bits() performs a read-modify-write cycle, it injects an
I2C read between the unlock write (abx80x_write_config_key) and the actual
register write.
If the hardware resets the key on any intervening I2C access, this might lock
the register again, causing the subsequent write to fail silently.
[ ... ]
> @@ -486,24 +473,14 @@ static ssize_t oscillator_store(struct device *dev,
[ ... ]
> /* Unlock write access on Oscillator Control register */
> if (abx80x_write_config_key(dev->parent, ABX8XX_CFG_KEY_OSC) < 0)
> return -EIO;
>
> - retval = regmap_write(priv->regmap, ABX8XX_REG_OSC, flags);
> - if (retval < 0) {
> + retval = regmap_write_bits(priv->regmap, ABX8XX_REG_OSC, ABX8XX_OSC_OSEL,
> + rc_mode == 0 ? 0 : (ABX8XX_OSC_OSEL));
> + if (retval < 0)
> dev_err(dev, "Failed to write Oscillator Control register\n");
[Severity: High]
Will this read-modify-write cycle also invalidate the unlock key before the
write occurs, similar to the issue in abx80x_rtc_set_autocalibration()?
[ ... ]
> @@ -946,8 +890,14 @@ static int abx80x_probe(struct i2c_client *client)
> if (abx80x_write_config_key(&client->dev, ABX8XX_CFG_KEY_MISC) < 0)
> return -EIO;
>
> - err = regmap_write(regmap, ABX8XX_REG_OUT_CTRL,
> - data | ABX8XX_OUT_CTRL_EXDS);
> + /*
> + * Avoid extra power leakage. The RV1805 uses smaller
> + * 10pin package and the EXTI input is not present.
> + * Disable it to avoid leakage.
> + */
> + err = regmap_write_bits(regmap, ABX8XX_REG_OUT_CTRL,
> + ABX8XX_OUT_CTRL_EXDS,
> + ABX8XX_OUT_CTRL_EXDS);
> if (err < 0) {
> dev_err(&client->dev,
> "Unable to write output control register\n");
[Severity: High]
Could the implicit I2C read inside regmap_write_bits() invalidate the MISC
unlock key here as well, causing the EXTI disable write to fail on RV1805
chips and leading to extra power leakage?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810193826.210683-1-apokusinski01@gmail.com?part=7
next prev parent reply other threads:[~2026-08-14 2:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 19:38 [PATCH v4 0/9] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-08-10 19:38 ` [PATCH v4 1/9] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-08-14 0:47 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 2/9] rtc: abx80x: fix error check after i2c_smbus_read in read_alarm() Antoni Pokusinski
2026-08-14 1:02 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 3/9] rtc: abx80x: add mutex protection for register writes Antoni Pokusinski
2026-08-14 1:20 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 4/9] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-08-14 1:33 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 5/9] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-08-14 1:44 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 6/9] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-08-14 1:57 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 7/9] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-08-14 2:07 ` sashiko-bot [this message]
2026-08-10 19:38 ` [PATCH v4 8/9] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-08-14 2:15 ` sashiko-bot
2026-08-10 19:38 ` [PATCH v4 9/9] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-08-14 2:31 ` sashiko-bot
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=20260814020700.D9CE51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=apokusinski01@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=robh@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