Commit 9b039330 authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Len Brown

ACPI: Hibernate erroneously disabled Suspend wakeup devices

S4 suspend to disk will disable GPE's permanently
because acpi_gpe_sleep_prepare() does not have
a counterpart at resume time.  Thus, those devices
became unavailable for wakeup from subsequent
S3 suspend-to-ram.

Here acpi_gpe_sleep_prepare() is removed, and upon suspend
acpi_enable_wakeup_device() gets its functionality.
Upon resume, acpi_disable_wakeup_device() restores the state.

https://bugzilla.novell.com/show_bug.cgi?id=292300Signed-off-by: default avatarAlexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: default avatarPavel Machek <pavel@suse.cz>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent ff0ce684
...@@ -44,7 +44,6 @@ int acpi_sleep_prepare(u32 acpi_state) ...@@ -44,7 +44,6 @@ int acpi_sleep_prepare(u32 acpi_state)
ACPI_FLUSH_CPU_CACHE(); ACPI_FLUSH_CPU_CACHE();
acpi_enable_wakeup_device_prep(acpi_state); acpi_enable_wakeup_device_prep(acpi_state);
#endif #endif
acpi_gpe_sleep_prepare(acpi_state);
acpi_enter_sleep_state_prep(acpi_state); acpi_enter_sleep_state_prep(acpi_state);
return 0; return 0;
} }
......
...@@ -5,6 +5,5 @@ extern int acpi_suspend (u32 state); ...@@ -5,6 +5,5 @@ extern int acpi_suspend (u32 state);
extern void acpi_enable_wakeup_device_prep(u8 sleep_state); extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
extern void acpi_enable_wakeup_device(u8 sleep_state); extern void acpi_enable_wakeup_device(u8 sleep_state);
extern void acpi_disable_wakeup_device(u8 sleep_state); extern void acpi_disable_wakeup_device(u8 sleep_state);
extern void acpi_gpe_sleep_prepare(u32 sleep_state);
extern int acpi_sleep_prepare(u32 acpi_state); extern int acpi_sleep_prepare(u32 acpi_state);
...@@ -64,36 +64,29 @@ void acpi_enable_wakeup_device(u8 sleep_state) ...@@ -64,36 +64,29 @@ void acpi_enable_wakeup_device(u8 sleep_state)
ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device");
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) { list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev = container_of(node, struct acpi_device *dev =
struct acpi_device, container_of(node, struct acpi_device, wakeup_list);
wakeup_list); if (!dev->wakeup.flags.valid)
continue;
/* If users want to disable run-wake GPE, /* If users want to disable run-wake GPE,
* we only disable it for wake and leave it for runtime * we only disable it for wake and leave it for runtime
*/ */
if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { if (!dev->wakeup.state.enabled ||
spin_unlock(&acpi_device_lock); sleep_state > (u32) dev->wakeup.sleep_state) {
acpi_set_gpe_type(dev->wakeup.gpe_device, if (dev->wakeup.flags.run_wake) {
dev->wakeup.gpe_number, spin_unlock(&acpi_device_lock);
ACPI_GPE_TYPE_RUNTIME); /* set_gpe_type will disable GPE, leave it like that */
/* Re-enable it, since set_gpe_type will disable it */ acpi_set_gpe_type(dev->wakeup.gpe_device,
acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
dev->wakeup.gpe_number, ACPI_ISR); ACPI_GPE_TYPE_RUNTIME);
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
}
continue; continue;
} }
if (!dev->wakeup.flags.valid ||
!dev->wakeup.state.enabled ||
(sleep_state > (u32) dev->wakeup.sleep_state))
continue;
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
/* run-wake GPE has been enabled */
if (!dev->wakeup.flags.run_wake) if (!dev->wakeup.flags.run_wake)
acpi_enable_gpe(dev->wakeup.gpe_device, acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_ISR); dev->wakeup.gpe_number, ACPI_ISR);
dev->wakeup.state.active = 1;
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
} }
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
...@@ -112,26 +105,25 @@ void acpi_disable_wakeup_device(u8 sleep_state) ...@@ -112,26 +105,25 @@ void acpi_disable_wakeup_device(u8 sleep_state)
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) { list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev = container_of(node, struct acpi_device *dev =
struct acpi_device, container_of(node, struct acpi_device, wakeup_list);
wakeup_list);
if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { if (!dev->wakeup.flags.valid)
spin_unlock(&acpi_device_lock);
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number,
ACPI_GPE_TYPE_WAKE_RUN);
/* Re-enable it, since set_gpe_type will disable it */
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR);
spin_lock(&acpi_device_lock);
continue; continue;
} if (!dev->wakeup.state.enabled ||
sleep_state > (u32) dev->wakeup.sleep_state) {
if (!dev->wakeup.flags.valid || if (dev->wakeup.flags.run_wake) {
!dev->wakeup.state.active || spin_unlock(&acpi_device_lock);
(sleep_state > (u32) dev->wakeup.sleep_state)) acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number,
ACPI_GPE_TYPE_WAKE_RUN);
/* Re-enable it, since set_gpe_type will disable it */
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR);
spin_lock(&acpi_device_lock);
}
continue; continue;
}
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
acpi_disable_wakeup_device_power(dev); acpi_disable_wakeup_device_power(dev);
...@@ -142,7 +134,6 @@ void acpi_disable_wakeup_device(u8 sleep_state) ...@@ -142,7 +134,6 @@ void acpi_disable_wakeup_device(u8 sleep_state)
acpi_clear_gpe(dev->wakeup.gpe_device, acpi_clear_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number, ACPI_NOT_ISR); dev->wakeup.gpe_number, ACPI_NOT_ISR);
} }
dev->wakeup.state.active = 0;
spin_lock(&acpi_device_lock); spin_lock(&acpi_device_lock);
} }
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
...@@ -160,48 +151,20 @@ static int __init acpi_wakeup_device_init(void) ...@@ -160,48 +151,20 @@ static int __init acpi_wakeup_device_init(void)
struct acpi_device *dev = container_of(node, struct acpi_device *dev = container_of(node,
struct acpi_device, struct acpi_device,
wakeup_list); wakeup_list);
/* In case user doesn't load button driver */ /* In case user doesn't load button driver */
if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled)
spin_unlock(&acpi_device_lock); continue;
acpi_set_gpe_type(dev->wakeup.gpe_device, spin_unlock(&acpi_device_lock);
dev->wakeup.gpe_number, acpi_set_gpe_type(dev->wakeup.gpe_device,
ACPI_GPE_TYPE_WAKE_RUN); dev->wakeup.gpe_number,
acpi_enable_gpe(dev->wakeup.gpe_device, ACPI_GPE_TYPE_WAKE_RUN);
dev->wakeup.gpe_number, ACPI_NOT_ISR); acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.state.enabled = 1; dev->wakeup.gpe_number, ACPI_NOT_ISR);
spin_lock(&acpi_device_lock); dev->wakeup.state.enabled = 1;
} spin_lock(&acpi_device_lock);
} }
spin_unlock(&acpi_device_lock); spin_unlock(&acpi_device_lock);
return 0; return 0;
} }
late_initcall(acpi_wakeup_device_init); late_initcall(acpi_wakeup_device_init);
/*
* Disable all wakeup GPEs before entering requested sleep state.
* @sleep_state: ACPI state
* Since acpi_enter_sleep_state() will disable all
* RUNTIME GPEs, we simply mark all GPES that
* are not enabled for wakeup from requested state as RUNTIME.
*/
void acpi_gpe_sleep_prepare(u32 sleep_state)
{
struct list_head *node, *next;
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
struct acpi_device *dev = container_of(node,
struct acpi_device,
wakeup_list);
/* The GPE can wakeup system from this state, don't touch it */
if ((u32) dev->wakeup.sleep_state >= sleep_state)
continue;
/* acpi_set_gpe_type will automatically disable GPE */
acpi_set_gpe_type(dev->wakeup.gpe_device,
dev->wakeup.gpe_number,
ACPI_GPE_TYPE_RUNTIME);
}
}
...@@ -264,7 +264,6 @@ struct acpi_device_wakeup_flags { ...@@ -264,7 +264,6 @@ struct acpi_device_wakeup_flags {
struct acpi_device_wakeup_state { struct acpi_device_wakeup_state {
u8 enabled:1; u8 enabled:1;
u8 active:1;
}; };
struct acpi_device_wakeup { struct acpi_device_wakeup {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment