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