public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2)
@ 2008-10-26 19:48 Rafael J. Wysocki
  2008-10-26 19:50 ` [PATCH 1/4] Hibernate: Call platform_begin before swsusp_shrink_memory Rafael J. Wysocki
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-26 19:48 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

Hi,

This is my second version of the patchset making the Linux hibernation code
handle the ACPI NVS memory as required by the spec, based on the previous
Zhang Rui's patches.

Please queue in the 'suspend' branch as .29 material.

Thanks,
Rafael


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] Hibernate: Call platform_begin before swsusp_shrink_memory
  2008-10-26 19:48 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Rafael J. Wysocki
@ 2008-10-26 19:50 ` Rafael J. Wysocki
  2008-10-26 19:52 ` [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory Rafael J. Wysocki
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-26 19:50 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

From: Zhang Rui <rui.zhang@intel.com>
Subject: Hibernate: Call platform_begin before swsusp_shrink_memory

Call platform_begin() before swsusp_shrink_memory() so that we can
always allocate enough memory to save the ACPI NVS region from
platform_begin().

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Nigel Cunningham <nigel@tuxonice.net>
Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 kernel/power/disk.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index c9d7408..096fe48 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -259,12 +259,12 @@ int hibernation_snapshot(int platform_mode)
 {
 	int error, ftrace_save;
 
-	/* Free memory before shutting down devices. */
-	error = swsusp_shrink_memory();
+	error = platform_begin(platform_mode);
 	if (error)
 		return error;
 
-	error = platform_begin(platform_mode);
+	/* Free memory before shutting down devices. */
+	error = swsusp_shrink_memory();
 	if (error)
 		goto Close;
 
-- 
1.5.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory
  2008-10-26 19:48 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Rafael J. Wysocki
  2008-10-26 19:50 ` [PATCH 1/4] Hibernate: Call platform_begin before swsusp_shrink_memory Rafael J. Wysocki
@ 2008-10-26 19:52 ` Rafael J. Wysocki
  2008-10-26 19:54 ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup Rafael J. Wysocki
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-26 19:52 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: [PATCH] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory

According to the ACPI Specification 3.0b, Section 15.3.2,
"OSPM will call the _PTS control method some time before entering a
sleeping state, to allow the platform's AML code to update this
memory image before entering the sleeping state. After the system
awakes from an S4 state, OSPM will restore this memory area and call
the _WAK control method to enable the BIOS to reclaim its memory
image."  For this reason, implement a mechanism allowing us to save
the NVS memory during hibernation and to restore it during the
subsequent resume.

Based on a patch by Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Nigel Cunningham <nigel@tuxonice.net>
Cc: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/sleep/main.c |   53 +++++++++++++++++---
 include/linux/suspend.h   |   13 +++++
 kernel/power/swsusp.c     |  122 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 180 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 80c0868..f861b73 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -356,9 +356,25 @@ void __init acpi_no_s4_hw_signature(void)
 
 static int acpi_hibernation_begin(void)
 {
-	acpi_target_sleep_state = ACPI_STATE_S4;
-	acpi_sleep_tts_switch(acpi_target_sleep_state);
-	return 0;
+	int error;
+
+	error = hibernate_nvs_alloc();
+	if (!error) {
+		acpi_target_sleep_state = ACPI_STATE_S4;
+		acpi_sleep_tts_switch(acpi_target_sleep_state);
+	}
+
+	return error;
+}
+
+static int acpi_hibernation_pre_snapshot(void)
+{
+	int error = acpi_pm_prepare();
+
+	if (!error)
+		hibernate_nvs_save();
+
+	return error;
 }
 
 static int acpi_hibernation_enter(void)
@@ -379,6 +395,12 @@ static int acpi_hibernation_enter(void)
 	return ACPI_SUCCESS(status) ? 0 : -EFAULT;
 }
 
+static void acpi_hibernation_finish(void)
+{
+	hibernate_nvs_free();
+	acpi_pm_finish();
+}
+
 static void acpi_hibernation_leave(void)
 {
 	/*
@@ -394,6 +416,8 @@ static void acpi_hibernation_leave(void)
 			"cannot resume!\n");
 		panic("ACPI S4 hardware signature mismatch");
 	}
+	/* Restore the NVS memory area */
+	hibernate_nvs_restore();
 }
 
 static void acpi_pm_enable_gpes(void)
@@ -404,8 +428,8 @@ static void acpi_pm_enable_gpes(void)
 static struct platform_hibernation_ops acpi_hibernation_ops = {
 	.begin = acpi_hibernation_begin,
 	.end = acpi_pm_end,
-	.pre_snapshot = acpi_pm_prepare,
-	.finish = acpi_pm_finish,
+	.pre_snapshot = acpi_hibernation_pre_snapshot,
+	.finish = acpi_hibernation_finish,
 	.prepare = acpi_pm_prepare,
 	.enter = acpi_hibernation_enter,
 	.leave = acpi_hibernation_leave,
@@ -431,8 +455,21 @@ static int acpi_hibernation_begin_old(void)
 
 	error = acpi_sleep_prepare(ACPI_STATE_S4);
 
+	if (!error) {
+		error = hibernate_nvs_alloc();
+		if (!error)
+			acpi_target_sleep_state = ACPI_STATE_S4;
+	}
+	return error;
+}
+
+static int acpi_hibernation_pre_snapshot_old(void)
+{
+	int error = acpi_pm_disable_gpes();
+
 	if (!error)
-		acpi_target_sleep_state = ACPI_STATE_S4;
+		hibernate_nvs_save();
+
 	return error;
 }
 
@@ -443,8 +480,8 @@ static int acpi_hibernation_begin_old(void)
 static struct platform_hibernation_ops acpi_hibernation_ops_old = {
 	.begin = acpi_hibernation_begin_old,
 	.end = acpi_pm_end,
-	.pre_snapshot = acpi_pm_disable_gpes,
-	.finish = acpi_pm_finish,
+	.pre_snapshot = acpi_hibernation_pre_snapshot_old,
+	.finish = acpi_hibernation_finish,
 	.prepare = acpi_pm_disable_gpes,
 	.enter = acpi_hibernation_enter,
 	.leave = acpi_hibernation_leave,
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 2ce8207..2b409c4 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -232,6 +232,11 @@ extern unsigned long get_safe_page(gfp_t gfp_mask);
 
 extern void hibernation_set_ops(struct platform_hibernation_ops *ops);
 extern int hibernate(void);
+extern int hibernate_nvs_register(unsigned long start, unsigned long size);
+extern int hibernate_nvs_alloc(void);
+extern void hibernate_nvs_free(void);
+extern void hibernate_nvs_save(void);
+extern void hibernate_nvs_restore(void);
 #else /* CONFIG_HIBERNATION */
 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
 static inline void swsusp_set_page_free(struct page *p) {}
@@ -239,6 +244,14 @@ static inline void swsusp_unset_page_free(struct page *p) {}
 
 static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {}
 static inline int hibernate(void) { return -ENOSYS; }
+static inline int hibernate_nvs_register(unsigned long a, unsigned long b)
+{
+	return 0;
+}
+static inline int hibernate_nvs_alloc(void) { return 0; }
+static inline void hibernate_nvs_free(void) {}
+static inline void hibernate_nvs_save(void) {}
+static inline void hibernate_nvs_restore(void) {}
 #endif /* CONFIG_HIBERNATION */
 
 #ifdef CONFIG_PM_SLEEP
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 023ff2a..a92c914 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -262,3 +262,125 @@ int swsusp_shrink_memory(void)
 
 	return 0;
 }
+
+/*
+ * Platforms, like ACPI, may want us to save some memory used by them during
+ * hibernation and to restore the contents of this memory during the subsequent
+ * resume.  The code below implements a mechanism allowing us to do that.
+ */
+
+struct nvs_page {
+	unsigned long phys_start;
+	unsigned int size;
+	void *kaddr;
+	void *data;
+	struct list_head node;
+};
+
+static LIST_HEAD(nvs_list);
+
+/**
+ *	hibernate_nvs_register - register platform NVS memory region to save
+ *	@start - physical address of the region
+ *	@size - size of the region
+ *
+ *	The NVS region need not be page-aligned (both ends) and we arrange
+ *	things so that the data from page-aligned addresses in this region will
+ *	be copied into separate RAM pages.
+ */
+int hibernate_nvs_register(unsigned long start, unsigned long size)
+{
+	struct nvs_page *entry, *next;
+
+	while (size > 0) {
+		unsigned int nr_bytes;
+
+		entry = kzalloc(sizeof(struct nvs_page), GFP_KERNEL);
+		if (!entry)
+			goto Error;
+
+		list_add_tail(&entry->node, &nvs_list);
+		entry->phys_start = start;
+		nr_bytes = PAGE_SIZE - (start & ~PAGE_MASK);
+		entry->size = (size < nr_bytes) ? size : nr_bytes;
+
+		start += entry->size;
+		size -= entry->size;
+	}
+	return 0;
+
+ Error:
+	list_for_each_entry_safe(entry, next, &nvs_list, node) {
+		list_del(&entry->node);
+		kfree(entry);
+	}
+	return -ENOMEM;
+}
+
+/**
+ *	hibernate_nvs_free - free data pages allocated for saving NVS regions
+ */
+void hibernate_nvs_free(void)
+{
+	struct nvs_page *entry;
+
+	list_for_each_entry(entry, &nvs_list, node)
+		if (entry->data) {
+			free_page((unsigned long)entry->data);
+			entry->data = NULL;
+			if (entry->kaddr) {
+				iounmap(entry->kaddr);
+				entry->kaddr = NULL;
+			}
+		}
+}
+
+/**
+ *	hibernate_nvs_alloc - allocate memory necessary for saving NVS regions
+ */
+int hibernate_nvs_alloc(void)
+{
+	struct nvs_page *entry;
+
+	list_for_each_entry(entry, &nvs_list, node) {
+		entry->data = (void *)__get_free_page(GFP_KERNEL);
+		if (!entry->data) {
+			hibernate_nvs_free();
+			return -ENOMEM;
+		}
+	}
+	return 0;
+}
+
+/**
+ *	hibernate_nvs_save - save NVS memory regions
+ */
+void hibernate_nvs_save(void)
+{
+	struct nvs_page *entry;
+
+	printk(KERN_INFO "PM: Saving platform NVS memory\n");
+
+	list_for_each_entry(entry, &nvs_list, node)
+		if (entry->data) {
+			entry->kaddr = ioremap(entry->phys_start, entry->size);
+			memcpy(entry->data, entry->kaddr, entry->size);
+		}
+}
+
+/**
+ *	hibernate_nvs_restore - restore NVS memory regions
+ *
+ *	This function is going to be called with interrupts disabled, so it
+ *	cannot iounmap the virtual addresses used to access the NVS region.
+ */
+void hibernate_nvs_restore(void)
+{
+	struct nvs_page *entry;
+
+	printk(KERN_INFO "PM: Restoring platform NVS memory\n");
+
+	list_for_each_entry(entry, &nvs_list, node)
+		if (entry->data)
+			memcpy(entry->kaddr, entry->data, entry->size);
+}
-- 
1.5.6



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup
  2008-10-26 19:48 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Rafael J. Wysocki
  2008-10-26 19:50 ` [PATCH 1/4] Hibernate: Call platform_begin before swsusp_shrink_memory Rafael J. Wysocki
  2008-10-26 19:52 ` [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory Rafael J. Wysocki
@ 2008-10-26 19:54 ` Rafael J. Wysocki
  2008-10-28  9:17   ` Yinghai Lu
  2008-10-31  0:02   ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup (rev. 2) Rafael J. Wysocki
  2008-10-26 19:56 ` [PATCH 4/4] ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs Rafael J. Wysocki
  2008-10-28  5:37 ` [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Len Brown
  4 siblings, 2 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-26 19:54 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: x86 hibernate: Mark ACPI NVS memory region at startup

Introduce new initcall for marking the ACPI NVS memory at startup, so
that it can be saved/restore during hibernation/resume.

Based on a patch by Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Zhang Rui <rui.zhang@intel.com>
---
 arch/x86/kernel/e820.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index ce97bf3..e1e63a8 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -20,6 +20,7 @@
 #include <linux/pfn.h>
 #include <linux/suspend.h>
 #include <linux/firmware-map.h>
+#include <linux/efi.h>
 
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -665,6 +666,30 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
 }
 #endif
 
+#ifdef CONFIG_HIBERNATION
+/**
+ * Mark ACPI NVS memory region, so that we can save/restore it during
+ * hibernation and the subsequent resume.
+ */
+static int __init e820_mark_nvs_memory(void)
+{
+	int i;
+
+	if (efi_enabled)
+		return 0;
+
+	for (i = 0; i < e820.nr_map; i++) {
+		struct e820entry *ei = &e820.map[i];
+
+		if (ei->type == E820_NVS)
+			hibernate_nvs_register(ei->addr, ei->size);
+	}
+
+	return 0;
+}
+core_initcall(e820_mark_nvs_memory);
+#endif
+
 /*
  * Early reserved memory areas.
  */
-- 
1.5.6



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs
  2008-10-26 19:48 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2008-10-26 19:54 ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup Rafael J. Wysocki
@ 2008-10-26 19:56 ` Rafael J. Wysocki
  2008-10-28  5:37 ` [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Len Brown
  4 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-26 19:56 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs

On some machines it may be necessary to disable the saving/restoring
of the ACPI NVS memory region during hibernation/resume.  For this
purpose, introduce new ACPI kernel command line option
acpi_sleep=s4_nonvs.

Based on a patch by Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Nigel Cunningham <nigel@tuxonice.net>
Acked-by: Pavel Machek <pavel@suse.cz>
Cc: Zhang Rui <rui.zhang@intel.com>
---
 Documentation/kernel-parameters.txt |    5 ++++-
 arch/x86/kernel/acpi/sleep.c        |    2 ++
 drivers/acpi/sleep/main.c           |   19 +++++++++++++++++--
 include/linux/acpi.h                |    1 +
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 343e0f0..9567123 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -149,7 +149,8 @@ and is between 256 and 4096 characters. It is defined in the file
 			default: 0
 
 	acpi_sleep=	[HW,ACPI] Sleep options
-			Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig, old_ordering }
+			Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig,
+				  old_ordering, s4_nonvs }
 			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.
@@ -159,6 +160,8 @@ and is between 256 and 4096 characters. It is defined in the file
 			control method, wrt putting devices into low power
 			states, to be enforced (the ACPI 2.0 ordering of _PTS is
 			used by default).
+			s4_nonvs prevents the kernel from saving/restoring the
+			ACPI NVS memory during hibernation.
 
 	acpi_sci=	[HW,ACPI] ACPI System Control Interrupt trigger mode
 			Format: { level | edge | high | low }
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index f8a12a8..1d3f36c 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -161,6 +161,8 @@ static int __init acpi_sleep_setup(char *str)
 #endif
 		if (strncmp(str, "old_ordering", 12) == 0)
 			acpi_old_suspend_ordering();
+		if (strncmp(str, "s4_nonvs", 8) == 0)
+			acpi_s4_no_nvs();
 		str = strchr(str, ',');
 		if (str != NULL)
 			str += strspn(str, ", \t");
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index f861b73..63bff78 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -90,6 +90,20 @@ void __init acpi_old_suspend_ordering(void)
 	old_suspend_ordering = true;
 }
 
+/*
+ * The ACPI specification wants us to save NVS memory regions during hibernation
+ * and to restore them during the subsequent resume.  However, it is not certain
+ * if this mechanism is going to work on all machines, so we allow the user to
+ * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
+ * option.
+ */
+static bool s4_no_nvs;
+
+void __init acpi_s4_no_nvs(void)
+{
+	s4_no_nvs = true;
+}
+
 /**
  *	acpi_pm_disable_gpes - Disable the GPEs.
  */
@@ -358,7 +372,7 @@ static int acpi_hibernation_begin(void)
 {
 	int error;
 
-	error = hibernate_nvs_alloc();
+	error = s4_no_nvs ? 0 : hibernate_nvs_alloc();
 	if (!error) {
 		acpi_target_sleep_state = ACPI_STATE_S4;
 		acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -456,7 +470,8 @@ static int acpi_hibernation_begin_old(void)
 	error = acpi_sleep_prepare(ACPI_STATE_S4);
 
 	if (!error) {
-		error = hibernate_nvs_alloc();
+		if (!s4_no_nvs)
+			error = hibernate_nvs_alloc();
 		if (!error)
 			acpi_target_sleep_state = ACPI_STATE_S4;
 	}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index fd6a452..4008f61 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -230,6 +230,7 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n,
 #ifdef CONFIG_PM_SLEEP
 void __init acpi_no_s4_hw_signature(void);
 void __init acpi_old_suspend_ordering(void);
+void __init acpi_s4_no_nvs(void);
 #endif /* CONFIG_PM_SLEEP */
 #else	/* CONFIG_ACPI */
 
-- 
1.5.6



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2)
  2008-10-26 19:48 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2008-10-26 19:56 ` [PATCH 4/4] ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs Rafael J. Wysocki
@ 2008-10-28  5:37 ` Len Brown
  2008-10-28 13:31   ` Rafael J. Wysocki
  4 siblings, 1 reply; 11+ messages in thread
From: Len Brown @ 2008-10-28  5:37 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui



> This is my second version of the patchset making the Linux hibernation code
> handle the ACPI NVS memory as required by the spec, based on the previous
> Zhang Rui's patches.
> 
> Please queue in the 'suspend' branch as .29 material.

done.

thanks,
-Len

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup
  2008-10-26 19:54 ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup Rafael J. Wysocki
@ 2008-10-28  9:17   ` Yinghai Lu
  2008-10-28 13:30     ` Rafael J. Wysocki
  2008-10-31  0:02   ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup (rev. 2) Rafael J. Wysocki
  1 sibling, 1 reply; 11+ messages in thread
From: Yinghai Lu @ 2008-10-28  9:17 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, ACPI Devel Maling List, pm list, Nigel Cunningham,
	Pavel Machek, Ingo Molnar, Zhang Rui

On Sun, Oct 26, 2008 at 12:54 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
> Subject: x86 hibernate: Mark ACPI NVS memory region at startup
>
> Introduce new initcall for marking the ACPI NVS memory at startup, so
> that it can be saved/restore during hibernation/resume.
>
> Based on a patch by Zhang Rui.
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Zhang Rui <rui.zhang@intel.com>
> ---
>  arch/x86/kernel/e820.c |   25 +++++++++++++++++++++++++
>  1 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index ce97bf3..e1e63a8 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -20,6 +20,7 @@
>  #include <linux/pfn.h>
>  #include <linux/suspend.h>
>  #include <linux/firmware-map.h>
> +#include <linux/efi.h>
>
>  #include <asm/pgtable.h>
>  #include <asm/page.h>
> @@ -665,6 +666,30 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
>  }
>  #endif
>
> +#ifdef CONFIG_HIBERNATION
> +/**
> + * Mark ACPI NVS memory region, so that we can save/restore it during
> + * hibernation and the subsequent resume.
> + */
> +static int __init e820_mark_nvs_memory(void)
> +{
> +       int i;
> +
> +       if (efi_enabled)
> +               return 0;
> +
> +       for (i = 0; i < e820.nr_map; i++) {
> +               struct e820entry *ei = &e820.map[i];
> +
> +               if (ei->type == E820_NVS)
> +                       hibernate_nvs_register(ei->addr, ei->size);

do you need to something to ACPI code too?

BIOS-provided physical RAM map:
>  BIOS-e820: 0000000000000100 - 0000000000095800 (usable)
>  BIOS-e820: 0000000000095800 - 00000000000a0000 (reserved)
>  BIOS-e820: 0000000000100000 - 00000000d7fa0000 (usable)
>  BIOS-e820: 00000000d7fae000 - 00000000d7fb0000 (reserved)
>  BIOS-e820: 00000000d7fb0000 - 00000000d7fbe000 (ACPI data) <================ acpi code
>  BIOS-e820: 00000000d7fbe000 - 00000000d7ff0000 (ACPI NVS)
>  BIOS-e820: 00000000d7ff0000 - 00000000d8000000 (reserved)
>  BIOS-e820: 00000000dc000000 - 00000000f0000000 (reserved)
>  BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved)
>  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
>  BIOS-e820: 00000000ff700000 - 0000000100000000 (reserved)
>  BIOS-e820: 0000000100000000 - 0000004028000000 (usable)

YH

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup
  2008-10-28  9:17   ` Yinghai Lu
@ 2008-10-28 13:30     ` Rafael J. Wysocki
  0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-28 13:30 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Len Brown, ACPI Devel Maling List, pm list, Nigel Cunningham,
	Pavel Machek, Ingo Molnar, Zhang Rui

On Tuesday, 28 of October 2008, Yinghai Lu wrote:
> On Sun, Oct 26, 2008 at 12:54 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> > Subject: x86 hibernate: Mark ACPI NVS memory region at startup
> >
> > Introduce new initcall for marking the ACPI NVS memory at startup, so
> > that it can be saved/restore during hibernation/resume.
> >
> > Based on a patch by Zhang Rui.
> >
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  arch/x86/kernel/e820.c |   25 +++++++++++++++++++++++++
> >  1 files changed, 25 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> > index ce97bf3..e1e63a8 100644
> > --- a/arch/x86/kernel/e820.c
> > +++ b/arch/x86/kernel/e820.c
> > @@ -20,6 +20,7 @@
> >  #include <linux/pfn.h>
> >  #include <linux/suspend.h>
> >  #include <linux/firmware-map.h>
> > +#include <linux/efi.h>
> >
> >  #include <asm/pgtable.h>
> >  #include <asm/page.h>
> > @@ -665,6 +666,30 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
> >  }
> >  #endif
> >
> > +#ifdef CONFIG_HIBERNATION
> > +/**
> > + * Mark ACPI NVS memory region, so that we can save/restore it during
> > + * hibernation and the subsequent resume.
> > + */
> > +static int __init e820_mark_nvs_memory(void)
> > +{
> > +       int i;
> > +
> > +       if (efi_enabled)
> > +               return 0;
> > +
> > +       for (i = 0; i < e820.nr_map; i++) {
> > +               struct e820entry *ei = &e820.map[i];
> > +
> > +               if (ei->type == E820_NVS)
> > +                       hibernate_nvs_register(ei->addr, ei->size);
> 
> do you need to something to ACPI code too?

No, ACPI NVS only, according to the spec.

> BIOS-provided physical RAM map:
> >  BIOS-e820: 0000000000000100 - 0000000000095800 (usable)
> >  BIOS-e820: 0000000000095800 - 00000000000a0000 (reserved)
> >  BIOS-e820: 0000000000100000 - 00000000d7fa0000 (usable)
> >  BIOS-e820: 00000000d7fae000 - 00000000d7fb0000 (reserved)
> >  BIOS-e820: 00000000d7fb0000 - 00000000d7fbe000 (ACPI data) <================ acpi code
> >  BIOS-e820: 00000000d7fbe000 - 00000000d7ff0000 (ACPI NVS)
> >  BIOS-e820: 00000000d7ff0000 - 00000000d8000000 (reserved)
> >  BIOS-e820: 00000000dc000000 - 00000000f0000000 (reserved)
> >  BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved)
> >  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
> >  BIOS-e820: 00000000ff700000 - 0000000100000000 (reserved)
> >  BIOS-e820: 0000000100000000 - 0000004028000000 (usable)

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2)
  2008-10-28  5:37 ` [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Len Brown
@ 2008-10-28 13:31   ` Rafael J. Wysocki
  0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-28 13:31 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

On Tuesday, 28 of October 2008, Len Brown wrote:
> 
> > This is my second version of the patchset making the Linux hibernation code
> > handle the ACPI NVS memory as required by the spec, based on the previous
> > Zhang Rui's patches.
> > 
> > Please queue in the 'suspend' branch as .29 material.
> 
> done.

Thanks!

Best,
Rafael

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup (rev. 2)
  2008-10-26 19:54 ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup Rafael J. Wysocki
  2008-10-28  9:17   ` Yinghai Lu
@ 2008-10-31  0:02   ` Rafael J. Wysocki
  2008-11-07  2:24     ` Len Brown
  1 sibling, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2008-10-31  0:02 UTC (permalink / raw)
  To: Len Brown
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui

Hi Len,

Please replace this patch with the appended one.

I have verified that we are supposed to save/restore the NVS area in the EFI
case too.

Thanks,
Rafael


On Sunday, 26 of October 2008, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
> Subject: x86 hibernate: Mark ACPI NVS memory region at startup
> 
> Introduce new initcall for marking the ACPI NVS memory at startup, so
> that it can be saved/restore during hibernation/resume.
> 
> Based on a patch by Zhang Rui.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Zhang Rui <rui.zhang@intel.com>
> ---
>  arch/x86/kernel/e820.c |   25 +++++++++++++++++++++++++
>  1 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
> index ce97bf3..e1e63a8 100644
> --- a/arch/x86/kernel/e820.c
> +++ b/arch/x86/kernel/e820.c
> @@ -20,6 +20,7 @@
>  #include <linux/pfn.h>
>  #include <linux/suspend.h>
>  #include <linux/firmware-map.h>
> +#include <linux/efi.h>
>  
>  #include <asm/pgtable.h>
>  #include <asm/page.h>
> @@ -665,6 +666,30 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
>  }
>  #endif
>  
> +#ifdef CONFIG_HIBERNATION
> +/**
> + * Mark ACPI NVS memory region, so that we can save/restore it during
> + * hibernation and the subsequent resume.
> + */
> +static int __init e820_mark_nvs_memory(void)
> +{
> +	int i;
> +
> +	if (efi_enabled)
> +		return 0;
> +
> +	for (i = 0; i < e820.nr_map; i++) {
> +		struct e820entry *ei = &e820.map[i];
> +
> +		if (ei->type == E820_NVS)
> +			hibernate_nvs_register(ei->addr, ei->size);
> +	}
> +
> +	return 0;
> +}
> +core_initcall(e820_mark_nvs_memory);
> +#endif
> +
>  /*
>   * Early reserved memory areas.
>   */

---
From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: x86 hibernate: Mark ACPI NVS memory region at startup

Introduce new initcall for marking the ACPI NVS memory at startup, so
that it can be saved/restored during hibernation/resume.

Based on a patch by Zhang Rui.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Zhang Rui <rui.zhang@intel.com>

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index ce97bf3..261d19c 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -665,6 +665,27 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
 }
 #endif
 
+#ifdef CONFIG_HIBERNATION
+/**
+ * Mark ACPI NVS memory region, so that we can save/restore it during
+ * hibernation and the subsequent resume.
+ */
+static int __init e820_mark_nvs_memory(void)
+{
+	int i;
+
+	for (i = 0; i < e820.nr_map; i++) {
+		struct e820entry *ei = &e820.map[i];
+
+		if (ei->type == E820_NVS)
+			hibernate_nvs_register(ei->addr, ei->size);
+	}
+
+	return 0;
+}
+core_initcall(e820_mark_nvs_memory);
+#endif
+
 /*
  * Early reserved memory areas.
  */

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup (rev. 2)
  2008-10-31  0:02   ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup (rev. 2) Rafael J. Wysocki
@ 2008-11-07  2:24     ` Len Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Len Brown @ 2008-11-07  2:24 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, pm list, Nigel Cunningham, Pavel Machek,
	Ingo Molnar, Zhang Rui


> Please replace this patch with the appended one.
> 
> I have verified that we are supposed to save/restore the NVS area in the EFI
> case too.

done.
i've also rebased the suspend branch on top of latest linus.

thanks,
-Len

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-11-07  2:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-26 19:48 [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Rafael J. Wysocki
2008-10-26 19:50 ` [PATCH 1/4] Hibernate: Call platform_begin before swsusp_shrink_memory Rafael J. Wysocki
2008-10-26 19:52 ` [PATCH 2/4] ACPI hibernate: Add a mechanism to save/restore ACPI NVS memory Rafael J. Wysocki
2008-10-26 19:54 ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup Rafael J. Wysocki
2008-10-28  9:17   ` Yinghai Lu
2008-10-28 13:30     ` Rafael J. Wysocki
2008-10-31  0:02   ` [PATCH 3/4] x86 hibernate: Mark ACPI NVS memory region at startup (rev. 2) Rafael J. Wysocki
2008-11-07  2:24     ` Len Brown
2008-10-26 19:56 ` [PATCH 4/4] ACPI hibernate: Introduce new kernel parameter acpi_sleep=s4_nonvs Rafael J. Wysocki
2008-10-28  5:37 ` [PATCH 0/4] Hibernate: Handle ACPI NVS memory as required by the spec (rev. 2) Len Brown
2008-10-28 13:31   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox