linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <maximlevitsky@gmail.com>
To: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>
Cc: linux-pm <linux-pm@lists.linux-foundation.org>,
	Matthew Garrett <mjg@redhat.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Alan Stern <stern@rowland.harvard.edu>,
	Maxim Levitsky <maximlevitsky@gmail.com>
Subject: [PATCH 2/2] ACPI: Store NVS state even when entering suspend to RAM
Date: Tue,  1 Jun 2010 21:22:24 +0300	[thread overview]
Message-ID: <1275416544-4515-2-git-send-email-maximlevitsky@gmail.com> (raw)
In-Reply-To: <1275416390.3778.7.camel@maxim-laptop>

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: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/acpi/sleep.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index bdb306f..5d26d8e 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -114,6 +114,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;
@@ -143,6 +145,8 @@ static void acpi_pm_finish(void)
 {
 	u32 acpi_state = acpi_target_sleep_state;
 
+	suspend_nvs_free();
+
 	if (acpi_state == ACPI_STATE_S0)
 		return;
 
@@ -192,6 +196,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);
@@ -269,6 +278,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;
 }
 
@@ -443,7 +454,6 @@ static int acpi_hibernation_enter(void)
 
 static void acpi_hibernation_finish(void)
 {
-	suspend_nvs_free();
 	acpi_ec_unblock_transactions();
 	acpi_pm_finish();
 }
@@ -479,7 +489,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,
-- 
1.7.0.4


  parent reply	other threads:[~2010-06-01 18:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-01 18:19 [PATCH] Store BIOS NVS area over s2ram [V2] Maxim Levitsky
2010-06-01 18:22 ` [PATCH 1/2] suspend: Move NVS save/restore code to generic suspend functionality Maxim Levitsky
2010-06-01 21:31   ` Rafael J. Wysocki
2010-06-01 21:52     ` Maxim Levitsky
2010-06-01 22:40       ` Rafael J. Wysocki
2010-06-01 22:46         ` Maxim Levitsky
2010-06-01 23:34           ` Rafael J. Wysocki
2010-06-10 13:58           ` [linux-pm] " Pavel Machek
2010-06-10 14:09             ` Matthew Garrett
2010-06-11 13:32               ` Henrique de Moraes Holschuh
2010-06-11 13:41                 ` Matthew Garrett
2010-06-01 18:22 ` Maxim Levitsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-05-28 20:32 Matthew Garrett
2010-05-28 20:32 ` [PATCH 2/2] ACPI: Store NVS state even when entering suspend to RAM Matthew Garrett
2010-05-30 14:40   ` Maxim Levitsky
2010-05-30 14:51     ` Matthew Garrett
2010-06-02  3:32       ` Henrique de Moraes Holschuh
2010-06-02 10:15         ` Maxim Levitsky
2010-06-02 11:47         ` Matthew Garrett
2010-06-02 13:06           ` Maxim Levitsky
2010-06-04 18:23   ` Len Brown
2010-06-10  9:41   ` Maxim Levitsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1275416544-4515-2-git-send-email-maximlevitsky@gmail.com \
    --to=maximlevitsky@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mjg@redhat.com \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).