From: Antoni Pokusinski <apokusinski01@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH v5 3/9] rtc: abx80x: add mutex protection for register writes
Date: Thu, 3 Sep 2026 22:21:32 +0200 [thread overview]
Message-ID: <apnV9eSqJtBUoyId@antoniarch> (raw)
In-Reply-To: <20260811195656.691DC1F00A3A@smtp.kernel.org>
On Tue, Aug 11, 2026 at 07:56:55PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [Medium] The patch adds a mutex (`priv->lock`) to protect multi-step write sequences (like configuration key writes followed by register writes) but fails to acquire it during I2C read operations. Because interleaved I2C access resets the hardware configuration key on this RTC chip, concurrent unprotected reads can silently abort active write sequences in other threads.
> --
>
> --- Patch [3]: [PATCH v5 3/9] rtc: abx80x: add mutex protection for register writes ---
> commit 22bce01eb8bed117145738b82a585f1daa2c3fdc
> Author: Antoni Pokusinski <apokusinski01@gmail.com>
>
> rtc: abx80x: add mutex protection for register writes
>
> This patch introduces a mutex to serialize multi-step register writes
> on the ABX80X RTC, such as NVMEM transfers and configuration key writes.
> It uses scoped guards to protect these sequences from race conditions.
>
> > diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> > index fdf9664ebb6f0..0c8d3416fd5a9 100644
> > --- a/drivers/rtc/rtc-abx80x.c
> > +++ b/drivers/rtc/rtc-abx80x.c
> [ ... ]
> > @@ -234,6 +237,8 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
> > buf[ABX8XX_REG_YR] = bin2bcd(tm->tm_year - 100);
> > buf[ABX8XX_REG_WD] = tm->tm_wday;
> >
> > + guard(mutex)(&priv->lock);
> > +
> > err = i2c_smbus_write_i2c_block_data(client, ABX8XX_REG_HTH,
> > sizeof(buf), buf);
>
> [Severity: Medium]
> This is a pre-existing issue, but do read operations like
> abx80x_rtc_read_time() and abx80x_read_alarm() also need to take
> priv->lock?
>
> If a process reads the time or alarm concurrently with a configuration key
> write sequence (like a sysfs store to the oscillator or autocalibration
> attributes), could the read operation interleave and silently reset the
> hardware unlock state?
>
> This would cause the subsequent configuration write to fail, since interleaved
> I2C access resets the hardware configuration key on this chip.
>
> [ ... ]
Not true, reading the registers does not cause a configuration key reset
> > @@ -539,16 +559,18 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
> > return put_user(tmp, (unsigned int __user *)arg);
> >
> > case RTC_VL_CLR:
> > - status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
> > - if (status < 0)
> > - return status;
> > + scoped_guard(mutex, &priv->lock) {
> > + status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
> > + if (status < 0)
> > + return status;
>
> [Severity: Medium]
> This is a pre-existing issue, but does the RTC_VL_READ case just above
> this block in abx80x_ioctl() also need to acquire the mutex?
>
> Since the read case performs an unprotected I2C read, it could bypass
> the lock and abort active locked write sequences in other threads.
>
As above, the read does cause configuration key reset.
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260811194034.28937-1-apokusinski01@gmail.com?part=3
next prev parent reply other threads:[~2026-09-03 20:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 19:40 [PATCH v5 0/9] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-08-11 19:40 ` [PATCH v5 1/9] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-08-11 19:48 ` sashiko-bot
2026-08-11 19:40 ` [PATCH v5 2/9] rtc: abx80x: fix error check after i2c_smbus_read in read_alarm() Antoni Pokusinski
2026-08-11 19:55 ` sashiko-bot
2026-08-11 19:40 ` [PATCH v5 3/9] rtc: abx80x: add mutex protection for register writes Antoni Pokusinski
2026-08-11 19:56 ` sashiko-bot
2026-09-03 20:21 ` Antoni Pokusinski [this message]
2026-08-11 19:40 ` [PATCH v5 4/9] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-08-11 19:53 ` sashiko-bot
2026-08-11 19:40 ` [PATCH v5 5/9] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-08-11 19:51 ` sashiko-bot
2026-08-11 19:40 ` [PATCH v5 6/9] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-08-11 19:55 ` sashiko-bot
2026-08-11 19:40 ` [PATCH v5 7/9] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-08-11 19:56 ` sashiko-bot
2026-09-03 21:25 ` Antoni Pokusinski
2026-08-11 19:40 ` [PATCH v5 8/9] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-08-11 19:54 ` sashiko-bot
2026-08-11 19:40 ` [PATCH v5 9/9] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-08-11 20:03 ` 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=apnV9eSqJtBUoyId@antoniarch \
--to=apokusinski01@gmail.com \
--cc=alexandre.belloni@bootlin.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.