Commit | Line | Data |
---|---|---|
0399d4db | 1 | System Power Management Sleep States |
1da177e4 | 2 | |
0399d4db | 3 | (C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
1da177e4 | 4 | |
0399d4db RW |
5 | The kernel supports up to four system sleep states generically, although three |
6 | of them depend on the platform support code to implement the low-level details | |
7 | for each state. | |
1da177e4 | 8 | |
0399d4db RW |
9 | The states are represented by strings that can be read or written to the |
10 | /sys/power/state file. Those strings may be "mem", "standby", "freeze" and | |
406e7938 RW |
11 | "disk", where the last three always represent Power-On Suspend (if supported), |
12 | Suspend-To-Idle and hibernation (Suspend-To-Disk), respectively. | |
13 | ||
14 | The meaning of the "mem" string is controlled by the /sys/power/mem_sleep file. | |
15 | It contains strings representing the available modes of system suspend that may | |
16 | be triggered by writing "mem" to /sys/power/state. These modes are "s2idle" | |
17 | (Suspend-To-Idle), "shallow" (Power-On Suspend) and "deep" (Suspend-To-RAM). | |
18 | The "s2idle" mode is always available, while the other ones are only available | |
19 | if supported by the platform (if not supported, the strings representing them | |
20 | are not present in /sys/power/mem_sleep). The string representing the suspend | |
21 | mode to be used subsequently is enclosed in square brackets. Writing one of | |
22 | the other strings present in /sys/power/mem_sleep to it causes the suspend mode | |
23 | to be used subsequently to change to the one represented by that string. | |
24 | ||
25 | Consequently, there are two ways to cause the system to go into the | |
26 | Suspend-To-Idle sleep state. The first one is to write "freeze" directly to | |
27 | /sys/power/state. The second one is to write "s2idle" to /sys/power/mem_sleep | |
28 | and then to wrtie "mem" to /sys/power/state. Similarly, there are two ways | |
29 | to cause the system to go into the Power-On Suspend sleep state (the strings to | |
30 | write to the control files in that case are "standby" or "shallow" and "mem", | |
31 | respectively) if that state is supported by the platform. In turn, there is | |
32 | only one way to cause the system to go into the Suspend-To-RAM state (write | |
33 | "deep" into /sys/power/mem_sleep and "mem" into /sys/power/state). | |
34 | ||
35 | The default suspend mode (ie. the one to be used without writing anything into | |
36 | /sys/power/mem_sleep) is either "deep" (if Suspend-To-RAM is supported) or | |
37 | "s2idle", but it can be overridden by the value of the "mem_sleep_default" | |
08b98d32 RW |
38 | parameter in the kernel command line. On some ACPI-based systems, depending on |
39 | the information in the FADT, the default may be "s2idle" even if Suspend-To-RAM | |
40 | is supported. | |
406e7938 RW |
41 | |
42 | The properties of all of the sleep states are described below. | |
43 | ||
44 | ||
45 | State: Suspend-To-Idle | |
dc5aeae4 | 46 | ACPI state: S0 |
406e7938 | 47 | Label: "s2idle" ("freeze") |
dc5aeae4 | 48 | |
0399d4db RW |
49 | This state is a generic, pure software, light-weight, system sleep state. |
50 | It allows more energy to be saved relative to runtime idle by freezing user | |
dc5aeae4 ZR |
51 | space and putting all I/O devices into low-power states (possibly |
52 | lower-power than available at run time), such that the processors can | |
53 | spend more time in their idle states. | |
0399d4db RW |
54 | |
55 | This state can be used for platforms without Power-On Suspend/Suspend-to-RAM | |
406e7938 RW |
56 | support, or it can be used in addition to Suspend-to-RAM to provide reduced |
57 | resume latency. It is always supported. | |
dc5aeae4 | 58 | |
1da177e4 LT |
59 | |
60 | State: Standby / Power-On Suspend | |
61 | ACPI State: S1 | |
406e7938 | 62 | Label: "shallow" ("standby") |
1da177e4 | 63 | |
0399d4db RW |
64 | This state, if supported, offers moderate, though real, power savings, while |
65 | providing a relatively low-latency transition back to a working system. No | |
66 | operating state is lost (the CPU retains power), so the system easily starts up | |
1da177e4 LT |
67 | again where it left off. |
68 | ||
0399d4db RW |
69 | In addition to freezing user space and putting all I/O devices into low-power |
70 | states, which is done for Suspend-To-Idle too, nonboot CPUs are taken offline | |
71 | and all low-level system functions are suspended during transitions into this | |
72 | state. For this reason, it should allow more energy to be saved relative to | |
73 | Suspend-To-Idle, but the resume latency will generally be greater than for that | |
74 | state. | |
1da177e4 | 75 | |
1da177e4 LT |
76 | |
77 | State: Suspend-to-RAM | |
78 | ACPI State: S3 | |
406e7938 | 79 | Label: "deep" |
1da177e4 | 80 | |
0399d4db RW |
81 | This state, if supported, offers significant power savings as everything in the |
82 | system is put into a low-power state, except for memory, which should be placed | |
83 | into the self-refresh mode to retain its contents. All of the steps carried out | |
84 | when entering Power-On Suspend are also carried out during transitions to STR. | |
85 | Additional operations may take place depending on the platform capabilities. In | |
86 | particular, on ACPI systems the kernel passes control to the BIOS (platform | |
87 | firmware) as the last step during STR transitions and that usually results in | |
88 | powering down some more low-level components that aren't directly controlled by | |
89 | the kernel. | |
1da177e4 | 90 | |
0399d4db RW |
91 | System and device state is saved and kept in memory. All devices are suspended |
92 | and put into low-power states. In many cases, all peripheral buses lose power | |
93 | when entering STR, so devices must be able to handle the transition back to the | |
94 | "on" state. | |
1da177e4 | 95 | |
0399d4db RW |
96 | For at least ACPI, STR requires some minimal boot-strapping code to resume the |
97 | system from it. This may be the case on other platforms too. | |
1da177e4 | 98 | |
1da177e4 LT |
99 | |
100 | State: Suspend-to-disk | |
101 | ACPI State: S4 | |
0399d4db | 102 | Label: "disk" |
1da177e4 LT |
103 | |
104 | This state offers the greatest power savings, and can be used even in | |
105 | the absence of low-level platform support for power management. This | |
106 | state operates similarly to Suspend-to-RAM, but includes a final step | |
107 | of writing memory contents to disk. On resume, this is read and memory | |
108 | is restored to its pre-suspend state. | |
109 | ||
110 | STD can be handled by the firmware or the kernel. If it is handled by | |
111 | the firmware, it usually requires a dedicated partition that must be | |
112 | setup via another operating system for it to use. Despite the | |
113 | inconvenience, this method requires minimal work by the kernel, since | |
114 | the firmware will also handle restoring memory contents on resume. | |
115 | ||
a8b7228c AC |
116 | For suspend-to-disk, a mechanism called 'swsusp' (Swap Suspend) is used |
117 | to write memory contents to free swap space. swsusp has some restrictive | |
118 | requirements, but should work in most cases. Some, albeit outdated, | |
119 | documentation can be found in Documentation/power/swsusp.txt. | |
120 | Alternatively, userspace can do most of the actual suspend to disk work, | |
121 | see userland-swsusp.txt. | |
1da177e4 LT |
122 | |
123 | Once memory state is written to disk, the system may either enter a | |
124 | low-power state (like ACPI S4), or it may simply power down. Powering | |
125 | down offers greater savings, and allows this mechanism to work on any | |
126 | system. However, entering a real low-power state allows the user to | |
11d77d0c | 127 | trigger wake up events (e.g. pressing a key or opening a laptop lid). |