Skip to contentSkip to conversation

genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq

PATCH Applied Guenter Roeck 3 participants 3 messages Aug 11, 2020 – Aug 12, 2020

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

PATCH 1/1 genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq

rearm_wake_irq() does not unlock the irq descriptor if the interrupt is not suspended or if wakeup is not enabled on it. Fix it.

Fixes 3a79bc63d9075 ("PCI: irq: Introduce rearm_wake_irq()")
Cc Rafael J. Wysocki <[email protected]>
---
 kernel/irq/pm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/pm.c +6 -2
index 8f557fa1f4fe..c6c7e187ae74 100644
@@ -185,14 +185,18 @@ void rearm_wake_irq(unsigned int irq)
 	unsigned long flags;
 	struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
 
-	if (!desc || !(desc->istate & IRQS_SUSPENDED) ||
-	    !irqd_is_wakeup_set(&desc->irq_data))
+	if (!desc)
 		return;
 
+	if (!(desc->istate & IRQS_SUSPENDED) ||
+	    !irqd_is_wakeup_set(&desc->irq_data))
+		goto unlock;
+
 	desc->istate &= ~IRQS_SUSPENDED;
 	irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
 	__enable_irq(desc);
 
+unlock:
 	irq_put_desc_busunlock(desc, flags);
 }
 
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Guenter Roeck

rearm_wake_irq() does not unlock the irq descriptor if the interrupt is not suspended or if wakeup is not enabled on it. Fix it.

Fixes 3a79bc63d9075 ("PCI: irq: Introduce rearm_wake_irq()")
Cc Rafael J. Wysocki <[email protected]>

And it needs to go to -stable (even though the bug is latent now, because this function is called for suspended IRQs only AFAICS).

Or I can apply this as the mistake was in my commit.  Please let me know what you prefer.

Quoted 29 lines
---
  kernel/irq/pm.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/pm.c +6 -2
index 8f557fa1f4fe..c6c7e187ae74 100644
@@ -185,14 +185,18 @@ void rearm_wake_irq(unsigned int irq)
  	unsigned long flags;
  	struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
 
-	if (!desc || !(desc->istate & IRQS_SUSPENDED) ||
-	    !irqd_is_wakeup_set(&desc->irq_data))
+	if (!desc)
  		return;
 
+	if (!(desc->istate & IRQS_SUSPENDED) ||
+	    !irqd_is_wakeup_set(&desc->irq_data))
+		goto unlock;
+
  	desc->istate &= ~IRQS_SUSPENDED;
  	irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
  	__enable_irq(desc);
 
+unlock:
  	irq_put_desc_busunlock(desc, flags);
  }
 
merge bot Applied
#2 lore raw

[tip: irq/urgent] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq()

In reply to Guenter Roeck
The following commit has been merged into the irq/urgent branch of tip:

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

Commit-ID:     e27b1636e9337d1a1d174b191e53d0f86421a822
Gitweb:        https://git.kernel.org/tip/e27b1636e9337d1a1d174b191e53d0f86421a822
Author:        Guenter Roeck <[email protected]>
AuthorDate:    Tue, 11 Aug 2020 11:00:01 -07:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 12 Aug 2020 11:04:05 +02:00

genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq()

rearm_wake_irq() does not unlock the irq descriptor if the interrupt is not suspended or if wakeup is not enabled on it.

Restucture the exit conditions so the unlock is always ensured.

---
 kernel/irq/pm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/pm.c +6 -2
index 8f557fa..c6c7e18 100644
@@ -185,14 +185,18 @@ void rearm_wake_irq(unsigned int irq)
 	unsigned long flags;
 	struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
 
-	if (!desc || !(desc->istate & IRQS_SUSPENDED) ||
-	    !irqd_is_wakeup_set(&desc->irq_data))
+	if (!desc)
 		return;
 
+	if (!(desc->istate & IRQS_SUSPENDED) ||
+	    !irqd_is_wakeup_set(&desc->irq_data))
+		goto unlock;
+
 	desc->istate &= ~IRQS_SUSPENDED;
 	irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
 	__enable_irq(desc);
 
+unlock:
 	irq_put_desc_busunlock(desc, flags);
 }