Skip to content

Commit 72ad5d7

Browse files
rjwysockilenb
authored andcommitted
ACPI / Sleep: Allow the NVS saving to be skipped during suspend to RAM
Commit 2a6b697 (ACPI: Store NVS state even when entering suspend to RAM) caused the ACPI suspend code save the NVS area during suspend and restore it during resume unconditionally, although it is known that some systems need to use acpi_sleep=s4_nonvs for hibernation to work. To allow the affected systems to avoid saving and restoring the NVS area during suspend to RAM and resume, introduce kernel command line option acpi_sleep=nonvs and make acpi_sleep=s4_nonvs work as its alias temporarily (add acpi_sleep=s4_nonvs to the feature removal file). Addresses https://bugzilla.kernel.org/show_bug.cgi?id=16396 . Signed-off-by: Rafael J. Wysocki <[email protected]> Reported-and-tested-by: tomas m <[email protected]> Signed-off-by: Len Brown <[email protected]>
1 parent b37fa16 commit 72ad5d7

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

Documentation/feature-removal-schedule.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,3 +647,10 @@ Who: Stefan Richter <[email protected]>
647647

648648
----------------------------
649649

650+
What: The acpi_sleep=s4_nonvs command line option
651+
When: 2.6.37
652+
Files: arch/x86/kernel/acpi/sleep.c
653+
Why: superseded by acpi_sleep=nonvs
654+
Who: Rafael J. Wysocki <[email protected]>
655+
656+
----------------------------

Documentation/kernel-parameters.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ and is between 256 and 4096 characters. It is defined in the file
254254
control method, with respect to putting devices into
255255
low power states, to be enforced (the ACPI 2.0 ordering
256256
of _PTS is used by default).
257-
s4_nonvs prevents the kernel from saving/restoring the
258-
ACPI NVS memory during hibernation.
257+
nonvs prevents the kernel from saving/restoring the
258+
ACPI NVS memory during suspend/hibernation and resume.
259259
sci_force_enable causes the kernel to set SCI_EN directly
260260
on resume from S1/S3 (which is against the ACPI spec,
261261
but some broken systems don't work without it).

arch/x86/kernel/acpi/sleep.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,14 @@ static int __init acpi_sleep_setup(char *str)
157157
#ifdef CONFIG_HIBERNATION
158158
if (strncmp(str, "s4_nohwsig", 10) == 0)
159159
acpi_no_s4_hw_signature();
160-
if (strncmp(str, "s4_nonvs", 8) == 0)
161-
acpi_s4_no_nvs();
160+
if (strncmp(str, "s4_nonvs", 8) == 0) {
161+
pr_warning("ACPI: acpi_sleep=s4_nonvs is deprecated, "
162+
"please use acpi_sleep=nonvs instead");
163+
acpi_nvs_nosave();
164+
}
162165
#endif
166+
if (strncmp(str, "nonvs", 5) == 0)
167+
acpi_nvs_nosave();
163168
if (strncmp(str, "old_ordering", 12) == 0)
164169
acpi_old_suspend_ordering();
165170
str = strchr(str, ',');

drivers/acpi/sleep.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ static int acpi_sleep_prepare(u32 acpi_state)
8181
#ifdef CONFIG_ACPI_SLEEP
8282
static u32 acpi_target_sleep_state = ACPI_STATE_S0;
8383

84+
/*
85+
* The ACPI specification wants us to save NVS memory regions during hibernation
86+
* and to restore them during the subsequent resume. Windows does that also for
87+
* suspend to RAM. However, it is known that this mechanism does not work on
88+
* all machines, so we allow the user to disable it with the help of the
89+
* 'acpi_sleep=nonvs' kernel command line option.
90+
*/
91+
static bool nvs_nosave;
92+
93+
void __init acpi_nvs_nosave(void)
94+
{
95+
nvs_nosave = true;
96+
}
97+
8498
/*
8599
* ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
86100
* user to request that behavior by using the 'acpi_old_suspend_ordering'
@@ -197,8 +211,7 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
197211
u32 acpi_state = acpi_suspend_states[pm_state];
198212
int error = 0;
199213

200-
error = suspend_nvs_alloc();
201-
214+
error = nvs_nosave ? 0 : suspend_nvs_alloc();
202215
if (error)
203216
return error;
204217

@@ -388,20 +401,6 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
388401
#endif /* CONFIG_SUSPEND */
389402

390403
#ifdef CONFIG_HIBERNATION
391-
/*
392-
* The ACPI specification wants us to save NVS memory regions during hibernation
393-
* and to restore them during the subsequent resume. However, it is not certain
394-
* if this mechanism is going to work on all machines, so we allow the user to
395-
* disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
396-
* option.
397-
*/
398-
static bool s4_no_nvs;
399-
400-
void __init acpi_s4_no_nvs(void)
401-
{
402-
s4_no_nvs = true;
403-
}
404-
405404
static unsigned long s4_hardware_signature;
406405
static struct acpi_table_facs *facs;
407406
static bool nosigcheck;
@@ -415,7 +414,7 @@ static int acpi_hibernation_begin(void)
415414
{
416415
int error;
417416

418-
error = s4_no_nvs ? 0 : suspend_nvs_alloc();
417+
error = nvs_nosave ? 0 : suspend_nvs_alloc();
419418
if (!error) {
420419
acpi_target_sleep_state = ACPI_STATE_S4;
421420
acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -510,7 +509,7 @@ static int acpi_hibernation_begin_old(void)
510509
error = acpi_sleep_prepare(ACPI_STATE_S4);
511510

512511
if (!error) {
513-
if (!s4_no_nvs)
512+
if (!nvs_nosave)
514513
error = suspend_nvs_alloc();
515514
if (!error)
516515
acpi_target_sleep_state = ACPI_STATE_S4;

include/linux/acpi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int acpi_resources_are_enforced(void);
253253
#ifdef CONFIG_PM_SLEEP
254254
void __init acpi_no_s4_hw_signature(void);
255255
void __init acpi_old_suspend_ordering(void);
256-
void __init acpi_s4_no_nvs(void);
256+
void __init acpi_nvs_nosave(void);
257257
#endif /* CONFIG_PM_SLEEP */
258258

259259
struct acpi_osc_context {

0 commit comments

Comments
 (0)