blob: 74311d7e0f3c9a9d250de17d241953114b335abe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001Power Management Interface
2
3
4The power management subsystem provides a unified sysfs interface to
5userspace, regardless of what architecture or platform one is
6running. The interface exists in /sys/power/ directory (assuming sysfs
7is mounted at /sys).
8
9/sys/power/state controls system power state. Reading from this file
10returns what states are supported, which is hard-coded to 'standby'
11(Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk'
12(Suspend-to-Disk).
13
14Writing to this file one of those strings causes the system to
15transition into that state. Please see the file
16Documentation/power/states.txt for a description of each of those
17states.
18
19
20/sys/power/disk controls the operating mode of the suspend-to-disk
21mechanism. Suspend-to-disk can be handled in several ways. The
22greatest distinction is who writes memory to disk - the firmware or
23the kernel. If the firmware does it, we assume that it also handles
24suspending the system.
25
26If the kernel does it, then we have three options for putting the system
27to sleep - using the platform driver (e.g. ACPI or other PM
28registers), powering off the system or rebooting the system (for
29testing). The system will support either 'firmware' or 'platform', and
30that is known a priori. But, the user may choose 'shutdown' or
31'reboot' as alternatives.
32
Rafael J. Wysockib918f6e2006-11-02 22:07:19 -080033Additionally, /sys/power/disk can be used to turn on one of the two testing
34modes of the suspend-to-disk mechanism: 'testproc' or 'test'. If the
35suspend-to-disk mechanism is in the 'testproc' mode, writing 'disk' to
36/sys/power/state will cause the kernel to disable nonboot CPUs and freeze
37tasks, wait for 5 seconds, unfreeze tasks and enable nonboot CPUs. If it is
38in the 'test' mode, writing 'disk' to /sys/power/state will cause the kernel
39to disable nonboot CPUs and freeze tasks, shrink memory, suspend devices, wait
40for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then,
41we are able to look in the log messages and work out, for example, which code
42is being slow and which device drivers are misbehaving.
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044Reading from this file will display what the mode is currently set
45to. Writing to this file will accept one of
46
47 'firmware'
48 'platform'
49 'shutdown'
50 'reboot'
Rafael J. Wysockib918f6e2006-11-02 22:07:19 -080051 'testproc'
52 'test'
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54It will only change to 'firmware' or 'platform' if the system supports
55it.
56
Rafael J. Wysockica0aec02006-01-06 00:15:56 -080057/sys/power/image_size controls the size of the image created by
58the suspend-to-disk mechanism. It can be written a string
59representing a non-negative integer that will be used as an upper
Rafael J. Wysocki853609b2006-02-01 03:05:07 -080060limit of the image size, in bytes. The suspend-to-disk mechanism will
Rafael J. Wysockica0aec02006-01-06 00:15:56 -080061do its best to ensure the image size will not exceed that number. However,
62if this turns out to be impossible, it will try to suspend anyway using the
63smallest image possible. In particular, if "0" is written to this file, the
64suspend image will be as small as possible.
65
66Reading from this file will display the current image size limit, which
67is set to 500 MB by default.
Rafael J. Wysockic5c6ba42006-09-25 23:32:58 -070068
69/sys/power/pm_trace controls the code which saves the last PM event point in
70the RTC across reboots, so that you can debug a machine that just hangs
71during suspend (or more commonly, during resume). Namely, the RTC is only
72used to save the last PM event point if this file contains '1'. Initially it
73contains '0' which may be changed to '1' by writing a string representing a
74nonzero integer into it.
75
76To use this debugging feature you should attempt to suspend the machine, then
77reboot it and run
78
79 dmesg -s 1000000 | grep 'hash matches'
80
81CAUTION: Using it will cause your machine's real-time (CMOS) clock to be
82set to a random invalid time after a resume.