aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-power29
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--Documentation/power/states.txt87
-rw-r--r--kernel/power/main.c12
-rw-r--r--kernel/power/suspend.c32
5 files changed, 119 insertions, 48 deletions
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
index 64c9276e9421..f4551816329e 100644
--- a/Documentation/ABI/testing/sysfs-power
+++ b/Documentation/ABI/testing/sysfs-power
@@ -7,19 +7,30 @@ Description:
7 subsystem. 7 subsystem.
8 8
9What: /sys/power/state 9What: /sys/power/state
10Date: August 2006 10Date: May 2014
11Contact: Rafael J. Wysocki <rjw@rjwysocki.net> 11Contact: Rafael J. Wysocki <rjw@rjwysocki.net>
12Description: 12Description:
13 The /sys/power/state file controls the system power state. 13 The /sys/power/state file controls system sleep states.
14 Reading from this file returns what states are supported, 14 Reading from this file returns the available sleep state
15 which is hard-coded to 'freeze' (Low-Power Idle), 'standby' 15 labels, which may be "mem", "standby", "freeze" and "disk"
16 (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk' 16 (hibernation). The meanings of the first three labels depend on
17 (Suspend-to-Disk). 17 the relative_sleep_states command line argument as follows:
18 1) relative_sleep_states = 1
19 "mem", "standby", "freeze" represent non-hibernation sleep
20 states from the deepest ("mem", always present) to the
21 shallowest ("freeze"). "standby" and "freeze" may or may
22 not be present depending on the capabilities of the
23 platform. "freeze" can only be present if "standby" is
24 present.
25 2) relative_sleep_states = 0 (default)
26 "mem" - "suspend-to-RAM", present if supported.
27 "standby" - "power-on suspend", present if supported.
28 "freeze" - "suspend-to-idle", always present.
18 29
19 Writing to this file one of these strings causes the system to 30 Writing to this file one of these strings causes the system to
20 transition into that state. Please see the file 31 transition into the corresponding state, if available. See
21 Documentation/power/states.txt for a description of each of 32 Documentation/power/states.txt for a description of what
22 these states. 33 "suspend-to-RAM", "power-on suspend" and "suspend-to-idle" mean.
23 34
24What: /sys/power/disk 35What: /sys/power/disk
25Date: September 2006 36Date: September 2006
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 43842177b771..e19a88b63eeb 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2889,6 +2889,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2889 [KNL, SMP] Set scheduler's default relax_domain_level. 2889 [KNL, SMP] Set scheduler's default relax_domain_level.
2890 See Documentation/cgroups/cpusets.txt. 2890 See Documentation/cgroups/cpusets.txt.
2891 2891
2892 relative_sleep_states=
2893 [SUSPEND] Use sleep state labeling where the deepest
2894 state available other than hibernation is always "mem".
2895 Format: { "0" | "1" }
2896 0 -- Traditional sleep state labels.
2897 1 -- Relative sleep state labels.
2898
2892 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area 2899 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area
2893 2900
2894 reservetop= [X86-32] 2901 reservetop= [X86-32]
diff --git a/Documentation/power/states.txt b/Documentation/power/states.txt
index 442d43df9b25..50f3ef9177c1 100644
--- a/Documentation/power/states.txt
+++ b/Documentation/power/states.txt
@@ -1,62 +1,87 @@
1System Power Management Sleep States
1 2
2System Power Management States 3(C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
3 4
5The kernel supports up to four system sleep states generically, although three
6of them depend on the platform support code to implement the low-level details
7for each state.
4 8
5The kernel supports four power management states generically, though 9The states are represented by strings that can be read or written to the
6one is generic and the other three are dependent on platform support 10/sys/power/state file. Those strings may be "mem", "standby", "freeze" and
7code to implement the low-level details for each state. 11"disk", where the last one always represents hibernation (Suspend-To-Disk) and
8This file describes each state, what they are 12the meaning of the remaining ones depends on the relative_sleep_states command
9commonly called, what ACPI state they map to, and what string to write 13line argument.
10to /sys/power/state to enter that state
11 14
12state: Freeze / Low-Power Idle 15For relative_sleep_states=1, the strings "mem", "standby" and "freeze" label the
16available non-hibernation sleep states from the deepest to the shallowest,
17respectively. In that case, "mem" is always present in /sys/power/state,
18because there is at least one non-hibernation sleep state in every system. If
19the given system supports two non-hibernation sleep states, "standby" is present
20in /sys/power/state in addition to "mem". If the system supports three
21non-hibernation sleep states, "freeze" will be present in /sys/power/state in
22addition to "mem" and "standby".
23
24For relative_sleep_states=0, which is the default, the following descriptions
25apply.
26
27state: Suspend-To-Idle
13ACPI state: S0 28ACPI state: S0
14String: "freeze" 29Label: "freeze"
15 30
16This state is a generic, pure software, light-weight, low-power state. 31This state is a generic, pure software, light-weight, system sleep state.
17It allows more energy to be saved relative to idle by freezing user 32It allows more energy to be saved relative to runtime idle by freezing user
18space and putting all I/O devices into low-power states (possibly 33space and putting all I/O devices into low-power states (possibly
19lower-power than available at run time), such that the processors can 34lower-power than available at run time), such that the processors can
20spend more time in their idle states. 35spend more time in their idle states.
21This state can be used for platforms without Standby/Suspend-to-RAM 36
37This state can be used for platforms without Power-On Suspend/Suspend-to-RAM
22support, or it can be used in addition to Suspend-to-RAM (memory sleep) 38support, or it can be used in addition to Suspend-to-RAM (memory sleep)
23to provide reduced resume latency. 39to provide reduced resume latency. It is always supported.
24 40
25 41
26State: Standby / Power-On Suspend 42State: Standby / Power-On Suspend
27ACPI State: S1 43ACPI State: S1
28String: "standby" 44Label: "standby"
29 45
30This state offers minimal, though real, power savings, while providing 46This state, if supported, offers moderate, though real, power savings, while
31a very low-latency transition back to a working system. No operating 47providing a relatively low-latency transition back to a working system. No
32state is lost (the CPU retains power), so the system easily starts up 48operating state is lost (the CPU retains power), so the system easily starts up
33again where it left off. 49again where it left off.
34 50
35We try to put devices in a low-power state equivalent to D1, which 51In addition to freezing user space and putting all I/O devices into low-power
36also offers low power savings, but low resume latency. Not all devices 52states, which is done for Suspend-To-Idle too, nonboot CPUs are taken offline
37support D1, and those that don't are left on. 53and all low-level system functions are suspended during transitions into this
54state. For this reason, it should allow more energy to be saved relative to
55Suspend-To-Idle, but the resume latency will generally be greater than for that
56state.
38 57
39 58
40State: Suspend-to-RAM 59State: Suspend-to-RAM
41ACPI State: S3 60ACPI State: S3
42String: "mem" 61Label: "mem"
43 62
44This state offers significant power savings as everything in the 63This state, if supported, offers significant power savings as everything in the
45system is put into a low-power state, except for memory, which is 64system is put into a low-power state, except for memory, which should be placed
46placed in self-refresh mode to retain its contents. 65into the self-refresh mode to retain its contents. All of the steps carried out
66when entering Power-On Suspend are also carried out during transitions to STR.
67Additional operations may take place depending on the platform capabilities. In
68particular, on ACPI systems the kernel passes control to the BIOS (platform
69firmware) as the last step during STR transitions and that usually results in
70powering down some more low-level components that aren't directly controlled by
71the kernel.
47 72
48System and device state is saved and kept in memory. All devices are 73System and device state is saved and kept in memory. All devices are suspended
49suspended and put into D3. In many cases, all peripheral buses lose 74and put into low-power states. In many cases, all peripheral buses lose power
50power when entering STR, so devices must be able to handle the 75when entering STR, so devices must be able to handle the transition back to the
51transition back to the On state. 76"on" state.
52 77
53For at least ACPI, STR requires some minimal boot-strapping code to 78For at least ACPI, STR requires some minimal boot-strapping code to resume the
54resume the system from STR. This may be true on other platforms. 79system from it. This may be the case on other platforms too.
55 80
56 81
57State: Suspend-to-disk 82State: Suspend-to-disk
58ACPI State: S4 83ACPI State: S4
59String: "disk" 84Label: "disk"
60 85
61This state offers the greatest power savings, and can be used even in 86This state offers the greatest power savings, and can be used even in
62the absence of low-level platform support for power management. This 87the absence of low-level platform support for power management. This
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 9f51f0ab3d86..573410d6647e 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -279,14 +279,14 @@ static inline void pm_print_times_init(void) {}
279struct kobject *power_kobj; 279struct kobject *power_kobj;
280 280
281/** 281/**
282 * state - control system power state. 282 * state - control system sleep states.
283 * 283 *
284 * show() returns what states are supported, which is hard-coded to 284 * show() returns available sleep state labels, which may be "mem", "standby",
285 * 'freeze' (Low-Power Idle), 'standby' (Power-On Suspend), 285 * "freeze" and "disk" (hibernation). See Documentation/power/states.txt for a
286 * 'mem' (Suspend-to-RAM), and 'disk' (Suspend-to-Disk). 286 * description of what they mean.
287 * 287 *
288 * store() accepts one of those strings, translates it into the 288 * store() accepts one of those strings, translates it into the proper
289 * proper enumerated value, and initiates a suspend transition. 289 * enumerated value, and initiates a suspend transition.
290 */ 290 */
291static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, 291static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
292 char *buf) 292 char *buf)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 00aca60904b0..338a6f147974 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -78,6 +78,26 @@ static bool valid_state(suspend_state_t state)
78 return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); 78 return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
79} 79}
80 80
81/*
82 * If this is set, the "mem" label always corresponds to the deepest sleep state
83 * available, the "standby" label corresponds to the second deepest sleep state
84 * available (if any), and the "freeze" label corresponds to the remaining
85 * available sleep state (if there is one).
86 */
87static bool relative_states;
88
89static int __init sleep_states_setup(char *str)
90{
91 relative_states = !strncmp(str, "1", 1);
92 if (relative_states) {
93 pm_states[PM_SUSPEND_MEM].state = PM_SUSPEND_FREEZE;
94 pm_states[PM_SUSPEND_FREEZE].state = 0;
95 }
96 return 1;
97}
98
99__setup("relative_sleep_states=", sleep_states_setup);
100
81/** 101/**
82 * suspend_set_ops - Set the global suspend method table. 102 * suspend_set_ops - Set the global suspend method table.
83 * @ops: Suspend operations to use. 103 * @ops: Suspend operations to use.
@@ -85,12 +105,20 @@ static bool valid_state(suspend_state_t state)
85void suspend_set_ops(const struct platform_suspend_ops *ops) 105void suspend_set_ops(const struct platform_suspend_ops *ops)
86{ 106{
87 suspend_state_t i; 107 suspend_state_t i;
108 int j = PM_SUSPEND_MAX - 1;
88 109
89 lock_system_sleep(); 110 lock_system_sleep();
90 111
91 suspend_ops = ops; 112 suspend_ops = ops;
92 for (i = PM_SUSPEND_STANDBY; i <= PM_SUSPEND_MEM; i++) 113 for (i = PM_SUSPEND_MEM; i >= PM_SUSPEND_STANDBY; i--)
93 pm_states[i].state = valid_state(i) ? i : 0; 114 if (valid_state(i))
115 pm_states[j--].state = i;
116 else if (!relative_states)
117 pm_states[j--].state = 0;
118
119 pm_states[j--].state = PM_SUSPEND_FREEZE;
120 while (j >= PM_SUSPEND_MIN)
121 pm_states[j--].state = 0;
94 122
95 unlock_system_sleep(); 123 unlock_system_sleep();
96} 124}