Skip to content

Commit a8d46b9

Browse files
committed
ACPI / sleep: Rework the handling of ACPI GPE wakeup from suspend-to-idle
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>
1 parent ebc3e41 commit a8d46b9

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎drivers/acpi/osl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
825825

826826
acpi_irq_handler = handler;
827827
acpi_irq_context = context;
828-
if (request_irq(irq, acpi_irq, IRQF_SHARED | IRQF_NO_SUSPEND, "acpi", acpi_irq)) {
828+
if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
829829
printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
830830
acpi_irq_handler = NULL;
831831
return AE_NOT_ACQUIRED;

‎drivers/acpi/sleep.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/irq.h>
1515
#include <linux/dmi.h>
1616
#include <linux/device.h>
17+
#include <linux/interrupt.h>
1718
#include <linux/suspend.h>
1819
#include <linux/reboot.h>
1920
#include <linux/acpi.h>
@@ -626,13 +627,28 @@ static int acpi_freeze_begin(void)
626627
return 0;
627628
}
628629

630+
static int acpi_freeze_prepare(void)
631+
{
632+
acpi_enable_all_wakeup_gpes();
633+
enable_irq_wake(acpi_gbl_FADT.sci_interrupt);
634+
return 0;
635+
}
636+
637+
static void acpi_freeze_restore(void)
638+
{
639+
disable_irq_wake(acpi_gbl_FADT.sci_interrupt);
640+
acpi_enable_all_runtime_gpes();
641+
}
642+
629643
static void acpi_freeze_end(void)
630644
{
631645
acpi_scan_lock_release();
632646
}
633647

634648
static const struct platform_freeze_ops acpi_freeze_ops = {
635649
.begin = acpi_freeze_begin,
650+
.prepare = acpi_freeze_prepare,
651+
.restore = acpi_freeze_restore,
636652
.end = acpi_freeze_end,
637653
};
638654

‎include/linux/suspend.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ struct platform_suspend_ops {
189189

190190
struct platform_freeze_ops {
191191
int (*begin)(void);
192+
int (*prepare)(void);
193+
void (*restore)(void);
192194
void (*end)(void);
193195
};
194196

‎kernel/power/suspend.c‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ static int platform_suspend_prepare(suspend_state_t state)
144144
suspend_ops->prepare() : 0;
145145
}
146146

147+
static int platform_suspend_prepare_late(suspend_state_t state)
148+
{
149+
return state == PM_SUSPEND_FREEZE && freeze_ops->prepare ?
150+
freeze_ops->prepare() : 0;
151+
}
152+
147153
static int platform_suspend_prepare_noirq(suspend_state_t state)
148154
{
149155
return state != PM_SUSPEND_FREEZE && suspend_ops->prepare_late ?
@@ -156,6 +162,12 @@ static void platform_resume_noirq(suspend_state_t state)
156162
suspend_ops->wake();
157163
}
158164

165+
static void platform_resume_early(suspend_state_t state)
166+
{
167+
if (state == PM_SUSPEND_FREEZE && freeze_ops->restore)
168+
freeze_ops->restore();
169+
}
170+
159171
static void platform_resume_finish(suspend_state_t state)
160172
{
161173
if (state != PM_SUSPEND_FREEZE && suspend_ops->finish)
@@ -270,10 +282,14 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
270282
printk(KERN_ERR "PM: late suspend of devices failed\n");
271283
goto Platform_finish;
272284
}
285+
error = platform_suspend_prepare_late(state);
286+
if (error)
287+
goto Devices_early_resume;
288+
273289
error = dpm_suspend_noirq(PMSG_SUSPEND);
274290
if (error) {
275291
printk(KERN_ERR "PM: noirq suspend of devices failed\n");
276-
goto Devices_early_resume;
292+
goto Platform_early_resume;
277293
}
278294
error = platform_suspend_prepare_noirq(state);
279295
if (error)
@@ -326,6 +342,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
326342
platform_resume_noirq(state);
327343
dpm_resume_noirq(PMSG_RESUME);
328344

345+
Platform_early_resume:
346+
platform_resume_early(state);
347+
329348
Devices_early_resume:
330349
dpm_resume_early(PMSG_RESUME);
331350

0 commit comments

Comments
 (0)