aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2010-06-12 01:15:40 -0400
committerLen Brown <len.brown@intel.com>2010-06-12 01:15:40 -0400
commit42de5532f4a58a52a60bdd8bd4f80f9f210dd65b (patch)
treef624579c4c27e1ffcba5e4141fcc0877c3a6ae56
parente9e8b4dd142da3b6cbf301ba922804d6cdc31a17 (diff)
parent2a6b69765ad794389f2fc3e14a0afa1a995221c2 (diff)
Merge branch 'bugzilla-13931-sleep-nvs' into release
Conflicts: drivers/acpi/sleep.c Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--arch/x86/kernel/e820.c2
-rw-r--r--drivers/acpi/sleep.c34
-rw-r--r--include/linux/suspend.h26
-rw-r--r--kernel/power/Kconfig9
-rw-r--r--kernel/power/Makefile2
-rw-r--r--kernel/power/nvs.c (renamed from kernel/power/hibernate_nvs.c)24
-rw-r--r--kernel/power/suspend.c6
7 files changed, 57 insertions, 46 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 7bca3c6a02fb..0d6fc71bedb1 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -729,7 +729,7 @@ static int __init e820_mark_nvs_memory(void)
729 struct e820entry *ei = &e820.map[i]; 729 struct e820entry *ei = &e820.map[i];
730 730
731 if (ei->type == E820_NVS) 731 if (ei->type == E820_NVS)
732 hibernate_nvs_register(ei->addr, ei->size); 732 suspend_nvs_register(ei->addr, ei->size);
733 } 733 }
734 734
735 return 0; 735 return 0;
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 3fb4bdea7e06..5b7c52e4a00f 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -114,6 +114,8 @@ static int __acpi_pm_prepare(void)
114{ 114{
115 int error = acpi_sleep_prepare(acpi_target_sleep_state); 115 int error = acpi_sleep_prepare(acpi_target_sleep_state);
116 116
117 suspend_nvs_save();
118
117 if (error) 119 if (error)
118 acpi_target_sleep_state = ACPI_STATE_S0; 120 acpi_target_sleep_state = ACPI_STATE_S0;
119 return error; 121 return error;
@@ -143,6 +145,9 @@ static void acpi_pm_finish(void)
143{ 145{
144 u32 acpi_state = acpi_target_sleep_state; 146 u32 acpi_state = acpi_target_sleep_state;
145 147
148 suspend_nvs_free();
149 acpi_ec_unblock_transactions();
150
146 if (acpi_state == ACPI_STATE_S0) 151 if (acpi_state == ACPI_STATE_S0)
147 return; 152 return;
148 153
@@ -192,6 +197,11 @@ static int acpi_suspend_begin(suspend_state_t pm_state)
192 u32 acpi_state = acpi_suspend_states[pm_state]; 197 u32 acpi_state = acpi_suspend_states[pm_state];
193 int error = 0; 198 int error = 0;
194 199
200 error = suspend_nvs_alloc();
201
202 if (error)
203 return error;
204
195 if (sleep_states[acpi_state]) { 205 if (sleep_states[acpi_state]) {
196 acpi_target_sleep_state = acpi_state; 206 acpi_target_sleep_state = acpi_state;
197 acpi_sleep_tts_switch(acpi_target_sleep_state); 207 acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -269,12 +279,13 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
269 if (acpi_state == ACPI_STATE_S3) 279 if (acpi_state == ACPI_STATE_S3)
270 acpi_restore_state_mem(); 280 acpi_restore_state_mem();
271 281
282 suspend_nvs_restore();
283
272 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 284 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
273} 285}
274 286
275static void acpi_suspend_finish(void) 287static void acpi_suspend_finish(void)
276{ 288{
277 acpi_ec_unblock_transactions();
278 acpi_pm_finish(); 289 acpi_pm_finish();
279} 290}
280 291
@@ -404,7 +415,7 @@ static int acpi_hibernation_begin(void)
404{ 415{
405 int error; 416 int error;
406 417
407 error = s4_no_nvs ? 0 : hibernate_nvs_alloc(); 418 error = s4_no_nvs ? 0 : suspend_nvs_alloc();
408 if (!error) { 419 if (!error) {
409 acpi_target_sleep_state = ACPI_STATE_S4; 420 acpi_target_sleep_state = ACPI_STATE_S4;
410 acpi_sleep_tts_switch(acpi_target_sleep_state); 421 acpi_sleep_tts_switch(acpi_target_sleep_state);
@@ -418,7 +429,7 @@ static int acpi_hibernation_pre_snapshot(void)
418 int error = acpi_pm_prepare(); 429 int error = acpi_pm_prepare();
419 430
420 if (!error) 431 if (!error)
421 hibernate_nvs_save(); 432 suspend_nvs_save();
422 433
423 return error; 434 return error;
424} 435}
@@ -441,13 +452,6 @@ static int acpi_hibernation_enter(void)
441 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 452 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
442} 453}
443 454
444static void acpi_hibernation_finish(void)
445{
446 hibernate_nvs_free();
447 acpi_ec_unblock_transactions();
448 acpi_pm_finish();
449}
450
451static void acpi_hibernation_leave(void) 455static void acpi_hibernation_leave(void)
452{ 456{
453 /* 457 /*
@@ -464,7 +468,7 @@ static void acpi_hibernation_leave(void)
464 panic("ACPI S4 hardware signature mismatch"); 468 panic("ACPI S4 hardware signature mismatch");
465 } 469 }
466 /* Restore the NVS memory area */ 470 /* Restore the NVS memory area */
467 hibernate_nvs_restore(); 471 suspend_nvs_restore();
468 /* Allow EC transactions to happen. */ 472 /* Allow EC transactions to happen. */
469 acpi_ec_unblock_transactions_early(); 473 acpi_ec_unblock_transactions_early();
470} 474}
@@ -479,7 +483,7 @@ static struct platform_hibernation_ops acpi_hibernation_ops = {
479 .begin = acpi_hibernation_begin, 483 .begin = acpi_hibernation_begin,
480 .end = acpi_pm_end, 484 .end = acpi_pm_end,
481 .pre_snapshot = acpi_hibernation_pre_snapshot, 485 .pre_snapshot = acpi_hibernation_pre_snapshot,
482 .finish = acpi_hibernation_finish, 486 .finish = acpi_pm_finish,
483 .prepare = acpi_pm_prepare, 487 .prepare = acpi_pm_prepare,
484 .enter = acpi_hibernation_enter, 488 .enter = acpi_hibernation_enter,
485 .leave = acpi_hibernation_leave, 489 .leave = acpi_hibernation_leave,
@@ -507,7 +511,7 @@ static int acpi_hibernation_begin_old(void)
507 511
508 if (!error) { 512 if (!error) {
509 if (!s4_no_nvs) 513 if (!s4_no_nvs)
510 error = hibernate_nvs_alloc(); 514 error = suspend_nvs_alloc();
511 if (!error) 515 if (!error)
512 acpi_target_sleep_state = ACPI_STATE_S4; 516 acpi_target_sleep_state = ACPI_STATE_S4;
513 } 517 }
@@ -517,7 +521,7 @@ static int acpi_hibernation_begin_old(void)
517static int acpi_hibernation_pre_snapshot_old(void) 521static int acpi_hibernation_pre_snapshot_old(void)
518{ 522{
519 acpi_pm_freeze(); 523 acpi_pm_freeze();
520 hibernate_nvs_save(); 524 suspend_nvs_save();
521 return 0; 525 return 0;
522} 526}
523 527
@@ -529,8 +533,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = {
529 .begin = acpi_hibernation_begin_old, 533 .begin = acpi_hibernation_begin_old,
530 .end = acpi_pm_end, 534 .end = acpi_pm_end,
531 .pre_snapshot = acpi_hibernation_pre_snapshot_old, 535 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
532 .finish = acpi_hibernation_finish,
533 .prepare = acpi_pm_freeze, 536 .prepare = acpi_pm_freeze,
537 .finish = acpi_pm_finish,
534 .enter = acpi_hibernation_enter, 538 .enter = acpi_hibernation_enter,
535 .leave = acpi_hibernation_leave, 539 .leave = acpi_hibernation_leave,
536 .pre_restore = acpi_pm_freeze, 540 .pre_restore = acpi_pm_freeze,
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 5e781d824e6d..bc7d6bb4cd8e 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -256,22 +256,22 @@ static inline int hibernate(void) { return -ENOSYS; }
256static inline bool system_entering_hibernation(void) { return false; } 256static inline bool system_entering_hibernation(void) { return false; }
257#endif /* CONFIG_HIBERNATION */ 257#endif /* CONFIG_HIBERNATION */
258 258
259#ifdef CONFIG_HIBERNATION_NVS 259#ifdef CONFIG_SUSPEND_NVS
260extern int hibernate_nvs_register(unsigned long start, unsigned long size); 260extern int suspend_nvs_register(unsigned long start, unsigned long size);
261extern int hibernate_nvs_alloc(void); 261extern int suspend_nvs_alloc(void);
262extern void hibernate_nvs_free(void); 262extern void suspend_nvs_free(void);
263extern void hibernate_nvs_save(void); 263extern void suspend_nvs_save(void);
264extern void hibernate_nvs_restore(void); 264extern void suspend_nvs_restore(void);
265#else /* CONFIG_HIBERNATION_NVS */ 265#else /* CONFIG_SUSPEND_NVS */
266static inline int hibernate_nvs_register(unsigned long a, unsigned long b) 266static inline int suspend_nvs_register(unsigned long a, unsigned long b)
267{ 267{
268 return 0; 268 return 0;
269} 269}
270static inline int hibernate_nvs_alloc(void) { return 0; } 270static inline int suspend_nvs_alloc(void) { return 0; }
271static inline void hibernate_nvs_free(void) {} 271static inline void suspend_nvs_free(void) {}
272static inline void hibernate_nvs_save(void) {} 272static inline void suspend_nvs_save(void) {}
273static inline void hibernate_nvs_restore(void) {} 273static inline void suspend_nvs_restore(void) {}
274#endif /* CONFIG_HIBERNATION_NVS */ 274#endif /* CONFIG_SUSPEND_NVS */
275 275
276#ifdef CONFIG_PM_SLEEP 276#ifdef CONFIG_PM_SLEEP
277void save_processor_state(void); 277void save_processor_state(void);
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 5c36ea9d55d2..ca6066a6952e 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -99,9 +99,13 @@ config PM_SLEEP_ADVANCED_DEBUG
99 depends on PM_ADVANCED_DEBUG 99 depends on PM_ADVANCED_DEBUG
100 default n 100 default n
101 101
102config SUSPEND_NVS
103 bool
104
102config SUSPEND 105config SUSPEND
103 bool "Suspend to RAM and standby" 106 bool "Suspend to RAM and standby"
104 depends on PM && ARCH_SUSPEND_POSSIBLE 107 depends on PM && ARCH_SUSPEND_POSSIBLE
108 select SUSPEND_NVS if HAS_IOMEM
105 default y 109 default y
106 ---help--- 110 ---help---
107 Allow the system to enter sleep states in which main memory is 111 Allow the system to enter sleep states in which main memory is
@@ -130,13 +134,10 @@ config SUSPEND_FREEZER
130 134
131 Turning OFF this setting is NOT recommended! If in doubt, say Y. 135 Turning OFF this setting is NOT recommended! If in doubt, say Y.
132 136
133config HIBERNATION_NVS
134 bool
135
136config HIBERNATION 137config HIBERNATION
137 bool "Hibernation (aka 'suspend to disk')" 138 bool "Hibernation (aka 'suspend to disk')"
138 depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE 139 depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
139 select HIBERNATION_NVS if HAS_IOMEM 140 select SUSPEND_NVS if HAS_IOMEM
140 ---help--- 141 ---help---
141 Enable the suspend to disk (STD) functionality, which is usually 142 Enable the suspend to disk (STD) functionality, which is usually
142 called "hibernation" in user interfaces. STD checkpoints the 143 called "hibernation" in user interfaces. STD checkpoints the
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index 524e058dcf06..f9063c6b185d 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -10,6 +10,6 @@ obj-$(CONFIG_SUSPEND) += suspend.o
10obj-$(CONFIG_PM_TEST_SUSPEND) += suspend_test.o 10obj-$(CONFIG_PM_TEST_SUSPEND) += suspend_test.o
11obj-$(CONFIG_HIBERNATION) += hibernate.o snapshot.o swap.o user.o \ 11obj-$(CONFIG_HIBERNATION) += hibernate.o snapshot.o swap.o user.o \
12 block_io.o 12 block_io.o
13obj-$(CONFIG_HIBERNATION_NVS) += hibernate_nvs.o 13obj-$(CONFIG_SUSPEND_NVS) += nvs.o
14 14
15obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o 15obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
diff --git a/kernel/power/hibernate_nvs.c b/kernel/power/nvs.c
index fdcad9ed5a7b..1836db60bbb6 100644
--- a/kernel/power/hibernate_nvs.c
+++ b/kernel/power/nvs.c
@@ -15,7 +15,7 @@
15 15
16/* 16/*
17 * Platforms, like ACPI, may want us to save some memory used by them during 17 * Platforms, like ACPI, may want us to save some memory used by them during
18 * hibernation and to restore the contents of this memory during the subsequent 18 * suspend and to restore the contents of this memory during the subsequent
19 * resume. The code below implements a mechanism allowing us to do that. 19 * resume. The code below implements a mechanism allowing us to do that.
20 */ 20 */
21 21
@@ -30,7 +30,7 @@ struct nvs_page {
30static LIST_HEAD(nvs_list); 30static LIST_HEAD(nvs_list);
31 31
32/** 32/**
33 * hibernate_nvs_register - register platform NVS memory region to save 33 * suspend_nvs_register - register platform NVS memory region to save
34 * @start - physical address of the region 34 * @start - physical address of the region
35 * @size - size of the region 35 * @size - size of the region
36 * 36 *
@@ -38,7 +38,7 @@ static LIST_HEAD(nvs_list);
38 * things so that the data from page-aligned addresses in this region will 38 * things so that the data from page-aligned addresses in this region will
39 * be copied into separate RAM pages. 39 * be copied into separate RAM pages.
40 */ 40 */
41int hibernate_nvs_register(unsigned long start, unsigned long size) 41int suspend_nvs_register(unsigned long start, unsigned long size)
42{ 42{
43 struct nvs_page *entry, *next; 43 struct nvs_page *entry, *next;
44 44
@@ -68,9 +68,9 @@ int hibernate_nvs_register(unsigned long start, unsigned long size)
68} 68}
69 69
70/** 70/**
71 * hibernate_nvs_free - free data pages allocated for saving NVS regions 71 * suspend_nvs_free - free data pages allocated for saving NVS regions
72 */ 72 */
73void hibernate_nvs_free(void) 73void suspend_nvs_free(void)
74{ 74{
75 struct nvs_page *entry; 75 struct nvs_page *entry;
76 76
@@ -86,16 +86,16 @@ void hibernate_nvs_free(void)
86} 86}
87 87
88/** 88/**
89 * hibernate_nvs_alloc - allocate memory necessary for saving NVS regions 89 * suspend_nvs_alloc - allocate memory necessary for saving NVS regions
90 */ 90 */
91int hibernate_nvs_alloc(void) 91int suspend_nvs_alloc(void)
92{ 92{
93 struct nvs_page *entry; 93 struct nvs_page *entry;
94 94
95 list_for_each_entry(entry, &nvs_list, node) { 95 list_for_each_entry(entry, &nvs_list, node) {
96 entry->data = (void *)__get_free_page(GFP_KERNEL); 96 entry->data = (void *)__get_free_page(GFP_KERNEL);
97 if (!entry->data) { 97 if (!entry->data) {
98 hibernate_nvs_free(); 98 suspend_nvs_free();
99 return -ENOMEM; 99 return -ENOMEM;
100 } 100 }
101 } 101 }
@@ -103,9 +103,9 @@ int hibernate_nvs_alloc(void)
103} 103}
104 104
105/** 105/**
106 * hibernate_nvs_save - save NVS memory regions 106 * suspend_nvs_save - save NVS memory regions
107 */ 107 */
108void hibernate_nvs_save(void) 108void suspend_nvs_save(void)
109{ 109{
110 struct nvs_page *entry; 110 struct nvs_page *entry;
111 111
@@ -119,12 +119,12 @@ void hibernate_nvs_save(void)
119} 119}
120 120
121/** 121/**
122 * hibernate_nvs_restore - restore NVS memory regions 122 * suspend_nvs_restore - restore NVS memory regions
123 * 123 *
124 * This function is going to be called with interrupts disabled, so it 124 * This function is going to be called with interrupts disabled, so it
125 * cannot iounmap the virtual addresses used to access the NVS region. 125 * cannot iounmap the virtual addresses used to access the NVS region.
126 */ 126 */
127void hibernate_nvs_restore(void) 127void suspend_nvs_restore(void)
128{ 128{
129 struct nvs_page *entry; 129 struct nvs_page *entry;
130 130
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 56e7dbb8b996..f37cb7dd4402 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -16,6 +16,12 @@
16#include <linux/cpu.h> 16#include <linux/cpu.h>
17#include <linux/syscalls.h> 17#include <linux/syscalls.h>
18#include <linux/gfp.h> 18#include <linux/gfp.h>
19#include <linux/io.h>
20#include <linux/kernel.h>
21#include <linux/list.h>
22#include <linux/mm.h>
23#include <linux/slab.h>
24#include <linux/suspend.h>
19 25
20#include "power.h" 26#include "power.h"
21 27