The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] i2c: spacemit: fix spurious IRQ handling returning IRQ_HANDLED
@ 2026-07-09  9:54 Pei Xiao
  2026-07-09 10:16 ` Troy Mitchell
       [not found] ` <1783645601561936.18899.seg@mailgw.kylinos.cn>
  0 siblings, 2 replies; 4+ messages in thread
From: Pei Xiao @ 2026-07-09  9:54 UTC (permalink / raw)
  To: troy.mitchell, andi.shyti, linux-i2c, linux-kernel, spacemit,
	linux-riscv
  Cc: Pei Xiao

When the interrupt status register reads zero (no interrupt pending
from this device), the handler should return IRQ_NONE. Returning
IRQ_HANDLED incorrectly claims the interrupt was serviced, which can
prevent other devices sharing the same IRQ line from receiving their
interrupts.

Fix this by returning IRQ_NONE instead of IRQ_HANDLED when the
status register is zero.

Fixes: 5ea558473fa3 ("i2c: spacemit: add support for SpacemiT K1 SoC")
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/i2c/busses/i2c-k1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index c2d090f6ba80..487f23fde725 100644
--- a/drivers/i2c/busses/i2c-k1.c
+++ b/drivers/i2c/busses/i2c-k1.c
@@ -728,7 +728,7 @@ static irqreturn_t spacemit_i2c_irq_handler(int irq, void *devid)
 
 	status = readl(i2c->base + SPACEMIT_ISR);
 	if (!status)
-		return IRQ_HANDLED;
+		return IRQ_NONE;
 
 	i2c->status = status;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: spacemit: fix spurious IRQ handling returning IRQ_HANDLED
  2026-07-09  9:54 [PATCH] i2c: spacemit: fix spurious IRQ handling returning IRQ_HANDLED Pei Xiao
@ 2026-07-09 10:16 ` Troy Mitchell
       [not found] ` <1783645601561936.18899.seg@mailgw.kylinos.cn>
  1 sibling, 0 replies; 4+ messages in thread
From: Troy Mitchell @ 2026-07-09 10:16 UTC (permalink / raw)
  To: Pei Xiao, troy.mitchell, andi.shyti, linux-i2c, linux-kernel,
	spacemit, linux-riscv

On Thu Jul 9, 2026 at 2:54 AM PDT, Pei Xiao wrote:
> When the interrupt status register reads zero (no interrupt pending
> from this device), the handler should return IRQ_NONE. Returning
> IRQ_HANDLED incorrectly claims the interrupt was serviced, which can
> prevent other devices sharing the same IRQ line from receiving their
> interrupts.
>
> Fix this by returning IRQ_NONE instead of IRQ_HANDLED when the
> status register is zero.
The change goes in the right direction, but the rationale in the
commit message doesn't hold, and I think the check itself can be
improved.

This driver requests its IRQ without IRQF_SHARED (see
spacemit_i2c_probe(), which passes only IRQF_NO_SUSPEND), so there
are no "other devices sharing the same IRQ line" to begin with.
Even on a genuinely shared line, the kernel invokes every handler
registered on the line regardless of what previous handlers return,
so IRQ_HANDLED cannot prevent other handlers from running.

What the return value actually feeds into is the spurious interrupt
accounting in note_interrupt(): falsely claiming IRQ_HANDLED defeats
the "irq XX: nobody cared" detection, so a stuck interrupt source
would never be caught. That applies to dedicated lines as well, and
is the real justification for this change.

Could you rework the check and the commit message and send a v2?

                                  - Troy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: spacemit: fix spurious IRQ handling returning IRQ_HANDLED
       [not found] ` <1783645601561936.18899.seg@mailgw.kylinos.cn>
@ 2026-07-10  1:10   ` Pei Xiao
  0 siblings, 0 replies; 4+ messages in thread
From: Pei Xiao @ 2026-07-10  1:10 UTC (permalink / raw)
  To: Troy Mitchell, andi.shyti, linux-i2c, linux-kernel, spacemit,
	linux-riscv



在 2026/7/9 18:16, Troy Mitchell 写道:
> On Thu Jul 9, 2026 at 2:54 AM PDT, Pei Xiao wrote:
>> When the interrupt status register reads zero (no interrupt pending
>> from this device), the handler should return IRQ_NONE. Returning
>> IRQ_HANDLED incorrectly claims the interrupt was serviced, which can
>> prevent other devices sharing the same IRQ line from receiving their
>> interrupts.
>>
>> Fix this by returning IRQ_NONE instead of IRQ_HANDLED when the
>> status register is zero.
> The change goes in the right direction, but the rationale in the
> commit message doesn't hold, and I think the check itself can be
> improved.
>
> This driver requests its IRQ without IRQF_SHARED (see
> spacemit_i2c_probe(), which passes only IRQF_NO_SUSPEND), so there
> are no "other devices sharing the same IRQ line" to begin with.
> Even on a genuinely shared line, the kernel invokes every handler
> registered on the line regardless of what previous handlers return,
> so IRQ_HANDLED cannot prevent other handlers from running.
Thanks for pointing out!
>
> What the return value actually feeds into is the spurious interrupt
> accounting in note_interrupt(): falsely claiming IRQ_HANDLED defeats
> the "irq XX: nobody cared" detection, so a stuck interrupt source
> would never be caught. That applies to dedicated lines as well, and
> is the real justification for this change.
>
> Could you rework the check and the commit message and send a v2?
yes, I will check again and send a v2.

Thanks! 
Pei.
>                                   - Troy


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] i2c: spacemit: fix spurious IRQ handling returning IRQ_HANDLED
@ 2026-07-10  7:14 Pei Xiao
  0 siblings, 0 replies; 4+ messages in thread
From: Pei Xiao @ 2026-07-10  7:14 UTC (permalink / raw)
  To: troy.mitchell, andi.shyti, linux-i2c, linux-kernel, linux-riscv,
	spacemit
  Cc: Pei Xiao

When the interrupt status register reads zero, the handler should
return IRQ_NONE instead of IRQ_HANDLED. What the return value
actually feeds into is the spurious interrupt accounting in
note_interrupt(): falsely claiming IRQ_HANDLED defeats the "irq XX:
nobody cared" detection, so a stuck interrupt source would never be
caught.

Fixes: 5ea558473fa3 ("i2c: spacemit: add support for SpacemiT K1 SoC")
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/i2c/busses/i2c-k1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
index c2d090f6ba80..487f23fde725 100644
--- a/drivers/i2c/busses/i2c-k1.c
+++ b/drivers/i2c/busses/i2c-k1.c
@@ -728,7 +728,7 @@ static irqreturn_t spacemit_i2c_irq_handler(int irq, void *devid)
 
 	status = readl(i2c->base + SPACEMIT_ISR);
 	if (!status)
-		return IRQ_HANDLED;
+		return IRQ_NONE;
 
 	i2c->status = status;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-10  7:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09  9:54 [PATCH] i2c: spacemit: fix spurious IRQ handling returning IRQ_HANDLED Pei Xiao
2026-07-09 10:16 ` Troy Mitchell
     [not found] ` <1783645601561936.18899.seg@mailgw.kylinos.cn>
2026-07-10  1:10   ` Pei Xiao
  -- strict thread matches above, loose matches on Subject: below --
2026-07-10  7:14 Pei Xiao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox