All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq
@ 2020-08-11 18:00 Guenter Roeck
  2020-08-11 19:21 ` Rafael J. Wysocki
  2020-08-12  9:13 ` [tip: irq/urgent] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq() tip-bot2 for Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2020-08-11 18:00 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Guenter Roeck, Rafael J . Wysocki

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 <rafael.j.wysocki@intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 kernel/irq/pm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c
index 8f557fa1f4fe..c6c7e187ae74 100644
--- a/kernel/irq/pm.c
+++ b/kernel/irq/pm.c
@@ -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);
 }
 
-- 
2.17.1


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

* Re: [PATCH] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq
  2020-08-11 18:00 [PATCH] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq Guenter Roeck
@ 2020-08-11 19:21 ` Rafael J. Wysocki
  2020-08-12  9:13 ` [tip: irq/urgent] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq() tip-bot2 for Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2020-08-11 19:21 UTC (permalink / raw)
  To: Guenter Roeck, Thomas Gleixner; +Cc: linux-kernel, Linux PM, linux-acpi, rafael

On 8/11/2020 8:00 PM, Guenter Roeck wrote:
> 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 <rafael.j.wysocki@intel.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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.


> ---
>   kernel/irq/pm.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c
> index 8f557fa1f4fe..c6c7e187ae74 100644
> --- a/kernel/irq/pm.c
> +++ b/kernel/irq/pm.c
> @@ -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);
>   }
>   



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

* [tip: irq/urgent] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq()
  2020-08-11 18:00 [PATCH] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq Guenter Roeck
  2020-08-11 19:21 ` Rafael J. Wysocki
@ 2020-08-12  9:13 ` tip-bot2 for Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Guenter Roeck @ 2020-08-12  9:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Guenter Roeck, Thomas Gleixner, Rafael J. Wysocki, stable, x86, LKML

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 <linux@roeck-us.net>
AuthorDate:    Tue, 11 Aug 2020 11:00:01 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
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.

Fixes: 3a79bc63d9075 ("PCI: irq: Introduce rearm_wake_irq()")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200811180001.80203-1-linux@roeck-us.net

---
 kernel/irq/pm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c
index 8f557fa..c6c7e18 100644
--- a/kernel/irq/pm.c
+++ b/kernel/irq/pm.c
@@ -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);
 }
 

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

end of thread, other threads:[~2020-08-12  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 18:00 [PATCH] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq Guenter Roeck
2020-08-11 19:21 ` Rafael J. Wysocki
2020-08-12  9:13 ` [tip: irq/urgent] genirq/PM: Always unlock IRQ descriptor in rearm_wake_irq() tip-bot2 for Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.