Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 1 | Power Management Interface for System Sleep |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 3 | Copyright (c) 2016 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 | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 5 | The power management subsystem provides userspace with a unified sysfs interface |
| 6 | for system sleep regardless of the underlying system architecture or platform. |
| 7 | The interface is located in the /sys/power/ directory (assuming that sysfs is |
| 8 | mounted at /sys). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 10 | /sys/power/state is the system sleep state control file. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 12 | Reading from it returns a list of supported sleep states, encoded as: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 14 | 'freeze' (Suspend-to-Idle) |
| 15 | 'standby' (Power-On Suspend) |
| 16 | 'mem' (Suspend-to-RAM) |
| 17 | 'disk' (Suspend-to-Disk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 19 | Suspend-to-Idle is always supported. Suspend-to-Disk is always supported |
| 20 | too as long the kernel has been configured to support hibernation at all |
| 21 | (ie. CONFIG_HIBERNATION is set in the kernel configuration file). Support |
| 22 | for Suspend-to-RAM and Power-On Suspend depends on the capabilities of the |
| 23 | platform. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 25 | If one of the strings listed in /sys/power/state is written to it, the system |
| 26 | will attempt to transition into the corresponding sleep state. Refer to |
Tom Saeger | 3ba9b1b | 2017-10-10 12:36:16 -0500 | [diff] [blame] | 27 | Documentation/admin-guide/pm/sleep-states.rst for a description of each of |
| 28 | those states. |
Rafael J. Wysocki | b918f6e | 2006-11-02 22:07:19 -0800 | [diff] [blame] | 29 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 30 | /sys/power/disk controls the operating mode of hibernation (Suspend-to-Disk). |
| 31 | Specifically, it tells the kernel what to do after creating a hibernation image. |
Johannes Berg | f0ced9b | 2007-05-06 14:50:50 -0700 | [diff] [blame] | 32 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 33 | Reading from it returns a list of supported options encoded as: |
Johannes Berg | f0ced9b | 2007-05-06 14:50:50 -0700 | [diff] [blame] | 34 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 35 | 'platform' (put the system into sleep using a platform-provided method) |
| 36 | 'shutdown' (shut the system down) |
| 37 | 'reboot' (reboot the system) |
| 38 | 'suspend' (trigger a Suspend-to-RAM transition) |
| 39 | 'test_resume' (resume-after-hibernation test mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 41 | The currently selected option is printed in square brackets. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 43 | The 'platform' option is only available if the platform provides a special |
| 44 | mechanism to put the system to sleep after creating a hibernation image (ACPI |
| 45 | does that, for example). The 'suspend' option is available if Suspend-to-RAM |
Tom Saeger | 4493c1f | 2017-10-12 15:24:05 -0500 | [diff] [blame] | 46 | is supported. Refer to Documentation/power/basic-pm-debugging.txt for the |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 47 | description of the 'test_resume' option. |
Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 48 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 49 | To select an option, write the string representing it to /sys/power/disk. |
Rafael J. Wysocki | c5c6ba4 | 2006-09-25 23:32:58 -0700 | [diff] [blame] | 50 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 51 | /sys/power/image_size controls the size of hibernation images. |
Rafael J. Wysocki | c5c6ba4 | 2006-09-25 23:32:58 -0700 | [diff] [blame] | 52 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 53 | It can be written a string representing a non-negative integer that will be |
| 54 | used as a best-effort upper limit of the image size, in bytes. The hibernation |
| 55 | core will do its best to ensure that the image size will not exceed that number. |
| 56 | However, if that turns out to be impossible to achieve, a hibernation image will |
| 57 | still be created and its size will be as small as possible. In particular, |
| 58 | writing '0' to this file will enforce hibernation images to be as small as |
| 59 | possible. |
Rafael J. Wysocki | c5c6ba4 | 2006-09-25 23:32:58 -0700 | [diff] [blame] | 60 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 61 | Reading from this file returns the current image size limit, which is set to |
| 62 | around 2/5 of available RAM by default. |
Rafael J. Wysocki | c5c6ba4 | 2006-09-25 23:32:58 -0700 | [diff] [blame] | 63 | |
Rafael J. Wysocki | 947d2c2 | 2016-08-13 02:54:04 +0200 | [diff] [blame] | 64 | /sys/power/pm_trace controls the PM trace mechanism saving the last suspend |
| 65 | or resume event point in the RTC across reboots. |
| 66 | |
| 67 | It helps to debug hard lockups or reboots due to device driver failures that |
| 68 | occur during system suspend or resume (which is more common) more effectively. |
| 69 | |
| 70 | If /sys/power/pm_trace contains '1', the fingerprint of each suspend/resume |
| 71 | event point in turn will be stored in the RTC memory (overwriting the actual |
| 72 | RTC information), so it will survive a system crash if one occurs right after |
| 73 | storing it and it can be used later to identify the driver that caused the crash |
| 74 | to happen (see Documentation/power/s2ram.txt for more information). |
| 75 | |
| 76 | Initially it contains '0' which may be changed to '1' by writing a string |
| 77 | representing a nonzero integer into it. |