aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/wakeup.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-06-17 11:40:57 -0400
committerLen Brown <len.brown@intel.com>2010-06-17 12:18:09 -0400
commitcb1cb1780f2025a7d612de09131bf6530f80fb1a (patch)
treeebe068c626d0f498586ff80653b9c2693a6e49ef /drivers/acpi/wakeup.c
parent7e27d6e778cd87b6f2415515d7127eba53fe5d02 (diff)
ACPI / PM: Do not enable GPEs for system wakeup in advance
After commit 9630bdd9b15d2f489c646d8bc04b60e53eb5ec78 (ACPI: Use GPE reference counting to support shared GPEs) the wakeup enable mask bits of GPEs are set as soon as the GPEs are enabled to wake up the system. Unfortunately, this leads to a regression reported by Michal Hocko, where a system is woken up from ACPI S5 by a device that is not supposed to do that, because the wakeup enable mask bit of this device's GPE is always set when acpi_enter_sleep_state() calls acpi_hw_enable_all_wakeup_gpes(), although it should only be set if the device is supposed to wake up the system from the target state. To work around this issue, rework the ACPI power management code so that GPEs are not enabled to wake up the system upfront, but only during a system state transition when the target state of the system is known. [Of course, this means that the reference counting of "wakeup" GPEs doesn't really make sense and it is sufficient to set/unset the wakeup mask bits for them during system sleep transitions. This will allow us to simplify the GPE handling code quite a bit, but that change is too intrusive for 2.6.35.] Fixes https://bugzilla.kernel.org/show_bug.cgi?id=15951 Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reported-and-tested-by: Michal Hocko <mhocko@suse.cz> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/wakeup.c')
-rw-r--r--drivers/acpi/wakeup.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 4b9d339a6e28..388747a7ef4f 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -64,16 +64,13 @@ void acpi_enable_wakeup_device(u8 sleep_state)
64 struct acpi_device *dev = 64 struct acpi_device *dev =
65 container_of(node, struct acpi_device, wakeup_list); 65 container_of(node, struct acpi_device, wakeup_list);
66 66
67 if (!dev->wakeup.flags.valid) 67 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
68 continue;
69
70 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
71 || sleep_state > (u32) dev->wakeup.sleep_state) 68 || sleep_state > (u32) dev->wakeup.sleep_state)
72 continue; 69 continue;
73 70
74 /* The wake-up power should have been enabled already. */ 71 /* The wake-up power should have been enabled already. */
75 acpi_set_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 72 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
76 ACPI_GPE_ENABLE); 73 ACPI_GPE_TYPE_WAKE);
77 } 74 }
78} 75}
79 76
@@ -96,6 +93,8 @@ void acpi_disable_wakeup_device(u8 sleep_state)
96 || (sleep_state > (u32) dev->wakeup.sleep_state)) 93 || (sleep_state > (u32) dev->wakeup.sleep_state))
97 continue; 94 continue;
98 95
96 acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
97 ACPI_GPE_TYPE_WAKE);
99 acpi_disable_wakeup_device_power(dev); 98 acpi_disable_wakeup_device_power(dev);
100 } 99 }
101} 100}
@@ -109,13 +108,8 @@ int __init acpi_wakeup_device_init(void)
109 struct acpi_device *dev = container_of(node, 108 struct acpi_device *dev = container_of(node,
110 struct acpi_device, 109 struct acpi_device,
111 wakeup_list); 110 wakeup_list);
112 /* In case user doesn't load button driver */ 111 if (dev->wakeup.flags.always_enabled)
113 if (!dev->wakeup.flags.always_enabled || 112 dev->wakeup.state.enabled = 1;
114 dev->wakeup.state.enabled)
115 continue;
116 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
117 ACPI_GPE_TYPE_WAKE);
118 dev->wakeup.state.enabled = 1;
119 } 113 }
120 mutex_unlock(&acpi_device_lock); 114 mutex_unlock(&acpi_device_lock);
121 return 0; 115 return 0;