Skip to contentSkip to conversation

irqchip/atmel-aic[5]: Disable interrupts in the irq_pm_shutdown() callbacks

PATCH Applied Karl Mehltretter 3 participants 3 messages Sep 26 – Oct 15

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

PATCH 1/1 irqchip/atmel-aic[5]: Disable interrupts in the irq_pm_shutdown() callbacks

irq_gc_shutdown() calls the irq_pm_shutdown() callbacks from syscore_shutdown() with interrupts enabled. aic_pm_shutdown() and aic5_pm_shutdown() take the generic chip lock with raw_spin_lock(), and irq_gc_eoi() takes the same lock from the interrupt handler. An interrupt from the chip while the lock is held spins in irq_gc_eoi() and hangs the reboot.

Lockdep reports this on every reboot of a SAM9X75 Curiosity board:

WARNING: inconsistent lock state
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. busybox/101 [HC0[0]:SC0[0]:HE1:SE1] takes:
c1c2b434 (&gc->lock){?.-.}-{2:2}, at: aic5_pm_shutdown+0x34/0xd8 {IN-HARDIRQ-W} state was registered at:

    ...
    irq_gc_eoi+0x28/0x60
    handle_fasteoi_irq+0x120/0x214

...
aic5_pm_shutdown from irq_gc_shutdown+0x4c/0x58 irq_gc_shutdown from syscore_shutdown+0x5c/0x9c syscore_shutdown from kernel_restart+0x34/0x78 kernel_restart from sys_reboot+0x180/0x25c

Use the irqsave guard, as
commit 33517881ede7 ("irqchip/brcmstb-l2: Use _irqsave locking variants in non-interrupt code") did for brcmstb-l2.

Fixes b1479ebb7720 ("irqchip: atmel-aic: Add atmel AIC/AIC5 drivers")
Assisted-by LLM

---

Notes:
Tested on a SAM9X75 Curiosity with v7.2.8 plus this patch, PREEMPT_RT and non-RT lockdep builds (clang 22, LLVM=1): the report is gone. On SAM9X60 and SAM9X7, lockdep only gets this far once the PIT64B timer report at boot is fixed, which I am sending separately. The irq-atmel-aic.c change is build-tested only.

 drivers/irqchip/irq-atmel-aic.c  | 2 +-
 drivers/irqchip/irq-atmel-aic5.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-atmel-aic.c +1 -1
index 1dcc52760eca..4a7935e75e4d 100644
@@ -123,7 +123,7 @@ static void aic_pm_shutdown(struct irq_data *d)
 {
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 
-	guard(raw_spinlock)(&gc->lock);
+	guard(raw_spinlock_irqsave)(&gc->lock);
 	irq_reg_writel(gc, 0xffffffff, AT91_AIC_IDCR);
 	irq_reg_writel(gc, 0xffffffff, AT91_AIC_ICCR);
 }
drivers/irqchip/irq-atmel-aic5.c +1 -1
index 1f14b401f71d..07a317ed06ef 100644
@@ -217,7 +217,7 @@ static void aic5_pm_shutdown(struct irq_data *d)
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 	int i;
 
-	guard(raw_spinlock)(&bgc->lock);
+	guard(raw_spinlock_irqsave)(&bgc->lock);
 	for (i = 0; i < dgc->irqs_per_chip; i++) {
 		irq_reg_writel(bgc, i + gc->irq_base, AT91_AIC5_SSR);
 		irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);
Signature · 1 line
2.39.5 (Apple Git-154)
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 67 lines · Karl Mehltretter

irq_gc_shutdown() calls the irq_pm_shutdown() callbacks from syscore_shutdown() with interrupts enabled. aic_pm_shutdown() and aic5_pm_shutdown() take the generic chip lock with raw_spin_lock(), and irq_gc_eoi() takes the same lock from the interrupt handler. An interrupt from the chip while the lock is held spins in irq_gc_eoi() and hangs the reboot.

Lockdep reports this on every reboot of a SAM9X75 Curiosity board:

  WARNING: inconsistent lock state
  inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. busybox/101 [HC0[0]:SC0[0]:HE1:SE1] takes:
  c1c2b434 (&gc->lock){?.-.}-{2:2}, at: aic5_pm_shutdown+0x34/0xd8 {IN-HARDIRQ-W} state was registered at:
    ...

    irq_gc_eoi+0x28/0x60
    handle_fasteoi_irq+0x120/0x214

  ...
   aic5_pm_shutdown from irq_gc_shutdown+0x4c/0x58 irq_gc_shutdown from syscore_shutdown+0x5c/0x9c syscore_shutdown from kernel_restart+0x34/0x78 kernel_restart from sys_reboot+0x180/0x25c

Use the irqsave guard, as
commit 33517881ede7 ("irqchip/brcmstb-l2: Use _irqsave locking variants in non-interrupt code") did for brcmstb-l2.

Fixes b1479ebb7720 ("irqchip: atmel-aic: Add atmel AIC/AIC5 drivers")
Assisted-by LLM

---

Notes:
    Tested on a SAM9X75 Curiosity with v7.2.8 plus this patch, PREEMPT_RT and non-RT lockdep builds (clang 22, LLVM=1): the report is gone. On SAM9X60 and SAM9X7, lockdep only gets this far once the PIT64B timer report at boot is fixed, which I am sending separately. The irq-atmel-aic.c change is build-tested only.

 drivers/irqchip/irq-atmel-aic.c  | 2 +-
 drivers/irqchip/irq-atmel-aic5.c | 2 +-

 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-atmel-aic.c +0 -0
index 1dcc52760eca..4a7935e75e4d 100644
@@ -123,7 +123,7 @@ static void aic_pm_shutdown(struct irq_data *d)
  {
  	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);

drivers/irqchip/irq-atmel-aic.c +1 -1
-	guard(raw_spinlock)(&gc->lock);
+	guard(raw_spinlock_irqsave)(&gc->lock);

  irq_reg_writel(gc, 0xffffffff, AT91_AIC_IDCR); irq_reg_writel(gc, 0xffffffff, AT91_AIC_ICCR); }

drivers/irqchip/irq-atmel-aic5.c +0 -0
index 1f14b401f71d..07a317ed06ef 100644
@@ -217,7 +217,7 @@ static void aic5_pm_shutdown(struct irq_data *d)
  	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  	int i;

drivers/irqchip/irq-atmel-aic5.c +1 -1
-	guard(raw_spinlock)(&bgc->lock);
+	guard(raw_spinlock_irqsave)(&bgc->lock);
Quoted 3 lines

  for (i = 0; i < dgc->irqs_per_chip; i++) { irq_reg_writel(bgc, i + gc->irq_base, AT91_AIC5_SSR); irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);

#2 lore raw
In reply to Karl Mehltretter
The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     0ca21fe111457c843624a835641bb490e704bb2f
Gitweb:        https://git.kernel.org/tip/0ca21fe111457c843624a835641bb490e704bb2f
Author:        Karl Mehltretter <[email protected]>
AuthorDate:    Sat, 26 Sep 2026 02:41:24 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 15 Oct 2026 11:59:22 +02:00

irqchip/atmel-aic[5]: Disable interrupts in the irq_pm_shutdown() callbacks

irq_gc_shutdown() calls the irq_pm_shutdown() callbacks from syscore_shutdown() with interrupts enabled. aic_pm_shutdown() and aic5_pm_shutdown() take the generic chip lock with raw_spin_lock(), and irq_gc_eoi() takes the same lock from the interrupt handler. An interrupt from the chip while the lock is held spins in irq_gc_eoi() and hangs the reboot.

Lockdep reports this on every reboot of a SAM9X75 Curiosity board:

WARNING: inconsistent lock state
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. busybox/101 [HC0[0]:SC0[0]:HE1:SE1] takes:
c1c2b434 (&gc->lock){?.-.}-{2:2}, at: aic5_pm_shutdown+0x34/0xd8 {IN-HARDIRQ-W} state was registered at:

    ...
    irq_gc_eoi+0x28/0x60
    handle_fasteoi_irq+0x120/0x214

...
aic5_pm_shutdown from irq_gc_shutdown+0x4c/0x58 irq_gc_shutdown from syscore_shutdown+0x5c/0x9c syscore_shutdown from kernel_restart+0x34/0x78 kernel_restart from sys_reboot+0x180/0x25c

Use the irqsave guard, as
commit 33517881ede7 ("irqchip/brcmstb-l2: Use _irqsave locking variants in non-interrupt code") did for brcmstb-l2.

Fixes b1479ebb7720 ("irqchip: atmel-aic: Add atmel AIC/AIC5 drivers")
Assisted-by LLM
---
 drivers/irqchip/irq-atmel-aic.c  | 2 +-
 drivers/irqchip/irq-atmel-aic5.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-atmel-aic.c +1 -1
index 1dcc527..4a7935e 100644
@@ -123,7 +123,7 @@ static void aic_pm_shutdown(struct irq_data *d)
 {
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 
-	guard(raw_spinlock)(&gc->lock);
+	guard(raw_spinlock_irqsave)(&gc->lock);
 	irq_reg_writel(gc, 0xffffffff, AT91_AIC_IDCR);
 	irq_reg_writel(gc, 0xffffffff, AT91_AIC_ICCR);
 }
drivers/irqchip/irq-atmel-aic5.c +1 -1
index 1f14b40..07a317e 100644
@@ -217,7 +217,7 @@ static void aic5_pm_shutdown(struct irq_data *d)
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 	int i;
 
-	guard(raw_spinlock)(&bgc->lock);
+	guard(raw_spinlock_irqsave)(&bgc->lock);
 	for (i = 0; i < dgc->irqs_per_chip; i++) {
 		irq_reg_writel(bgc, i + gc->irq_base, AT91_AIC5_SSR);
 		irq_reg_writel(bgc, 1, AT91_AIC5_IDCR);