184ed64eeSRafael J. WysockiWhat: /sys/power/ 284ed64eeSRafael J. WysockiDate: August 2006 349db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 484ed64eeSRafael J. WysockiDescription: 584ed64eeSRafael J. Wysocki The /sys/power directory will contain files that will 684ed64eeSRafael J. Wysocki provide a unified interface to the power management 784ed64eeSRafael J. Wysocki subsystem. 884ed64eeSRafael J. Wysocki 984ed64eeSRafael J. WysockiWhat: /sys/power/state 10*0399d4dbSRafael J. WysockiDate: May 2014 1149db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 1284ed64eeSRafael J. WysockiDescription: 13*0399d4dbSRafael J. Wysocki The /sys/power/state file controls system sleep states. 14*0399d4dbSRafael J. Wysocki Reading from this file returns the available sleep state 15*0399d4dbSRafael J. Wysocki labels, which may be "mem", "standby", "freeze" and "disk" 16*0399d4dbSRafael J. Wysocki (hibernation). The meanings of the first three labels depend on 17*0399d4dbSRafael J. Wysocki the relative_sleep_states command line argument as follows: 18*0399d4dbSRafael J. Wysocki 1) relative_sleep_states = 1 19*0399d4dbSRafael J. Wysocki "mem", "standby", "freeze" represent non-hibernation sleep 20*0399d4dbSRafael J. Wysocki states from the deepest ("mem", always present) to the 21*0399d4dbSRafael J. Wysocki shallowest ("freeze"). "standby" and "freeze" may or may 22*0399d4dbSRafael J. Wysocki not be present depending on the capabilities of the 23*0399d4dbSRafael J. Wysocki platform. "freeze" can only be present if "standby" is 24*0399d4dbSRafael J. Wysocki present. 25*0399d4dbSRafael J. Wysocki 2) relative_sleep_states = 0 (default) 26*0399d4dbSRafael J. Wysocki "mem" - "suspend-to-RAM", present if supported. 27*0399d4dbSRafael J. Wysocki "standby" - "power-on suspend", present if supported. 28*0399d4dbSRafael J. Wysocki "freeze" - "suspend-to-idle", always present. 2984ed64eeSRafael J. Wysocki 3084ed64eeSRafael J. Wysocki Writing to this file one of these strings causes the system to 31*0399d4dbSRafael J. Wysocki transition into the corresponding state, if available. See 32*0399d4dbSRafael J. Wysocki Documentation/power/states.txt for a description of what 33*0399d4dbSRafael J. Wysocki "suspend-to-RAM", "power-on suspend" and "suspend-to-idle" mean. 3484ed64eeSRafael J. Wysocki 3584ed64eeSRafael J. WysockiWhat: /sys/power/disk 36b918f6e6SRafael J. WysockiDate: September 2006 3749db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 3884ed64eeSRafael J. WysockiDescription: 3984ed64eeSRafael J. Wysocki The /sys/power/disk file controls the operating mode of the 4084ed64eeSRafael J. Wysocki suspend-to-disk mechanism. Reading from this file returns 4184ed64eeSRafael J. Wysocki the name of the method by which the system will be put to 4284ed64eeSRafael J. Wysocki sleep on the next suspend. There are four methods supported: 4384ed64eeSRafael J. Wysocki 'firmware' - means that the memory image will be saved to disk 4484ed64eeSRafael J. Wysocki by some firmware, in which case we also assume that the 4584ed64eeSRafael J. Wysocki firmware will handle the system suspend. 4684ed64eeSRafael J. Wysocki 'platform' - the memory image will be saved by the kernel and 4784ed64eeSRafael J. Wysocki the system will be put to sleep by the platform driver (e.g. 4884ed64eeSRafael J. Wysocki ACPI or other PM registers). 4984ed64eeSRafael J. Wysocki 'shutdown' - the memory image will be saved by the kernel and 5084ed64eeSRafael J. Wysocki the system will be powered off. 5184ed64eeSRafael J. Wysocki 'reboot' - the memory image will be saved by the kernel and 5284ed64eeSRafael J. Wysocki the system will be rebooted. 5384ed64eeSRafael J. Wysocki 54b918f6e6SRafael J. Wysocki Additionally, /sys/power/disk can be used to turn on one of the 55b918f6e6SRafael J. Wysocki two testing modes of the suspend-to-disk mechanism: 'testproc' 56b918f6e6SRafael J. Wysocki or 'test'. If the suspend-to-disk mechanism is in the 57b918f6e6SRafael J. Wysocki 'testproc' mode, writing 'disk' to /sys/power/state will cause 58b918f6e6SRafael J. Wysocki the kernel to disable nonboot CPUs and freeze tasks, wait for 5 59b918f6e6SRafael J. Wysocki seconds, unfreeze tasks and enable nonboot CPUs. If it is in 60b918f6e6SRafael J. Wysocki the 'test' mode, writing 'disk' to /sys/power/state will cause 61b918f6e6SRafael J. Wysocki the kernel to disable nonboot CPUs and freeze tasks, shrink 62b918f6e6SRafael J. Wysocki memory, suspend devices, wait for 5 seconds, resume devices, 63b918f6e6SRafael J. Wysocki unfreeze tasks and enable nonboot CPUs. Then, we are able to 64b918f6e6SRafael J. Wysocki look in the log messages and work out, for example, which code 65b918f6e6SRafael J. Wysocki is being slow and which device drivers are misbehaving. 66b918f6e6SRafael J. Wysocki 6784ed64eeSRafael J. Wysocki The suspend-to-disk method may be chosen by writing to this 6884ed64eeSRafael J. Wysocki file one of the accepted strings: 6984ed64eeSRafael J. Wysocki 7084ed64eeSRafael J. Wysocki 'firmware' 7184ed64eeSRafael J. Wysocki 'platform' 7284ed64eeSRafael J. Wysocki 'shutdown' 7384ed64eeSRafael J. Wysocki 'reboot' 74b918f6e6SRafael J. Wysocki 'testproc' 75b918f6e6SRafael J. Wysocki 'test' 7684ed64eeSRafael J. Wysocki 7784ed64eeSRafael J. Wysocki It will only change to 'firmware' or 'platform' if the system 7884ed64eeSRafael J. Wysocki supports that. 7984ed64eeSRafael J. Wysocki 8084ed64eeSRafael J. WysockiWhat: /sys/power/image_size 8184ed64eeSRafael J. WysockiDate: August 2006 8249db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 8384ed64eeSRafael J. WysockiDescription: 8484ed64eeSRafael J. Wysocki The /sys/power/image_size file controls the size of the image 8584ed64eeSRafael J. Wysocki created by the suspend-to-disk mechanism. It can be written a 8684ed64eeSRafael J. Wysocki string representing a non-negative integer that will be used 8784ed64eeSRafael J. Wysocki as an upper limit of the image size, in bytes. The kernel's 8884ed64eeSRafael J. Wysocki suspend-to-disk code will do its best to ensure the image size 8984ed64eeSRafael J. Wysocki will not exceed this number. However, if it turns out to be 9084ed64eeSRafael J. Wysocki impossible, the kernel will try to suspend anyway using the 9184ed64eeSRafael J. Wysocki smallest image possible. In particular, if "0" is written to 9284ed64eeSRafael J. Wysocki this file, the suspend image will be as small as possible. 9384ed64eeSRafael J. Wysocki 9484ed64eeSRafael J. Wysocki Reading from this file will display the current image size 9584ed64eeSRafael J. Wysocki limit, which is set to 500 MB by default. 9684ed64eeSRafael J. Wysocki 9784ed64eeSRafael J. WysockiWhat: /sys/power/pm_trace 9884ed64eeSRafael J. WysockiDate: August 2006 9949db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 10084ed64eeSRafael J. WysockiDescription: 10184ed64eeSRafael J. Wysocki The /sys/power/pm_trace file controls the code which saves the 10284ed64eeSRafael J. Wysocki last PM event point in the RTC across reboots, so that you can 10384ed64eeSRafael J. Wysocki debug a machine that just hangs during suspend (or more 10484ed64eeSRafael J. Wysocki commonly, during resume). Namely, the RTC is only used to save 10584ed64eeSRafael J. Wysocki the last PM event point if this file contains '1'. Initially 10684ed64eeSRafael J. Wysocki it contains '0' which may be changed to '1' by writing a 10784ed64eeSRafael J. Wysocki string representing a nonzero integer into it. 10884ed64eeSRafael J. Wysocki 10984ed64eeSRafael J. Wysocki To use this debugging feature you should attempt to suspend 11084ed64eeSRafael J. Wysocki the machine, then reboot it and run 11184ed64eeSRafael J. Wysocki 11284ed64eeSRafael J. Wysocki dmesg -s 1000000 | grep 'hash matches' 11384ed64eeSRafael J. Wysocki 114d33ac60bSJames Hogan If you do not get any matches (or they appear to be false 115d33ac60bSJames Hogan positives), it is possible that the last PM event point 116d33ac60bSJames Hogan referred to a device created by a loadable kernel module. In 117d33ac60bSJames Hogan this case cat /sys/power/pm_trace_dev_match (see below) after 118d33ac60bSJames Hogan your system is started up and the kernel modules are loaded. 119d33ac60bSJames Hogan 12084ed64eeSRafael J. Wysocki CAUTION: Using it will cause your machine's real-time (CMOS) 12184ed64eeSRafael J. Wysocki clock to be set to a random invalid time after a resume. 1220e06b4a8SRafael J. Wysocki 123d33ac60bSJames HoganWhat; /sys/power/pm_trace_dev_match 124d33ac60bSJames HoganDate: October 2010 125d33ac60bSJames HoganContact: James Hogan <james@albanarts.com> 126d33ac60bSJames HoganDescription: 127d33ac60bSJames Hogan The /sys/power/pm_trace_dev_match file contains the name of the 128d33ac60bSJames Hogan device associated with the last PM event point saved in the RTC 129d33ac60bSJames Hogan across reboots when pm_trace has been used. More precisely it 130d33ac60bSJames Hogan contains the list of current devices (including those 131d33ac60bSJames Hogan registered by loadable kernel modules since boot) which match 132d33ac60bSJames Hogan the device hash in the RTC at boot, with a newline after each 133d33ac60bSJames Hogan one. 134d33ac60bSJames Hogan 135d33ac60bSJames Hogan The advantage of this file over the hash matches printed to the 136d33ac60bSJames Hogan kernel log (see /sys/power/pm_trace), is that it includes 137d33ac60bSJames Hogan devices created after boot by loadable kernel modules. 138d33ac60bSJames Hogan 139d33ac60bSJames Hogan Due to the small hash size necessary to fit in the RTC, it is 140d33ac60bSJames Hogan possible that more than one device matches the hash, in which 141d33ac60bSJames Hogan case further investigation is required to determine which 142d33ac60bSJames Hogan device is causing the problem. Note that genuine RTC clock 143d33ac60bSJames Hogan values (such as when pm_trace has not been used), can still 144d33ac60bSJames Hogan match a device and output it's name here. 145d33ac60bSJames Hogan 1460e06b4a8SRafael J. WysockiWhat: /sys/power/pm_async 1470e06b4a8SRafael J. WysockiDate: January 2009 14849db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 1490e06b4a8SRafael J. WysockiDescription: 1500e06b4a8SRafael J. Wysocki The /sys/power/pm_async file controls the switch allowing the 1510e06b4a8SRafael J. Wysocki user space to enable or disable asynchronous suspend and resume 1520e06b4a8SRafael J. Wysocki of devices. If enabled, this feature will cause some device 1530e06b4a8SRafael J. Wysocki drivers' suspend and resume callbacks to be executed in parallel 1540e06b4a8SRafael J. Wysocki with each other and with the main suspend thread. It is enabled 1550e06b4a8SRafael J. Wysocki if this file contains "1", which is the default. It may be 1560e06b4a8SRafael J. Wysocki disabled by writing "0" to this file, in which case all devices 1570e06b4a8SRafael J. Wysocki will be suspended and resumed synchronously. 158c125e96fSRafael J. Wysocki 159c125e96fSRafael J. WysockiWhat: /sys/power/wakeup_count 160c125e96fSRafael J. WysockiDate: July 2010 16149db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 162c125e96fSRafael J. WysockiDescription: 163c125e96fSRafael J. Wysocki The /sys/power/wakeup_count file allows user space to put the 164c125e96fSRafael J. Wysocki system into a sleep state while taking into account the 165c125e96fSRafael J. Wysocki concurrent arrival of wakeup events. Reading from it returns 166c125e96fSRafael J. Wysocki the current number of registered wakeup events and it blocks if 167c125e96fSRafael J. Wysocki some wakeup events are being processed at the time the file is 168c125e96fSRafael J. Wysocki read from. Writing to it will only succeed if the current 169c125e96fSRafael J. Wysocki number of wakeup events is equal to the written value and, if 170c125e96fSRafael J. Wysocki successful, will make the kernel abort a subsequent transition 171c125e96fSRafael J. Wysocki to a sleep state if any wakeup events are reported after the 172c125e96fSRafael J. Wysocki write has returned. 173ddeb6487SRafael J. Wysocki 174ddeb6487SRafael J. WysockiWhat: /sys/power/reserved_size 175ddeb6487SRafael J. WysockiDate: May 2011 17649db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 177ddeb6487SRafael J. WysockiDescription: 178ddeb6487SRafael J. Wysocki The /sys/power/reserved_size file allows user space to control 179ddeb6487SRafael J. Wysocki the amount of memory reserved for allocations made by device 180ddeb6487SRafael J. Wysocki drivers during the "device freeze" stage of hibernation. It can 181ddeb6487SRafael J. Wysocki be written a string representing a non-negative integer that 182ddeb6487SRafael J. Wysocki will be used as the amount of memory to reserve for allocations 183ddeb6487SRafael J. Wysocki made by device drivers' "freeze" callbacks, in bytes. 184ddeb6487SRafael J. Wysocki 185ddeb6487SRafael J. Wysocki Reading from this file will display the current value, which is 186ddeb6487SRafael J. Wysocki set to 1 MB by default. 1877483b4a4SRafael J. Wysocki 1887483b4a4SRafael J. WysockiWhat: /sys/power/autosleep 1897483b4a4SRafael J. WysockiDate: April 2012 19049db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 1917483b4a4SRafael J. WysockiDescription: 1927483b4a4SRafael J. Wysocki The /sys/power/autosleep file can be written one of the strings 1937483b4a4SRafael J. Wysocki returned by reads from /sys/power/state. If that happens, a 1947483b4a4SRafael J. Wysocki work item attempting to trigger a transition of the system to 1957483b4a4SRafael J. Wysocki the sleep state represented by that string is queued up. This 1967483b4a4SRafael J. Wysocki attempt will only succeed if there are no active wakeup sources 1977483b4a4SRafael J. Wysocki in the system at that time. After every execution, regardless 1987483b4a4SRafael J. Wysocki of whether or not the attempt to put the system to sleep has 1997483b4a4SRafael J. Wysocki succeeded, the work item requeues itself until user space 2007483b4a4SRafael J. Wysocki writes "off" to /sys/power/autosleep. 2017483b4a4SRafael J. Wysocki 2027483b4a4SRafael J. Wysocki Reading from this file causes the last string successfully 2037483b4a4SRafael J. Wysocki written to it to be returned. 204b86ff982SRafael J. Wysocki 205b86ff982SRafael J. WysockiWhat: /sys/power/wake_lock 206b86ff982SRafael J. WysockiDate: February 2012 20749db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 208b86ff982SRafael J. WysockiDescription: 209b86ff982SRafael J. Wysocki The /sys/power/wake_lock file allows user space to create 210b86ff982SRafael J. Wysocki wakeup source objects and activate them on demand (if one of 211b86ff982SRafael J. Wysocki those wakeup sources is active, reads from the 212b86ff982SRafael J. Wysocki /sys/power/wakeup_count file block or return false). When a 213b86ff982SRafael J. Wysocki string without white space is written to /sys/power/wake_lock, 214b86ff982SRafael J. Wysocki it will be assumed to represent a wakeup source name. If there 215b86ff982SRafael J. Wysocki is a wakeup source object with that name, it will be activated 216b86ff982SRafael J. Wysocki (unless active already). Otherwise, a new wakeup source object 217b86ff982SRafael J. Wysocki will be registered, assigned the given name and activated. 218b86ff982SRafael J. Wysocki If a string written to /sys/power/wake_lock contains white 219b86ff982SRafael J. Wysocki space, the part of the string preceding the white space will be 220b86ff982SRafael J. Wysocki regarded as a wakeup source name and handled as descrived above. 221b86ff982SRafael J. Wysocki The other part of the string will be regarded as a timeout (in 222b86ff982SRafael J. Wysocki nanoseconds) such that the wakeup source will be automatically 223b86ff982SRafael J. Wysocki deactivated after it has expired. The timeout, if present, is 224b86ff982SRafael J. Wysocki set regardless of the current state of the wakeup source object 225b86ff982SRafael J. Wysocki in question. 226b86ff982SRafael J. Wysocki 227b86ff982SRafael J. Wysocki Reads from this file return a string consisting of the names of 228b86ff982SRafael J. Wysocki wakeup sources created with the help of it that are active at 229b86ff982SRafael J. Wysocki the moment, separated with spaces. 230b86ff982SRafael J. Wysocki 231b86ff982SRafael J. Wysocki 232b86ff982SRafael J. WysockiWhat: /sys/power/wake_unlock 233b86ff982SRafael J. WysockiDate: February 2012 23449db1903SRafael J. WysockiContact: Rafael J. Wysocki <rjw@rjwysocki.net> 235b86ff982SRafael J. WysockiDescription: 236b86ff982SRafael J. Wysocki The /sys/power/wake_unlock file allows user space to deactivate 237b86ff982SRafael J. Wysocki wakeup sources created with the help of /sys/power/wake_lock. 238b86ff982SRafael J. Wysocki When a string is written to /sys/power/wake_unlock, it will be 239b86ff982SRafael J. Wysocki assumed to represent the name of a wakeup source to deactivate. 240b86ff982SRafael J. Wysocki If a wakeup source object of that name exists and is active at 241b86ff982SRafael J. Wysocki the moment, it will be deactivated. 242b86ff982SRafael J. Wysocki 243b86ff982SRafael J. Wysocki Reads from this file return a string consisting of the names of 244b86ff982SRafael J. Wysocki wakeup sources created with the help of /sys/power/wake_lock 245b86ff982SRafael J. Wysocki that are inactive at the moment, separated with spaces. 2464b7760baSSameer Nanda 2474b7760baSSameer NandaWhat: /sys/power/pm_print_times 2484b7760baSSameer NandaDate: May 2012 2494b7760baSSameer NandaContact: Sameer Nanda <snanda@chromium.org> 2504b7760baSSameer NandaDescription: 2514b7760baSSameer Nanda The /sys/power/pm_print_times file allows user space to 2524b7760baSSameer Nanda control whether the time taken by devices to suspend and 2534b7760baSSameer Nanda resume is printed. These prints are useful for hunting down 2544b7760baSSameer Nanda devices that take too long to suspend or resume. 2554b7760baSSameer Nanda 2564b7760baSSameer Nanda Writing a "1" enables this printing while writing a "0" 2574b7760baSSameer Nanda disables it. The default value is "0". Reading from this file 2584b7760baSSameer Nanda will display the current value. 259