From: Antoni Pokusinski <apokusinski01@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, linux-rtc@vger.kernel.org,
devicetree@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
conor+dt@kernel.org
Subject: Re: [PATCH v7 4/9] rtc: abx80x: properly handle shared IRQs
Date: Thu, 17 Sep 2026 20:00:44 +0200 [thread overview]
Message-ID: <aqwpLXghj-NWgH8w@antoniarch> (raw)
In-Reply-To: <20260916210527.CF14B1F0089A@smtp.kernel.org>
On Wed, Sep 16, 2026 at 09:05:27PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] rtc: abx80x: race condition loses interrupts due to flawed W0C status register clearing
> --
>
> commit 27cfcb7135851594344aa538f01f8ef1328d2392
> Author: Antoni Pokusinski <apokusinski01@gmail.com>
>
> rtc: abx80x: properly handle shared IRQs
>
> This commit updates the abx80x RTC interrupt handler to only return
> IRQ_HANDLED and clear the status register when the alarm or watchdog flags
> are set. It aims to properly support IRQF_SHARED by returning IRQ_NONE
> for unrelated interrupts.
>
> > diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> > --- a/drivers/rtc/rtc-abx80x.c
> > +++ b/drivers/rtc/rtc-abx80x.c
>
> [ ... ]
>
> > @@ -284,9 +291,15 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
> > if (status & ABX8XX_STATUS_WDT)
> > dev_alert(&client->dev, "watchdog timeout interrupt.\n");
> >
> > - i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0);
> > + status_flags_clear = status & (ABX8XX_STATUS_AF | ABX8XX_STATUS_WDT);
> >
> > - return IRQ_HANDLED;
> > + if (status_flags_clear) {
> > + i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS,
> > + status & ~status_flags_clear);
>
> [Severity: High]
> Does this logic introduce a race condition that loses late-arriving interrupts
> in abx80x_handle_irq()?
>
> Because the ABX8XX_REG_STATUS register is W0C (write-0-to-clear), any bit
> written as 0 will be cleared in hardware.
>
> The expression status & ~status_flags_clear forces a 0 for all bits that
> were 0 during the initial read. If a new hardware interrupt asserts between
> the read and this write, its status bit will be newly set to 1 in hardware.
> However, writing back the old status value forces a 0 for that new bit,
> silently clearing it and losing the event.
>
> To preserve unhandled or newly asserted bits, the correct write value for a
> W0C register is ~status_flags_clear instead.
>
Not really: if the register bits are written with 1, then during the
next call to `handle_irq()` all the interrupts are reported as pending
(in other words the written ones are preserved).
In particular, when I was testing the alarm interrupt and the written value was
`~status_flags_clear` as sashiko suggests, I was always getting the WDT
bit enabled and hence the alert "watchdog timeout interrupt" was
printed.
> > + return IRQ_HANDLED;
> > + }
> > +
> > + return IRQ_NONE;
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260916205138.16771-1-apokusinski01@gmail.com?part=4
next prev parent reply other threads:[~2026-09-17 18:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 20:51 [PATCH v7 0/9] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-09-16 20:51 ` [PATCH v7 1/9] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-09-16 20:59 ` sashiko-bot
2026-09-16 20:51 ` [PATCH v7 2/9] rtc: abx80x: fix error check after i2c_smbus_read in read_alarm() Antoni Pokusinski
2026-09-16 21:01 ` sashiko-bot
2026-09-16 20:51 ` [PATCH v7 3/9] rtc: abx80x: add mutex protection for register writes Antoni Pokusinski
2026-09-16 21:02 ` sashiko-bot
2026-09-16 20:51 ` [PATCH v7 4/9] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-09-16 21:05 ` sashiko-bot
2026-09-17 18:00 ` Antoni Pokusinski [this message]
2026-09-16 20:51 ` [PATCH v7 5/9] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-09-16 20:59 ` sashiko-bot
2026-09-16 20:51 ` [PATCH v7 6/9] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-09-16 21:05 ` sashiko-bot
2026-09-16 20:51 ` [PATCH v7 7/9] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-09-16 21:05 ` sashiko-bot
2026-09-17 18:03 ` Antoni Pokusinski
2026-09-16 20:51 ` [PATCH v7 8/9] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-09-16 21:07 ` sashiko-bot
2026-09-16 20:51 ` [PATCH v7 9/9] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-09-16 21:06 ` sashiko-bot
2026-10-09 15:06 ` [PATCH v7 0/9] rtc: abx80x: add support for abx81x 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=aqwpLXghj-NWgH8w@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.