blob: 8a39ce45d8a01c298ec3b62b878e2623cba5a958 [file] [log] [blame]
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +02001System Power Management Sleep States
Linus Torvalds1da177e2005-04-16 15:20:36 -07002
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +02003(C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +02005The 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +02009The 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
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010011"disk", where the last three always represent Power-On Suspend (if supported),
12Suspend-To-Idle and hibernation (Suspend-To-Disk), respectively.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010014The meaning of the "mem" string is controlled by the /sys/power/mem_sleep file.
15It contains strings representing the available modes of system suspend that may
16be 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).
18The "s2idle" mode is always available, while the other ones are only available
19if supported by the platform (if not supported, the strings representing them
20are not present in /sys/power/mem_sleep). The string representing the suspend
21mode to be used subsequently is enclosed in square brackets. Writing one of
22the other strings present in /sys/power/mem_sleep to it causes the suspend mode
23to be used subsequently to change to the one represented by that string.
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020024
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010025Consequently, there are two ways to cause the system to go into the
26Suspend-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
28and then to wrtie "mem" to /sys/power/state. Similarly, there are two ways
29to cause the system to go into the Power-On Suspend sleep state (the strings to
30write to the control files in that case are "standby" or "shallow" and "mem",
31respectively) if that state is supported by the platform. In turn, there is
32only 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).
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020034
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010035The 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"
Rafael J. Wysocki08b98d32016-11-17 03:28:53 +010038parameter in the kernel command line. On some ACPI-based systems, depending on
39the information in the FADT, the default may be "s2idle" even if Suspend-To-RAM
40is supported.
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010041
42The properties of all of the sleep states are described below.
43
44
45State: Suspend-To-Idle
Zhang Ruidc5aeae2013-05-13 02:42:11 +000046ACPI state: S0
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010047Label: "s2idle" ("freeze")
Zhang Ruidc5aeae2013-05-13 02:42:11 +000048
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020049This state is a generic, pure software, light-weight, system sleep state.
50It allows more energy to be saved relative to runtime idle by freezing user
Zhang Ruidc5aeae2013-05-13 02:42:11 +000051space and putting all I/O devices into low-power states (possibly
52lower-power than available at run time), such that the processors can
53spend more time in their idle states.
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020054
55This state can be used for platforms without Power-On Suspend/Suspend-to-RAM
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010056support, or it can be used in addition to Suspend-to-RAM to provide reduced
57resume latency. It is always supported.
Zhang Ruidc5aeae2013-05-13 02:42:11 +000058
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60State: Standby / Power-On Suspend
61ACPI State: S1
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010062Label: "shallow" ("standby")
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020064This state, if supported, offers moderate, though real, power savings, while
65providing a relatively low-latency transition back to a working system. No
66operating state is lost (the CPU retains power), so the system easily starts up
Linus Torvalds1da177e2005-04-16 15:20:36 -070067again where it left off.
68
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020069In addition to freezing user space and putting all I/O devices into low-power
70states, which is done for Suspend-To-Idle too, nonboot CPUs are taken offline
71and all low-level system functions are suspended during transitions into this
72state. For this reason, it should allow more energy to be saved relative to
73Suspend-To-Idle, but the resume latency will generally be greater than for that
74state.
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77State: Suspend-to-RAM
78ACPI State: S3
Rafael J. Wysocki406e7932016-11-21 22:45:40 +010079Label: "deep"
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020081This state, if supported, offers significant power savings as everything in the
82system is put into a low-power state, except for memory, which should be placed
83into the self-refresh mode to retain its contents. All of the steps carried out
84when entering Power-On Suspend are also carried out during transitions to STR.
85Additional operations may take place depending on the platform capabilities. In
86particular, on ACPI systems the kernel passes control to the BIOS (platform
87firmware) as the last step during STR transitions and that usually results in
88powering down some more low-level components that aren't directly controlled by
89the kernel.
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020091System and device state is saved and kept in memory. All devices are suspended
92and put into low-power states. In many cases, all peripheral buses lose power
93when entering STR, so devices must be able to handle the transition back to the
94"on" state.
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +020096For at least ACPI, STR requires some minimal boot-strapping code to resume the
97system from it. This may be the case on other platforms too.
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100State: Suspend-to-disk
101ACPI State: S4
Rafael J. Wysocki0399d4d2014-05-26 13:40:59 +0200102Label: "disk"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104This state offers the greatest power savings, and can be used even in
105the absence of low-level platform support for power management. This
106state operates similarly to Suspend-to-RAM, but includes a final step
107of writing memory contents to disk. On resume, this is read and memory
108is restored to its pre-suspend state.
109
110STD can be handled by the firmware or the kernel. If it is handled by
111the firmware, it usually requires a dedicated partition that must be
112setup via another operating system for it to use. Despite the
113inconvenience, this method requires minimal work by the kernel, since
114the firmware will also handle restoring memory contents on resume.
115
Alexandre Courbota8b72282011-02-24 20:48:56 +0100116For suspend-to-disk, a mechanism called 'swsusp' (Swap Suspend) is used
117to write memory contents to free swap space. swsusp has some restrictive
118requirements, but should work in most cases. Some, albeit outdated,
119documentation can be found in Documentation/power/swsusp.txt.
120Alternatively, userspace can do most of the actual suspend to disk work,
121see userland-swsusp.txt.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123Once memory state is written to disk, the system may either enter a
124low-power state (like ACPI S4), or it may simply power down. Powering
125down offers greater savings, and allows this mechanism to work on any
126system. However, entering a real low-power state allows the user to
Johannes Berg11d77d02007-04-30 15:09:53 -0700127trigger wake up events (e.g. pressing a key or opening a laptop lid).