From: Antoni Pokusinski <apokusinski01@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
robh@kernel.org, devicetree@vger.kernel.org,
linux-rtc@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 3/8] rtc: abx80x: properly handle shared IRQs
Date: Tue, 4 Aug 2026 23:05:59 +0200 [thread overview]
Message-ID: <anJQBtfXjktYm6Cw@antoniarch> (raw)
In-Reply-To: <20260731190522.C11D41F00AC4@smtp.kernel.org>
On Fri, Jul 31, 2026 at 07:05:22PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Returning IRQ_NONE without masking or clearing unhandled RTC interrupts can cause an interrupt storm on the shared IRQ line.
> --
>
> --- Patch [3]: [PATCH v3 3/8] rtc: abx80x: properly handle shared IRQs ---
> commit e06155ed4aeb662277df57a2324e881c6d065e84
> Author: Antoni Pokusinski <apokusinski01@gmail.com>
>
> rtc: abx80x: properly handle shared IRQs
>
> This commit modifies the abx80x interrupt handler to only claim the IRQ and
> clear the status register if the alarm or watchdog flags are explicitly set.
> It aims to prevent claiming interrupts from other devices sharing the same
> IRQ line.
>
> > 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
>
> [ ... ]
>
> > @@ -266,27 +266,34 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
>
> [ ... ]
>
> > - 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));
> >
> > - return IRQ_HANDLED;
> > + return handled;
>
> [Severity: High]
> If the RTC hardware asserts an interrupt for a reason other than AF or WDT
> (for example, a timer or century interrupt left enabled by a bootloader),
> will this cause an interrupt storm?
>
> Because handled remains IRQ_NONE, the handler skips the i2c_smbus_write_byte_data()
> call and returns IRQ_NONE without clearing the unhandled RTC status bits.
>
> Since the unhandled RTC interrupt is never cleared, the IRQ line will remain
> asserted. This causes the kernel to immediately re-enter the handler until
> the spurious IRQ detector steps in and completely disables the shared IRQ line.
>
> Could we check if the status register indicates the interrupt originated
> from this RTC, clear those bits, and return IRQ_HANDLED?
Ok so it turns out that neither the current nor the newly proposed interrupt
handling is correct.
The current approach is that we write 0 to REG_STATUS so we clear
e.g. the BL flag which prevents the userspace from detecting a low
battery. Also, IRQ_HANDLED is returned unconditionally which prevents
handling a potential interrupt from another shared device.
The new approach that I've added in this v3 is not ok neither
since (as sashiko points out) any interrupt other than AF or WDT may be
enabled e.g. by the bootloader and in this case we'd get an interrupt
storm.
In v4 I'll improve the new solution with explicitly disabling the
interrupts that are not used in the probe function. That is:
* disable EX1, EX2, Timer, BL interrupts in REG_IRQ
* disable "oscillator fail" and "autocalibration fail" interrupts in REG_OSC
>
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260731184831.44037-1-apokusinski01@gmail.com?part=3
next prev parent reply other threads:[~2026-08-04 21:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 18:48 [PATCH v3 0/8] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-07-31 18:48 ` [PATCH v3 1/8] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-07-31 18:57 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 2/8] rtc: abx80x: add mutex protection for register writes Antoni Pokusinski
2026-07-31 19:02 ` sashiko-bot
2026-08-03 20:48 ` Antoni Pokusinski
2026-07-31 18:48 ` [PATCH v3 3/8] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-07-31 19:05 ` sashiko-bot
2026-08-04 21:05 ` Antoni Pokusinski [this message]
2026-07-31 18:48 ` [PATCH v3 4/8] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-07-31 19:04 ` sashiko-bot
2026-08-03 20:31 ` Antoni Pokusinski
2026-07-31 18:48 ` [PATCH v3 5/8] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-07-31 19:05 ` sashiko-bot
2026-08-03 20:53 ` Antoni Pokusinski
2026-07-31 18:48 ` [PATCH v3 6/8] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-07-31 19:01 ` sashiko-bot
2026-08-03 20:57 ` Antoni Pokusinski
2026-07-31 18:48 ` [PATCH v3 7/8] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-07-31 19:02 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 8/8] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-07-31 19:05 ` 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=anJQBtfXjktYm6Cw@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox