From: sashiko-bot@kernel.org
To: "Antoni Pokusinski" <apokusinski01@gmail.com>
Cc: robh@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
conor+dt@kernel.org, linux-rtc@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 4/8] rtc: abx80x: add irq to struct abx80x_priv
Date: Sat, 25 Jul 2026 15:12:57 +0000 [thread overview]
Message-ID: <20260725151258.3931E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725145718.14733-5-apokusinski01@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The interrupt handler indiscriminately clears unrelated and newly arrived interrupts due to a read-modify-write race condition.
--
--- Patch [4]: [PATCH v2 4/8] rtc: abx80x: add irq to struct abx80x_priv ---
commit c9bf7d6c99deb7b828f721f449db552d3b1510a0
Author: Antoni Pokusinski <apokusinski01@gmail.com>
rtc: abx80x: add irq to struct abx80x_priv
This patch adds an irq field to the abx80x_priv struct to decouple the
interrupt number from the i2c_client. This enables the irq to be easily
accessed for both i2c and spi variants. It also updates the interrupt
handler to selectively clear status bits.
> diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> index 5486d9d0b1e5d..b83c789e213d6 100644
> --- a/drivers/rtc/rtc-abx80x.c
> +++ b/drivers/rtc/rtc-abx80x.c
[ ... ]
> @@ -261,35 +262,43 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
> struct i2c_client *client = dev_id;
> struct abx80x_priv *priv = i2c_get_clientdata(client);
> struct rtc_device *rtc = priv->rtc;
> + irqreturn_t handled = IRQ_NONE;
> int status;
>
> status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
> if (status < 0)
> - return IRQ_NONE;
> + return handled;
>
> - if (status & ABX8XX_STATUS_AF)
> + if (status & ABX8XX_STATUS_AF) {
> rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF);
> + handled = IRQ_HANDLED;
> + }
>
> /*
> * It is unclear if we'll get an interrupt before the external
> * reset kicks in.
> */
> - if (status & ABX8XX_STATUS_WDT)
> + if (status & ABX8XX_STATUS_WDT) {
> dev_alert(&client->dev, "watchdog timeout interrupt.\n");
> + handled = IRQ_HANDLED;
> + }
>
> - i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0);
> + if (handled == IRQ_HANDLED)
> + i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS,
> + status & ~(ABX8XX_STATUS_AF | ABX8XX_STATUS_WDT));
[Severity: High]
Does this status write introduce a race condition that could cause us to lose
newly arrived interrupts?
If a new interrupt (such as a watchdog or alarm event) triggers immediately
after the status register is read, its corresponding hardware bit becomes 1,
but it remains 0 in the local status variable.
When writing back status & ~(ABX8XX_STATUS_AF | ABX8XX_STATUS_WDT), this
writes 0 to the newly triggered interrupt's bit. Since this chip appears to
use write-0-to-clear semantics, writing 0 clears the new interrupt before it
can be handled, effectively losing the hardware event.
Would it be better to write ~(ABX8XX_STATUS_AF | ABX8XX_STATUS_WDT) directly
to ensure any unhandled bits remain untouched?
> - return IRQ_HANDLED;
> + return handled;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725145718.14733-1-apokusinski01@gmail.com?part=4
next prev parent reply other threads:[~2026-07-25 15:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 14:57 [PATCH v2 0/8] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-07-25 14:57 ` [PATCH v2 1/8] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-07-25 15:04 ` Krzysztof Kozlowski
2026-07-25 15:11 ` sashiko-bot
2026-07-25 14:57 ` [PATCH v2 2/8] rtc: abx80x: move part autodetection before RV1805 configuration Antoni Pokusinski
2026-07-25 15:07 ` sashiko-bot
2026-07-25 14:57 ` [PATCH v2 3/8] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-07-25 15:14 ` sashiko-bot
2026-07-25 14:57 ` [PATCH v2 4/8] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-07-25 15:12 ` sashiko-bot [this message]
2026-07-25 14:57 ` [PATCH v2 5/8] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-07-25 15:13 ` sashiko-bot
2026-07-25 14:57 ` [PATCH v2 6/8] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-07-25 15:12 ` sashiko-bot
2026-07-25 14:57 ` [PATCH v2 7/8] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-07-25 15:13 ` sashiko-bot
2026-07-25 14:57 ` [PATCH v2 8/8] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-07-25 15:30 ` 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=20260725151258.3931E1F000E9@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