aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-07-29 17:27:18 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-29 19:45:38 -0400
commit296699de6bdc717189a331ab6bbe90e05c94db06 (patch)
tree53c847ecc8cce11952502921844052e44ca60d5e /kernel/power
parentb0cb1a19d05b8ea8611a9ef48a17fe417f1832e6 (diff)
Introduce CONFIG_SUSPEND for suspend-to-Ram and standby
Introduce CONFIG_SUSPEND representing the ability to enter system sleep states, such as the ACPI S3 state, and allow the user to choose SUSPEND and HIBERNATION independently of each other. Make HOTPLUG_CPU be selected automatically if SUSPEND or HIBERNATION has been chosen and the kernel is intended for SMP systems. Also, introduce CONFIG_PM_SLEEP which is automatically selected if CONFIG_SUSPEND or CONFIG_HIBERNATION is set and use it to select the code needed for both suspend and hibernation. The top-level power management headers and the ACPI code related to suspend and hibernation are modified to use the new definitions (the changes in drivers/acpi/sleep/main.c are, mostly, moving code to reduce the number of ifdefs). There are many other files in which CONFIG_PM can be replaced with CONFIG_PM_SLEEP or even with CONFIG_SUSPEND, but they can be updated in the future. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/Kconfig41
-rw-r--r--kernel/power/Makefile3
-rw-r--r--kernel/power/main.c26
-rw-r--r--kernel/power/power.h10
4 files changed, 61 insertions, 19 deletions
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index c2582a4a5373..412859f8d94a 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -46,7 +46,7 @@ config PM_VERBOSE
46 46
47config DISABLE_CONSOLE_SUSPEND 47config DISABLE_CONSOLE_SUSPEND
48 bool "Keep console(s) enabled during suspend/resume (DANGEROUS)" 48 bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
49 depends on PM_DEBUG 49 depends on PM_DEBUG && PM_SLEEP
50 default n 50 default n
51 ---help--- 51 ---help---
52 This option turns off the console suspend mechanism that prevents 52 This option turns off the console suspend mechanism that prevents
@@ -57,7 +57,7 @@ config DISABLE_CONSOLE_SUSPEND
57 57
58config PM_TRACE 58config PM_TRACE
59 bool "Suspend/resume event tracing" 59 bool "Suspend/resume event tracing"
60 depends on PM_DEBUG && X86 && EXPERIMENTAL 60 depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
61 default n 61 default n
62 ---help--- 62 ---help---
63 This enables some cheesy code to save the last PM event point in the 63 This enables some cheesy code to save the last PM event point in the
@@ -72,9 +72,37 @@ config PM_TRACE
72 CAUTION: this option will cause your machine's real-time clock to be 72 CAUTION: this option will cause your machine's real-time clock to be
73 set to an invalid time after a resume. 73 set to an invalid time after a resume.
74 74
75config SUSPEND_SMP_POSSIBLE
76 bool
77 depends on (X86 && !X86_VOYAGER) || (PPC64 && (PPC_PSERIES || PPC_PMAC))
78 depends on SMP
79 default y
80
81config SUSPEND_SMP
82 bool
83 depends on SUSPEND_SMP_POSSIBLE && PM_SLEEP
84 select HOTPLUG_CPU
85 default y
86
87config PM_SLEEP
88 bool
89 depends on SUSPEND || HIBERNATION
90 default y
91
92config SUSPEND
93 bool "Suspend to RAM and standby"
94 depends on PM
95 depends on !SMP || SUSPEND_SMP_POSSIBLE
96 default y
97 ---help---
98 Allow the system to enter sleep states in which main memory is
99 powered and thus its contents are preserved, such as the
100 suspend-to-RAM state (i.e. the ACPI S3 state).
101
75config HIBERNATION 102config HIBERNATION
76 bool "Hibernation" 103 bool "Hibernation (aka 'suspend to disk')"
77 depends on PM && SWAP && (((X86 || PPC64_SWSUSP) && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP)) 104 depends on PM && SWAP
105 depends on ((X86 || PPC64_SWSUSP || FRV || PPC32) && !SMP) || SUSPEND_SMP_POSSIBLE
78 ---help--- 106 ---help---
79 Enable the suspend to disk (STD) functionality, which is usually 107 Enable the suspend to disk (STD) functionality, which is usually
80 called "hibernation" in user interfaces. STD checkpoints the 108 called "hibernation" in user interfaces. STD checkpoints the
@@ -132,11 +160,6 @@ config PM_STD_PARTITION
132 suspended image to. It will simply pick the first available swap 160 suspended image to. It will simply pick the first available swap
133 device. 161 device.
134 162
135config SUSPEND_SMP
136 bool
137 depends on HOTPLUG_CPU && (X86 || PPC64) && PM
138 default y
139
140config APM_EMULATION 163config APM_EMULATION
141 tristate "Advanced Power Management Emulation" 164 tristate "Advanced Power Management Emulation"
142 depends on PM && SYS_SUPPORTS_APM_EMULATION 165 depends on PM && SYS_SUPPORTS_APM_EMULATION
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index c6b03764512f..f7dfff28ecdb 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -3,8 +3,9 @@ ifeq ($(CONFIG_PM_DEBUG),y)
3EXTRA_CFLAGS += -DDEBUG 3EXTRA_CFLAGS += -DDEBUG
4endif 4endif
5 5
6obj-y := main.o process.o console.o 6obj-y := main.o
7obj-$(CONFIG_PM_LEGACY) += pm.o 7obj-$(CONFIG_PM_LEGACY) += pm.o
8obj-$(CONFIG_PM_SLEEP) += process.o console.o
8obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o 9obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
9 10
10obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o 11obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
diff --git a/kernel/power/main.c b/kernel/power/main.c
index cfba6987ae7d..350b485b3b60 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -25,11 +25,13 @@
25 25
26BLOCKING_NOTIFIER_HEAD(pm_chain_head); 26BLOCKING_NOTIFIER_HEAD(pm_chain_head);
27 27
28/*This is just an arbitrary number */
29#define FREE_PAGE_NUMBER (100)
30
31DEFINE_MUTEX(pm_mutex); 28DEFINE_MUTEX(pm_mutex);
32 29
30#ifdef CONFIG_SUSPEND
31
32/* This is just an arbitrary number */
33#define FREE_PAGE_NUMBER (100)
34
33struct pm_ops *pm_ops; 35struct pm_ops *pm_ops;
34 36
35/** 37/**
@@ -269,6 +271,8 @@ int pm_suspend(suspend_state_t state)
269 271
270EXPORT_SYMBOL(pm_suspend); 272EXPORT_SYMBOL(pm_suspend);
271 273
274#endif /* CONFIG_SUSPEND */
275
272decl_subsys(power,NULL,NULL); 276decl_subsys(power,NULL,NULL);
273 277
274 278
@@ -285,13 +289,15 @@ decl_subsys(power,NULL,NULL);
285 289
286static ssize_t state_show(struct kset *kset, char *buf) 290static ssize_t state_show(struct kset *kset, char *buf)
287{ 291{
292 char *s = buf;
293#ifdef CONFIG_SUSPEND
288 int i; 294 int i;
289 char * s = buf;
290 295
291 for (i = 0; i < PM_SUSPEND_MAX; i++) { 296 for (i = 0; i < PM_SUSPEND_MAX; i++) {
292 if (pm_states[i] && valid_state(i)) 297 if (pm_states[i] && valid_state(i))
293 s += sprintf(s,"%s ", pm_states[i]); 298 s += sprintf(s,"%s ", pm_states[i]);
294 } 299 }
300#endif
295#ifdef CONFIG_HIBERNATION 301#ifdef CONFIG_HIBERNATION
296 s += sprintf(s, "%s\n", "disk"); 302 s += sprintf(s, "%s\n", "disk");
297#else 303#else
@@ -304,11 +310,13 @@ static ssize_t state_show(struct kset *kset, char *buf)
304 310
305static ssize_t state_store(struct kset *kset, const char *buf, size_t n) 311static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
306{ 312{
313#ifdef CONFIG_SUSPEND
307 suspend_state_t state = PM_SUSPEND_STANDBY; 314 suspend_state_t state = PM_SUSPEND_STANDBY;
308 const char * const *s; 315 const char * const *s;
316#endif
309 char *p; 317 char *p;
310 int error;
311 int len; 318 int len;
319 int error = -EINVAL;
312 320
313 p = memchr(buf, '\n', n); 321 p = memchr(buf, '\n', n);
314 len = p ? p - buf : n; 322 len = p ? p - buf : n;
@@ -316,17 +324,19 @@ static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
316 /* First, check if we are requested to hibernate */ 324 /* First, check if we are requested to hibernate */
317 if (len == 4 && !strncmp(buf, "disk", len)) { 325 if (len == 4 && !strncmp(buf, "disk", len)) {
318 error = hibernate(); 326 error = hibernate();
319 return error ? error : n; 327 goto Exit;
320 } 328 }
321 329
330#ifdef CONFIG_SUSPEND
322 for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { 331 for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
323 if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) 332 if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
324 break; 333 break;
325 } 334 }
326 if (state < PM_SUSPEND_MAX && *s) 335 if (state < PM_SUSPEND_MAX && *s)
327 error = enter_state(state); 336 error = enter_state(state);
328 else 337#endif
329 error = -EINVAL; 338
339 Exit:
330 return error ? error : n; 340 return error ? error : n;
331} 341}
332 342
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 9080914796f5..95fbf2dd3fe3 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -176,9 +176,17 @@ struct timeval;
176extern void swsusp_show_speed(struct timeval *, struct timeval *, 176extern void swsusp_show_speed(struct timeval *, struct timeval *,
177 unsigned int, char *); 177 unsigned int, char *);
178 178
179#ifdef CONFIG_SUSPEND
179/* kernel/power/main.c */ 180/* kernel/power/main.c */
180extern int suspend_enter(suspend_state_t state);
181extern int suspend_devices_and_enter(suspend_state_t state); 181extern int suspend_devices_and_enter(suspend_state_t state);
182#else /* !CONFIG_SUSPEND */
183static inline int suspend_devices_and_enter(suspend_state_t state)
184{
185 return -ENOSYS;
186}
187#endif /* !CONFIG_SUSPEND */
188
189/* kernel/power/common.c */
182extern struct blocking_notifier_head pm_chain_head; 190extern struct blocking_notifier_head pm_chain_head;
183 191
184static inline int pm_notifier_call_chain(unsigned long val) 192static inline int pm_notifier_call_chain(unsigned long val)