Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.11 125 lines 6.2 kB view raw
1System Power Management Sleep States 2 3(C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> 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. 8 9The 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 11"disk", where the last three always represent Power-On Suspend (if supported), 12Suspend-To-Idle and hibernation (Suspend-To-Disk), respectively. 13 14The 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. 24 25Consequently, 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 write "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). 34 35The 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" 38parameter in the kernel command line. 39 40The properties of all of the sleep states are described below. 41 42 43State: Suspend-To-Idle 44ACPI state: S0 45Label: "s2idle" ("freeze") 46 47This state is a generic, pure software, light-weight, system sleep state. 48It allows more energy to be saved relative to runtime idle by freezing user 49space and putting all I/O devices into low-power states (possibly 50lower-power than available at run time), such that the processors can 51spend more time in their idle states. 52 53This state can be used for platforms without Power-On Suspend/Suspend-to-RAM 54support, or it can be used in addition to Suspend-to-RAM to provide reduced 55resume latency. It is always supported. 56 57 58State: Standby / Power-On Suspend 59ACPI State: S1 60Label: "shallow" ("standby") 61 62This state, if supported, offers moderate, though real, power savings, while 63providing a relatively low-latency transition back to a working system. No 64operating state is lost (the CPU retains power), so the system easily starts up 65again where it left off. 66 67In addition to freezing user space and putting all I/O devices into low-power 68states, which is done for Suspend-To-Idle too, nonboot CPUs are taken offline 69and all low-level system functions are suspended during transitions into this 70state. For this reason, it should allow more energy to be saved relative to 71Suspend-To-Idle, but the resume latency will generally be greater than for that 72state. 73 74 75State: Suspend-to-RAM 76ACPI State: S3 77Label: "deep" 78 79This state, if supported, offers significant power savings as everything in the 80system is put into a low-power state, except for memory, which should be placed 81into the self-refresh mode to retain its contents. All of the steps carried out 82when entering Power-On Suspend are also carried out during transitions to STR. 83Additional operations may take place depending on the platform capabilities. In 84particular, on ACPI systems the kernel passes control to the BIOS (platform 85firmware) as the last step during STR transitions and that usually results in 86powering down some more low-level components that aren't directly controlled by 87the kernel. 88 89System and device state is saved and kept in memory. All devices are suspended 90and put into low-power states. In many cases, all peripheral buses lose power 91when entering STR, so devices must be able to handle the transition back to the 92"on" state. 93 94For at least ACPI, STR requires some minimal boot-strapping code to resume the 95system from it. This may be the case on other platforms too. 96 97 98State: Suspend-to-disk 99ACPI State: S4 100Label: "disk" 101 102This state offers the greatest power savings, and can be used even in 103the absence of low-level platform support for power management. This 104state operates similarly to Suspend-to-RAM, but includes a final step 105of writing memory contents to disk. On resume, this is read and memory 106is restored to its pre-suspend state. 107 108STD can be handled by the firmware or the kernel. If it is handled by 109the firmware, it usually requires a dedicated partition that must be 110setup via another operating system for it to use. Despite the 111inconvenience, this method requires minimal work by the kernel, since 112the firmware will also handle restoring memory contents on resume. 113 114For suspend-to-disk, a mechanism called 'swsusp' (Swap Suspend) is used 115to write memory contents to free swap space. swsusp has some restrictive 116requirements, but should work in most cases. Some, albeit outdated, 117documentation can be found in Documentation/power/swsusp.txt. 118Alternatively, userspace can do most of the actual suspend to disk work, 119see userland-swsusp.txt. 120 121Once memory state is written to disk, the system may either enter a 122low-power state (like ACPI S4), or it may simply power down. Powering 123down offers greater savings, and allows this mechanism to work on any 124system. However, entering a real low-power state allows the user to 125trigger wake up events (e.g. pressing a key or opening a laptop lid).