]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
PCI: irq: Introduce rearm_wake_irq()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 13 Jan 2020 09:40:00 +0000 (10:40 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Fri, 14 Feb 2020 10:57:30 +0000 (11:57 +0100)
BugLink: https://bugs.launchpad.net/bugs/1859407
Introduce a new function, rearm_wake_irq(), allowing a wakeup IRQ
to be armed for systen wakeup detection again without running any
action handlers associated with it after it has been armed for
wakeup detection and triggered.

That is useful for IRQs, like ACPI SCI, that may deliver wakeup
as well as non-wakeup interrupts when armed for systen wakeup
detection.  In those cases, it may be possible to determine whether
or not the delivered interrupt is a systen wakeup one without
running the entire action handler (or handlers, if the IRQ is
shared) for the IRQ, and if the interrupt turns out to be a
non-wakeup one, the IRQ can be rearmed with the help of the
new function.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
(cherry picked from commit 3a79bc63d90750f737ab9d7219bd3091d2fd6d84)
Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
include/linux/interrupt.h
kernel/irq/pm.c

index 5b8328a99b2aaa4295f4eadf763657c69c0fee24..0e9cdb3efda742b4f72d09fbd8b21f14f87c0969 100644 (file)
@@ -238,6 +238,7 @@ extern void teardown_percpu_nmi(unsigned int irq);
 /* The following three functions are for the core kernel use only. */
 extern void suspend_device_irqs(void);
 extern void resume_device_irqs(void);
+extern void rearm_wake_irq(unsigned int irq);
 
 /**
  * struct irq_affinity_notify - context for notification of IRQ affinity changes
index d6961d3c6f9e2673b8ecf0b9d4e610b77e42750a..8f557fa1f4fe47642dd0782ebf55a7be5a3a0f55 100644 (file)
@@ -176,6 +176,26 @@ static void resume_irqs(bool want_early)
        }
 }
 
+/**
+ * rearm_wake_irq - rearm a wakeup interrupt line after signaling wakeup
+ * @irq: Interrupt to rearm
+ */
+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))
+               return;
+
+       desc->istate &= ~IRQS_SUSPENDED;
+       irqd_set(&desc->irq_data, IRQD_WAKEUP_ARMED);
+       __enable_irq(desc);
+
+       irq_put_desc_busunlock(desc, flags);
+}
+
 /**
  * irq_pm_syscore_ops - enable interrupt lines early
  *