Skip to content

Commit

Permalink
ACPI: Store NVS state even when entering suspend to RAM
Browse files Browse the repository at this point in the history
https://bugzilla.kernel.org/show_bug.cgi?id=13931 describes a bug where
a system fails to successfully resume after the second suspend. Maxim
Levitsky discovered that this could be rectified by forcibly saving
and restoring the ACPI non-volatile state. The spec indicates that this
is only required for S4, but testing the behaviour of Windows by adding
an ACPI NVS region to qemu's e820 map and registering a custom memory
read/write handler reveals that it's saved and restored even over suspend
to RAM. We should mimic that behaviour to avoid other broken platforms.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Matthew Garrett authored and Len Brown committed Jun 10, 2010
1 parent dd4c4f1 commit 2a6b697
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ static int __acpi_pm_prepare(void)
{
int error = acpi_sleep_prepare(acpi_target_sleep_state);

suspend_nvs_save();

if (error)
acpi_target_sleep_state = ACPI_STATE_S0;
return error;
Expand Down Expand Up @@ -140,6 +142,8 @@ static void acpi_pm_finish(void)
{
u32 acpi_state = acpi_target_sleep_state;

suspend_nvs_free();

if (acpi_state == ACPI_STATE_S0)
return;

Expand Down Expand Up @@ -189,6 +193,11 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
u32 acpi_state = acpi_suspend_states[pm_state];
int error = 0;

error = suspend_nvs_alloc();

if (error)
return error;

if (sleep_states[acpi_state]) {
acpi_target_sleep_state = acpi_state;
acpi_sleep_tts_switch(acpi_target_sleep_state);
Expand Down Expand Up @@ -264,6 +273,8 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
if (acpi_state == ACPI_STATE_S3)
acpi_restore_state_mem();

suspend_nvs_restore();

return ACPI_SUCCESS(status) ? 0 : -EFAULT;
}

Expand Down Expand Up @@ -430,12 +441,6 @@ static int acpi_hibernation_enter(void)
return ACPI_SUCCESS(status) ? 0 : -EFAULT;
}

static void acpi_hibernation_finish(void)
{
suspend_nvs_free();
acpi_pm_finish();
}

static void acpi_hibernation_leave(void)
{
/*
Expand Down Expand Up @@ -473,7 +478,7 @@ static struct platform_hibernation_ops acpi_hibernation_ops = {
.begin = acpi_hibernation_begin,
.end = acpi_pm_end,
.pre_snapshot = acpi_hibernation_pre_snapshot,
.finish = acpi_hibernation_finish,
.finish = acpi_pm_finish,
.prepare = acpi_pm_prepare,
.enter = acpi_hibernation_enter,
.leave = acpi_hibernation_leave,
Expand Down Expand Up @@ -526,7 +531,7 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = {
.begin = acpi_hibernation_begin_old,
.end = acpi_pm_end,
.pre_snapshot = acpi_hibernation_pre_snapshot_old,
.finish = acpi_hibernation_finish,
.finish = acpi_pm_finish,
.prepare = acpi_pm_disable_gpes,
.enter = acpi_hibernation_enter,
.leave = acpi_hibernation_leave,
Expand Down

0 comments on commit 2a6b697

Please sign in to comment.