public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@suse.cz>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Shaohua Li <shaohua.li@intel.com>,
	Andi Kleen <andi@firstfloor.org>
Subject: [PATCH -mm 7/8] ACPI hibernation: Utilize hardware signature
Date: Thu, 10 Jul 2008 02:05:51 +0200	[thread overview]
Message-ID: <200807100205.52308.rjw@sisk.pl> (raw)
In-Reply-To: <200807100152.17755.rjw@sisk.pl>

From: Shaohua Li <shaohua.li@intel.com>
Subject: ACPI hibernation: Utilize hardware signature

ACPI defines a hardware signature.  BIOS calculates the signature
according to hardware configure and if hardware changes while
hibernated, the signature will change.  In that case, S4 resume
should fail.

Still, there may be systems on which this mechanism does not work
correctly, so it is better to provide a workaround for them.  For
this reason, add a new switch to the acpi_sleep= command line
argument allowing one to disable hardware signature checking.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 Documentation/kernel-parameters.txt |    4 +++-
 arch/x86/kernel/acpi/sleep.c        |    2 ++
 drivers/acpi/sleep/main.c           |   22 ++++++++++++++++++++++
 include/linux/acpi.h                |    1 +
 4 files changed, 28 insertions(+), 1 deletion(-)

Index: linux-next/drivers/acpi/sleep/main.c
===================================================================
--- linux-next.orig/drivers/acpi/sleep/main.c
+++ linux-next/drivers/acpi/sleep/main.c
@@ -283,6 +283,15 @@ static struct platform_suspend_ops acpi_
 #endif /* CONFIG_SUSPEND */
 
 #ifdef CONFIG_HIBERNATION
+static unsigned long s4_hardware_signature;
+static struct acpi_table_facs *facs;
+static bool nosigcheck;
+
+void __init acpi_no_s4_hw_signature(void)
+{
+	nosigcheck = true;
+}
+
 static int acpi_hibernation_begin(void)
 {
 	acpi_target_sleep_state = ACPI_STATE_S4;
@@ -316,6 +325,12 @@ static void acpi_hibernation_leave(void)
 	acpi_enable();
 	/* Reprogram control registers and execute _BFS */
 	acpi_leave_sleep_state_prep(ACPI_STATE_S4);
+	/* Check the hardware signature */
+	if (facs && s4_hardware_signature != facs->hardware_signature) {
+		printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
+			"cannot resume!\n");
+		panic("ACPI S4 hardware signature mismatch");
+	}
 }
 
 static void acpi_pm_enable_gpes(void)
@@ -544,6 +559,13 @@ int __init acpi_sleep_init(void)
 			&acpi_hibernation_ops_old : &acpi_hibernation_ops);
 		sleep_states[ACPI_STATE_S4] = 1;
 		printk(" S4");
+		if (!nosigcheck) {
+			acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
+				(struct acpi_table_header **)&facs);
+			if (facs)
+				s4_hardware_signature =
+					facs->hardware_signature;
+		}
 	}
 #endif
 	status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
Index: linux-next/Documentation/kernel-parameters.txt
===================================================================
--- linux-next.orig/Documentation/kernel-parameters.txt
+++ linux-next/Documentation/kernel-parameters.txt
@@ -147,10 +147,12 @@ and is between 256 and 4096 characters. 
 			default: 0
 
 	acpi_sleep=	[HW,ACPI] Sleep options
-			Format: { s3_bios, s3_mode, s3_beep, old_ordering }
+			Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig, old_ordering }
 			See Documentation/power/video.txt for s3_bios and s3_mode.
 			s3_beep is for debugging; it makes the PC's speaker beep
 			as soon as the kernel's real-mode entry point is called.
+			s4_nohwsig prevents ACPI hardware signature from being
+			used during resume from hibernation.
 			old_ordering causes the ACPI 1.0 ordering of the _PTS
 			control method, wrt putting devices into low power
 			states, to be enforced (the ACPI 2.0 ordering of _PTS is
Index: linux-next/arch/x86/kernel/acpi/sleep.c
===================================================================
--- linux-next.orig/arch/x86/kernel/acpi/sleep.c
+++ linux-next/arch/x86/kernel/acpi/sleep.c
@@ -142,6 +142,8 @@ static int __init acpi_sleep_setup(char 
 			acpi_realmode_flags |= 2;
 		if (strncmp(str, "s3_beep", 7) == 0)
 			acpi_realmode_flags |= 4;
+		if (strncmp(str, "s4_nohwsig", 10) == 0)
+			acpi_no_s4_hw_signature();
 		if (strncmp(str, "old_ordering", 12) == 0)
 			acpi_old_suspend_ordering();
 		str = strchr(str, ',');
Index: linux-next/include/linux/acpi.h
===================================================================
--- linux-next.orig/include/linux/acpi.h
+++ linux-next/include/linux/acpi.h
@@ -236,6 +236,7 @@ int acpi_check_mem_region(resource_size_
 		      const char *name);
 
 #ifdef CONFIG_PM_SLEEP
+void __init acpi_no_s4_hw_signature(void);
 void __init acpi_old_suspend_ordering(void);
 #endif /* CONFIG_PM_SLEEP */
 #else	/* CONFIG_ACPI */


  parent reply	other threads:[~2008-07-10  0:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09 23:52 [PATCH -mm 0/8] PM patches for 2.6.27 Rafael J. Wysocki
2008-07-09 23:55 ` [PATCH -mm 1/8] PM: Add new PM_EVENT codes for runtime power transitions Rafael J. Wysocki
2008-07-10 11:34   ` Pavel Machek
2008-07-09 23:58 ` [PATCH -mm 2/8] AHCI: Speed-up resume Rafael J. Wysocki
2008-07-10 11:34   ` Pavel Machek
2008-07-10  0:00 ` [PATCH -mm 3/8] Hibernation: Simplify memory bitmap Rafael J. Wysocki
2008-07-10 11:34   ` Pavel Machek
2008-07-10  0:01 ` [PATCH -mm 4/8] serio: Speed-up resume Rafael J. Wysocki
2008-07-10 11:35   ` Pavel Machek
2008-07-10 15:11     ` Dmitry Torokhov
2008-07-10  0:03 ` [PATCH -mm 5/8] Introduce new interface schedule_work_on Rafael J. Wysocki
2008-07-10 11:36   ` Pavel Machek
2008-07-10  0:04 ` [PATCH -mm 6/8] Schedule sysrq poweroff on boot cpu Rafael J. Wysocki
2008-07-10 11:36   ` Pavel Machek
2008-07-10  0:05 ` Rafael J. Wysocki [this message]
2008-07-10  8:34   ` [PATCH -mm 7/8] ACPI hibernation: Utilize hardware signature Pavel Machek
2008-07-10  0:07 ` [PATCH -mm 8/8] ACPI PM: Add DMI quirk list for ACPI 1.0 suspend ordering Rafael J. Wysocki
2008-07-10 11:37   ` Pavel Machek

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=200807100205.52308.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@suse.cz \
    --cc=shaohua.li@intel.com \
    /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