| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | Power Management Interface | 
|  | 2 |  | 
|  | 3 |  | 
|  | 4 | The power management subsystem provides a unified sysfs interface to | 
|  | 5 | userspace, regardless of what architecture or platform one is | 
|  | 6 | running. The interface exists in /sys/power/ directory (assuming sysfs | 
|  | 7 | is mounted at /sys). | 
|  | 8 |  | 
|  | 9 | /sys/power/state controls system power state. Reading from this file | 
|  | 10 | returns 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 |  | 
|  | 14 | Writing to this file one of those strings causes the system to | 
|  | 15 | transition into that state. Please see the file | 
|  | 16 | Documentation/power/states.txt for a description of each of those | 
|  | 17 | states. | 
|  | 18 |  | 
|  | 19 |  | 
|  | 20 | /sys/power/disk controls the operating mode of the suspend-to-disk | 
| Johannes Berg | 11d77d0 | 2007-04-30 15:09:53 -0700 | [diff] [blame] | 21 | mechanism. Suspend-to-disk can be handled in several ways. We have a | 
|  | 22 | few options for putting the system to sleep - using the platform driver | 
|  | 23 | (e.g. ACPI or other pm_ops), powering off the system or rebooting the | 
|  | 24 | system (for testing). | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 |  | 
| Rafael J. Wysocki | b918f6e | 2006-11-02 22:07:19 -0800 | [diff] [blame] | 26 | Additionally, /sys/power/disk can be used to turn on one of the two testing | 
|  | 27 | modes of the suspend-to-disk mechanism: 'testproc' or 'test'.  If the | 
|  | 28 | suspend-to-disk mechanism is in the 'testproc' mode, writing 'disk' to | 
|  | 29 | /sys/power/state will cause the kernel to disable nonboot CPUs and freeze | 
|  | 30 | tasks, wait for 5 seconds, unfreeze tasks and enable nonboot CPUs.  If it is | 
|  | 31 | in the 'test' mode, writing 'disk' to /sys/power/state will cause the kernel | 
|  | 32 | to disable nonboot CPUs and freeze tasks, shrink memory, suspend devices, wait | 
|  | 33 | for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs.  Then, | 
|  | 34 | we are able to look in the log messages and work out, for example, which code | 
|  | 35 | is being slow and which device drivers are misbehaving. | 
|  | 36 |  | 
| Johannes Berg | f0ced9b | 2007-05-06 14:50:50 -0700 | [diff] [blame] | 37 | Reading from this file will display all supported modes and the currently | 
|  | 38 | selected one in brackets, for example | 
|  | 39 |  | 
|  | 40 | [shutdown] reboot test testproc | 
|  | 41 |  | 
|  | 42 | Writing to this file will accept one of | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 |  | 
| Johannes Berg | 11d77d0 | 2007-04-30 15:09:53 -0700 | [diff] [blame] | 44 | 'platform' (only if the platform supports it) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | 'shutdown' | 
|  | 46 | 'reboot' | 
| Rafael J. Wysocki | b918f6e | 2006-11-02 22:07:19 -0800 | [diff] [blame] | 47 | 'testproc' | 
|  | 48 | 'test' | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 |  | 
| Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 50 | /sys/power/image_size controls the size of the image created by | 
|  | 51 | the suspend-to-disk mechanism.  It can be written a string | 
|  | 52 | representing a non-negative integer that will be used as an upper | 
| Rafael J. Wysocki | 853609b | 2006-02-01 03:05:07 -0800 | [diff] [blame] | 53 | limit of the image size, in bytes.  The suspend-to-disk mechanism will | 
| Rafael J. Wysocki | ca0aec0 | 2006-01-06 00:15:56 -0800 | [diff] [blame] | 54 | do its best to ensure the image size will not exceed that number.  However, | 
|  | 55 | if this turns out to be impossible, it will try to suspend anyway using the | 
|  | 56 | smallest image possible.  In particular, if "0" is written to this file, the | 
|  | 57 | suspend image will be as small as possible. | 
|  | 58 |  | 
|  | 59 | Reading from this file will display the current image size limit, which | 
|  | 60 | is set to 500 MB by default. | 
| Rafael J. Wysocki | c5c6ba4 | 2006-09-25 23:32:58 -0700 | [diff] [blame] | 61 |  | 
|  | 62 | /sys/power/pm_trace controls the code which saves the last PM event point in | 
|  | 63 | the RTC across reboots, so that you can debug a machine that just hangs | 
|  | 64 | during suspend (or more commonly, during resume).  Namely, the RTC is only | 
|  | 65 | used to save the last PM event point if this file contains '1'.  Initially it | 
|  | 66 | contains '0' which may be changed to '1' by writing a string representing a | 
|  | 67 | nonzero integer into it. | 
|  | 68 |  | 
|  | 69 | To use this debugging feature you should attempt to suspend the machine, then | 
|  | 70 | reboot it and run | 
|  | 71 |  | 
|  | 72 | dmesg -s 1000000 | grep 'hash matches' | 
|  | 73 |  | 
|  | 74 | CAUTION: Using it will cause your machine's real-time (CMOS) clock to be | 
|  | 75 | set to a random invalid time after a resume. |