ACPI / sleep: Rework the handling of ACPI GPE wakeup from suspend-to-idle
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 30 Sep 2014 00:29:01 +0000 (02:29 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 30 Sep 2014 19:06:07 +0000 (21:06 +0200)
The ACPI GPE wakeup from suspend-to-idle is currently based on using
the IRQF_NO_SUSPEND flag for the ACPI SCI, but that is problematic
for a couple of reasons.  First, in principle the ACPI SCI may be
shared and IRQF_NO_SUSPEND does not really work well with shared
interrupts.  Second, it may require the ACPI subsystem to special-case
the handling of device notifications depending on whether or not
they are received during suspend-to-idle in some places which would
lead to fragile code.  Finally, it's better the handle ACPI wakeup
interrupts consistently with wakeup interrupts from other sources.

For this reason, remove the IRQF_NO_SUSPEND flag from the ACPI SCI
and use enable_irq_wake()/disable_irq_wake() with it instead, which
requires two additional platform hooks to be added to struct
platform_freeze_ops.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/osl.c
drivers/acpi/sleep.c
include/linux/suspend.h
kernel/power/suspend.c

index 3abe9b223ba717a644ecfd0a4edf401004f24807..5ca29b5af8d1744bb8aa2962cd21dbd17fafd4ee 100644 (file)
@@ -825,7 +825,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
 
        acpi_irq_handler = handler;
        acpi_irq_context = context;
-       if (request_irq(irq, acpi_irq, IRQF_SHARED | IRQF_NO_SUSPEND, "acpi", acpi_irq)) {
+       if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
                printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
                acpi_irq_handler = NULL;
                return AE_NOT_ACQUIRED;
index 54da4a3fe65e65d4b6334d93b82244f95c245b1f..05a31b573fc327b2a843c314294eff18d6b288ba 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/irq.h>
 #include <linux/dmi.h>
 #include <linux/device.h>
+#include <linux/interrupt.h>
 #include <linux/suspend.h>
 #include <linux/reboot.h>
 #include <linux/acpi.h>
@@ -626,6 +627,19 @@ static int acpi_freeze_begin(void)
        return 0;
 }
 
+static int acpi_freeze_prepare(void)
+{
+       acpi_enable_all_wakeup_gpes();
+       enable_irq_wake(acpi_gbl_FADT.sci_interrupt);
+       return 0;
+}
+
+static void acpi_freeze_restore(void)
+{
+       disable_irq_wake(acpi_gbl_FADT.sci_interrupt);
+       acpi_enable_all_runtime_gpes();
+}
+
 static void acpi_freeze_end(void)
 {
        acpi_scan_lock_release();
@@ -633,6 +647,8 @@ static void acpi_freeze_end(void)
 
 static const struct platform_freeze_ops acpi_freeze_ops = {
        .begin = acpi_freeze_begin,
+       .prepare = acpi_freeze_prepare,
+       .restore = acpi_freeze_restore,
        .end = acpi_freeze_end,
 };
 
index 06a9910827c298d03fe014d030cef47039dbe82e..3388c1b6f7d8d3b981eee4d886fdcdf9e0f30297 100644 (file)
@@ -189,6 +189,8 @@ struct platform_suspend_ops {
 
 struct platform_freeze_ops {
        int (*begin)(void);
+       int (*prepare)(void);
+       void (*restore)(void);
        void (*end)(void);
 };
 
index a25e768d92b591f852e0f82df3f81d5f8be9ffaa..4ca9a33ff62020e63d15219ce9f097611ebf6507 100644 (file)
@@ -144,6 +144,12 @@ static int platform_suspend_prepare(suspend_state_t state)
                suspend_ops->prepare() : 0;
 }
 
+static int platform_suspend_prepare_late(suspend_state_t state)
+{
+       return state == PM_SUSPEND_FREEZE && freeze_ops->prepare ?
+               freeze_ops->prepare() : 0;
+}
+
 static int platform_suspend_prepare_noirq(suspend_state_t state)
 {
        return state != PM_SUSPEND_FREEZE && suspend_ops->prepare_late ?
@@ -156,6 +162,12 @@ static void platform_resume_noirq(suspend_state_t state)
                suspend_ops->wake();
 }
 
+static void platform_resume_early(suspend_state_t state)
+{
+       if (state == PM_SUSPEND_FREEZE && freeze_ops->restore)
+               freeze_ops->restore();
+}
+
 static void platform_resume_finish(suspend_state_t state)
 {
        if (state != PM_SUSPEND_FREEZE && suspend_ops->finish)
@@ -270,10 +282,14 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
                printk(KERN_ERR "PM: late suspend of devices failed\n");
                goto Platform_finish;
        }
+       error = platform_suspend_prepare_late(state);
+       if (error)
+               goto Devices_early_resume;
+
        error = dpm_suspend_noirq(PMSG_SUSPEND);
        if (error) {
                printk(KERN_ERR "PM: noirq suspend of devices failed\n");
-               goto Devices_early_resume;
+               goto Platform_early_resume;
        }
        error = platform_suspend_prepare_noirq(state);
        if (error)
@@ -326,6 +342,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
        platform_resume_noirq(state);
        dpm_resume_noirq(PMSG_RESUME);
 
+ Platform_early_resume:
+       platform_resume_early(state);
+
  Devices_early_resume:
        dpm_resume_early(PMSG_RESUME);