Skip to contentSkip to conversation

i2c: ls2x-v2: return IRQ_HANDLED after servicing an error

PATCH Applied David Carlier 5 participants 8 messages May 6 – Jun 16 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: ls2x-v2: return IRQ_HANDLED after servicing an error

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

Fixes 6d1b0785f6d5 ("i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller")
---
 drivers/i2c/busses/i2c-ls2x-v2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ls2x-v2.c +1 -1
index 517760d70169..9df73557ecc4 100644
@@ -304,7 +304,7 @@ static irqreturn_t loongson2_i2c_isr_event(int irq, void *data)
 	regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
 	if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
 		loongson2_i2c_isr_error(status, data);
-		return IRQ_NONE;
+		return IRQ_HANDLED;
 	}
 
 	regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);
Signature · 1 line
2.53.0
#1 lore raw
Quoted 6 lines · David Carlier

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

Quoted 6 lines

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Have you exhibited this on a real HW?

Quoted 2 lines

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

Hmm... This sounds logical, but we need the Loongson folks to confirm as this is sensitive code and changes like this may affect existing work flows.

Quoted 7 lines
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ls2x-v2.c +0 -0
index 517760d70169..9df73557ecc4 100644

drivers/i2c/busses/i2c-ls2x-v2.c static irqreturn_t loongson2_i2c_isr_event(int irq, void *data) · line 310

Quoted 8 lines
drivers/i2c/busses/i2c-ls2x-v2.c +1 -1
@@ -304,7 +304,7 @@ static irqreturn_t loongson2_i2c_isr_event(int irq, void *data)
 	regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
 	if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
 		loongson2_i2c_isr_error(status, data);
-		return IRQ_NONE;
+		return IRQ_HANDLED;
 	}
 
 	regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);

P.S.
Is the analysis and/or commit message AI assisted?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#2 lore raw

Hi all:

Quoted 13 lines · Andy Shevchenko
Quoted 6 lines · David Carlier

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

Quoted 6 lines

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Quoted 6 lines

Have you exhibited this on a real HW?

Quoted 2 lines

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

Hmm... This sounds logical, but we need the Loongson folks to confirm as this is sensitive code and changes like this may affect existing work flows.

I will try to test this boundary case in the next couple of days.

Quoted 15 lines
Quoted 15 lines
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ls2x-v2.c +1 -1
index 517760d70169..9df73557ecc4 100644
@@ -304,7 +304,7 @@ static irqreturn_t loongson2_i2c_isr_event(int irq, void *data)
  	regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
  	if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
  		loongson2_i2c_isr_error(status, data);
-		return IRQ_NONE;
+		return IRQ_HANDLED;
  	}
 
Quoted 3 lines

drivers/i2c/busses/i2c-ls2x-v2.c static irqreturn_t loongson2_i2c_isr_event(int irq, void *data) · line 310

Quoted 1 line
drivers/i2c/busses/i2c-ls2x-v2.c +0 -0
  	regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);

P.S.
Is the analysis and/or commit message AI assisted?

Thanks.
Binbin

Quoted 1 line

A message that is not in the archive (sent off-list or not yet received): CA+XhMqw=WCkAn66X=P29ojx=wOVezfjnwvDbxYnZ1FOK=4Z8ng@mail.gmail.com

#4 lore raw
Quoted 3 lines · David CARLIER
Quoted 1 line · On Wed, 6 May 2026, 10:12 Andy Shevchenko, <[email protected]> wrote:

On Wed, May 06, 2026 at 05:48:18AM +0100, David Carlier wrote:

...

Quoted 4 lines
Quoted 2 lines

Is the analysis and/or commit message AI assisted?

No h w but I Vs seen the pattern in another driver but I used codex to write commit message so I ll send a V2 later then. Cheers

Don't forget to mention any AI assistance. There is a special tag

Assisted-by IIRC, but dunno if it's for reports and/or code analysis.
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH v2 1/1 i2c: ls2x-v2: return IRQ_HANDLED after servicing an error

In reply to David Carlier

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

Fixes 6d1b0785f6d5 ("i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller")
Assisted-by Codex:GPT-5.5

---
v2:
- Add Assisted-by: Codex:GPT-5.5 trailer (no code change).

 drivers/i2c/busses/i2c-ls2x-v2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ls2x-v2.c +1 -1
index 517760d70169..9df73557ecc4 100644
@@ -304,7 +304,7 @@ static irqreturn_t loongson2_i2c_isr_event(int irq, void *data)
 	regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
 	if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
 		loongson2_i2c_isr_error(status, data);
-		return IRQ_NONE;
+		return IRQ_HANDLED;
 	}
 
 	regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#6 lore raw
Quoted 13 lines · David Carlier

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Quoted 2 lines

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

From the analysis and code sounds legit,

but my tag applies only after Loongson people confirm this is correct change.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by Tested-by on v2 1/1
#7 lore raw
In reply to David Carlier

Hi David:

Thanks for your patch.

Quoted 13 lines · David Carlier

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Quoted 6 lines

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

Fixes 6d1b0785f6d5 ("i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller")
Assisted-by Codex:GPT-5.5

I tested the above boundary conditions on the Loongson-2K0300 platform, and the issue does indeed exist.

Quoted 20 lines

---
v2:
- Add Assisted-by: Codex:GPT-5.5 trailer (no code change).

  drivers/i2c/busses/i2c-ls2x-v2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-ls2x-v2.c +1 -1
index 517760d70169..9df73557ecc4 100644
@@ -304,7 +304,7 @@ static irqreturn_t loongson2_i2c_isr_event(int irq, void *data)
  	regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
  	if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
  		loongson2_i2c_isr_error(status, data);
-		return IRQ_NONE;
+		return IRQ_HANDLED;
  	}
 
  	regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);
Signature · 2 lines
Thanks.
Binbin
maintainer Applied
#8 lore raw
In reply to David Carlier

Hi David,

Quoted 13 lines · David Carlier

The event ISR reads SR1 and, when an error flag (ARLO/AF/BERR) is set, calls loongson2_i2c_isr_error() which clears the offending flag, issues STOP for the AF case, records msg->result, masks every CR2 interrupt enable and completes the waiter. The handler then returns IRQ_NONE, declaring to the IRQ core that the device did not interrupt.

That report is wrong. The device did interrupt and the handler fully serviced it. Because the IRQ is requested with IRQF_SHARED, the genirq spurious-IRQ tracker counts each error as unhandled. A bus that emits sporadic NACKs, arbitration losses or bus errors will therefore march toward the spurious-IRQ threshold and the line can end up disabled, wedging the controller.

Quoted 5 lines

Return IRQ_HANDLED on this path. The other IRQ_NONE site, taken when neither an event nor an error bit is set, remains correct.

Fixes 6d1b0785f6d5 ("i2c: ls2x-v2: Add driver for Loongson-2K0300 I2C controller")

merged to i2c/i2c-host.

Thanks,
Andi