aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep/main.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2008-03-29 21:19:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-01 14:21:08 -0400
commit7731ce63d9a863c987dd87b0425451fff0e6cdc8 (patch)
tree7bf9798c40cf43283deeff67747bd15e226e495b /drivers/acpi/sleep/main.c
parentcabce28ec0a0ae3d0ddfa4461f0e8be94ade9e46 (diff)
ACPI PM: Restore the 2.6.24 suspend ordering
Some time ago it turned out that our suspend code ordering broke some NVidia-based systems that hung if _PTS was executed with one of the PCI devices, specifically a USB controller, in a low power state. Then, it was noticed that the suspend code ordering was not compliant with ACPI 1.0, although it was compliant with ACPI 2.0 (and later), and it was argued that the code had to be changed for that reason (ref. http://bugzilla.kernel.org/show_bug.cgi?id=9528). So we did, but evidently we did wrong, because it's now turning out that some systems have been broken by this change. Refs: http://bugzilla.kernel.org/show_bug.cgi?id=10340 https://bugzilla.novell.com/show_bug.cgi?id=374217#c16 [ I said at that time that something like this might happend, but the majority of people involved thought that it was improbable due to the necessity to preserve the compliance of hardware with ACPI 1.0. ] This actually is a quite serious regression from 2.6.24. Moreover, the ACPI 1.0 ordering of suspend code introduced another issue that I have only noticed recently. Namely, if the suspend of one of devices fails, the already suspended devices will be resumed without executing _WAK before, which leads to problems on some systems (for example, in such situations thermal management is broken on my HP nx6325). Consequently, it also breaks suspend debugging on the affected systems. Note also, that the requirement to execute _PTS before suspending devices does not really make sense, because the device in question may be put into a low power state at run time for a reason unrelated to a system-wide suspend. For the reasons outlined above, the change of the suspend ordering should be reverted, which is done by the patch below. [ Felix Möller: "I am the reporter from the original Novell Bug: https://bugzilla.novell.com/show_bug.cgi?id=374217 I just tried current git head (two hours ago) with the patch (the one from the beginning of this thread) from Rafael and without it. With the patch my MacBook does suspend without it does not." ] Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Tested-by: Felix Möller <felix@derklecks.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/acpi/sleep/main.c')
-rw-r--r--drivers/acpi/sleep/main.c71
1 files changed, 14 insertions, 57 deletions
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index d2f71a54726c..71183eea7906 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -26,21 +26,6 @@ u8 sleep_states[ACPI_S_STATE_COUNT];
26 26
27#ifdef CONFIG_PM_SLEEP 27#ifdef CONFIG_PM_SLEEP
28static u32 acpi_target_sleep_state = ACPI_STATE_S0; 28static u32 acpi_target_sleep_state = ACPI_STATE_S0;
29static bool acpi_sleep_finish_wake_up;
30
31/*
32 * ACPI 2.0 and later want us to execute _PTS after suspending devices, so we
33 * allow the user to request that behavior by using the 'acpi_new_pts_ordering'
34 * kernel command line option that causes the following variable to be set.
35 */
36static bool new_pts_ordering;
37
38static int __init acpi_new_pts_ordering(char *str)
39{
40 new_pts_ordering = true;
41 return 1;
42}
43__setup("acpi_new_pts_ordering", acpi_new_pts_ordering);
44#endif 29#endif
45 30
46static int acpi_sleep_prepare(u32 acpi_state) 31static int acpi_sleep_prepare(u32 acpi_state)
@@ -91,14 +76,6 @@ static int acpi_pm_begin(suspend_state_t pm_state)
91 76
92 if (sleep_states[acpi_state]) { 77 if (sleep_states[acpi_state]) {
93 acpi_target_sleep_state = acpi_state; 78 acpi_target_sleep_state = acpi_state;
94 if (new_pts_ordering)
95 return 0;
96
97 error = acpi_sleep_prepare(acpi_state);
98 if (error)
99 acpi_target_sleep_state = ACPI_STATE_S0;
100 else
101 acpi_sleep_finish_wake_up = true;
102 } else { 79 } else {
103 printk(KERN_ERR "ACPI does not support this state: %d\n", 80 printk(KERN_ERR "ACPI does not support this state: %d\n",
104 pm_state); 81 pm_state);
@@ -116,14 +93,11 @@ static int acpi_pm_begin(suspend_state_t pm_state)
116 93
117static int acpi_pm_prepare(void) 94static int acpi_pm_prepare(void)
118{ 95{
119 if (new_pts_ordering) { 96 int error = acpi_sleep_prepare(acpi_target_sleep_state);
120 int error = acpi_sleep_prepare(acpi_target_sleep_state);
121 97
122 if (error) { 98 if (error) {
123 acpi_target_sleep_state = ACPI_STATE_S0; 99 acpi_target_sleep_state = ACPI_STATE_S0;
124 return error; 100 return error;
125 }
126 acpi_sleep_finish_wake_up = true;
127 } 101 }
128 102
129 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; 103 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
@@ -212,7 +186,6 @@ static void acpi_pm_finish(void)
212 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 186 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
213 187
214 acpi_target_sleep_state = ACPI_STATE_S0; 188 acpi_target_sleep_state = ACPI_STATE_S0;
215 acpi_sleep_finish_wake_up = false;
216 189
217#ifdef CONFIG_X86 190#ifdef CONFIG_X86
218 if (init_8259A_after_S1) { 191 if (init_8259A_after_S1) {
@@ -229,11 +202,10 @@ static void acpi_pm_finish(void)
229static void acpi_pm_end(void) 202static void acpi_pm_end(void)
230{ 203{
231 /* 204 /*
232 * This is necessary in case acpi_pm_finish() is not called directly 205 * This is necessary in case acpi_pm_finish() is not called during a
233 * during a failing transition to a sleep state. 206 * failing transition to a sleep state.
234 */ 207 */
235 if (acpi_sleep_finish_wake_up) 208 acpi_target_sleep_state = ACPI_STATE_S0;
236 acpi_pm_finish();
237} 209}
238 210
239static int acpi_pm_state_valid(suspend_state_t pm_state) 211static int acpi_pm_state_valid(suspend_state_t pm_state)
@@ -285,31 +257,18 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
285#ifdef CONFIG_HIBERNATION 257#ifdef CONFIG_HIBERNATION
286static int acpi_hibernation_begin(void) 258static int acpi_hibernation_begin(void)
287{ 259{
288 int error;
289
290 acpi_target_sleep_state = ACPI_STATE_S4; 260 acpi_target_sleep_state = ACPI_STATE_S4;
291 if (new_pts_ordering)
292 return 0;
293 261
294 error = acpi_sleep_prepare(ACPI_STATE_S4); 262 return 0;
295 if (error)
296 acpi_target_sleep_state = ACPI_STATE_S0;
297 else
298 acpi_sleep_finish_wake_up = true;
299
300 return error;
301} 263}
302 264
303static int acpi_hibernation_prepare(void) 265static int acpi_hibernation_prepare(void)
304{ 266{
305 if (new_pts_ordering) { 267 int error = acpi_sleep_prepare(ACPI_STATE_S4);
306 int error = acpi_sleep_prepare(ACPI_STATE_S4);
307 268
308 if (error) { 269 if (error) {
309 acpi_target_sleep_state = ACPI_STATE_S0; 270 acpi_target_sleep_state = ACPI_STATE_S0;
310 return error; 271 return error;
311 }
312 acpi_sleep_finish_wake_up = true;
313 } 272 }
314 273
315 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; 274 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
@@ -353,17 +312,15 @@ static void acpi_hibernation_finish(void)
353 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 312 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
354 313
355 acpi_target_sleep_state = ACPI_STATE_S0; 314 acpi_target_sleep_state = ACPI_STATE_S0;
356 acpi_sleep_finish_wake_up = false;
357} 315}
358 316
359static void acpi_hibernation_end(void) 317static void acpi_hibernation_end(void)
360{ 318{
361 /* 319 /*
362 * This is necessary in case acpi_hibernation_finish() is not called 320 * This is necessary in case acpi_hibernation_finish() is not called
363 * directly during a failing transition to the sleep state. 321 * during a failing transition to the sleep state.
364 */ 322 */
365 if (acpi_sleep_finish_wake_up) 323 acpi_target_sleep_state = ACPI_STATE_S0;
366 acpi_hibernation_finish();
367} 324}
368 325
369static int acpi_hibernation_pre_restore(void) 326static int acpi_hibernation_pre_restore(void)