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