xref: /linux/Documentation/ABI/testing/sysfs-power (revision b86ff9820fd5df69295273b9aa68e58786ffc23f)
184ed64eeSRafael J. WysockiWhat:		/sys/power/
284ed64eeSRafael J. WysockiDate:		August 2006
384ed64eeSRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
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
1084ed64eeSRafael J. WysockiDate:		August 2006
1184ed64eeSRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
1284ed64eeSRafael J. WysockiDescription:
1384ed64eeSRafael J. Wysocki		The /sys/power/state file controls the system power state.
1484ed64eeSRafael J. Wysocki		Reading from this file returns what states are supported,
1584ed64eeSRafael J. Wysocki		which is hard-coded to 'standby' (Power-On Suspend), 'mem'
1684ed64eeSRafael J. Wysocki		(Suspend-to-RAM), and 'disk' (Suspend-to-Disk).
1784ed64eeSRafael J. Wysocki
1884ed64eeSRafael J. Wysocki		Writing to this file one of these strings causes the system to
1984ed64eeSRafael J. Wysocki		transition into that state. Please see the file
2084ed64eeSRafael J. Wysocki		Documentation/power/states.txt for a description of each of
2184ed64eeSRafael J. Wysocki		these states.
2284ed64eeSRafael J. Wysocki
2384ed64eeSRafael J. WysockiWhat:		/sys/power/disk
24b918f6e6SRafael J. WysockiDate:		September 2006
2584ed64eeSRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
2684ed64eeSRafael J. WysockiDescription:
2784ed64eeSRafael J. Wysocki		The /sys/power/disk file controls the operating mode of the
2884ed64eeSRafael J. Wysocki		suspend-to-disk mechanism.  Reading from this file returns
2984ed64eeSRafael J. Wysocki		the name of the method by which the system will be put to
3084ed64eeSRafael J. Wysocki		sleep on the next suspend.  There are four methods supported:
3184ed64eeSRafael J. Wysocki		'firmware' - means that the memory image will be saved to disk
3284ed64eeSRafael J. Wysocki		by some firmware, in which case we also assume that the
3384ed64eeSRafael J. Wysocki		firmware will handle the system suspend.
3484ed64eeSRafael J. Wysocki		'platform' - the memory image will be saved by the kernel and
3584ed64eeSRafael J. Wysocki		the system will be put to sleep by the platform driver (e.g.
3684ed64eeSRafael J. Wysocki		ACPI or other PM registers).
3784ed64eeSRafael J. Wysocki		'shutdown' - the memory image will be saved by the kernel and
3884ed64eeSRafael J. Wysocki		the system will be powered off.
3984ed64eeSRafael J. Wysocki		'reboot' - the memory image will be saved by the kernel and
4084ed64eeSRafael J. Wysocki		the system will be rebooted.
4184ed64eeSRafael J. Wysocki
42b918f6e6SRafael J. Wysocki		Additionally, /sys/power/disk can be used to turn on one of the
43b918f6e6SRafael J. Wysocki		two testing modes of the suspend-to-disk mechanism: 'testproc'
44b918f6e6SRafael J. Wysocki		or 'test'.  If the suspend-to-disk mechanism is in the
45b918f6e6SRafael J. Wysocki		'testproc' mode, writing 'disk' to /sys/power/state will cause
46b918f6e6SRafael J. Wysocki		the kernel to disable nonboot CPUs and freeze tasks, wait for 5
47b918f6e6SRafael J. Wysocki		seconds, unfreeze tasks and enable nonboot CPUs.  If it is in
48b918f6e6SRafael J. Wysocki		the 'test' mode, writing 'disk' to /sys/power/state will cause
49b918f6e6SRafael J. Wysocki		the kernel to disable nonboot CPUs and freeze tasks, shrink
50b918f6e6SRafael J. Wysocki		memory, suspend devices, wait for 5 seconds, resume devices,
51b918f6e6SRafael J. Wysocki		unfreeze tasks and enable nonboot CPUs.  Then, we are able to
52b918f6e6SRafael J. Wysocki		look in the log messages and work out, for example, which code
53b918f6e6SRafael J. Wysocki		is being slow and which device drivers are misbehaving.
54b918f6e6SRafael J. Wysocki
5584ed64eeSRafael J. Wysocki		The suspend-to-disk method may be chosen by writing to this
5684ed64eeSRafael J. Wysocki		file one of the accepted strings:
5784ed64eeSRafael J. Wysocki
5884ed64eeSRafael J. Wysocki		'firmware'
5984ed64eeSRafael J. Wysocki		'platform'
6084ed64eeSRafael J. Wysocki		'shutdown'
6184ed64eeSRafael J. Wysocki		'reboot'
62b918f6e6SRafael J. Wysocki		'testproc'
63b918f6e6SRafael J. Wysocki		'test'
6484ed64eeSRafael J. Wysocki
6584ed64eeSRafael J. Wysocki		It will only change to 'firmware' or 'platform' if the system
6684ed64eeSRafael J. Wysocki		supports that.
6784ed64eeSRafael J. Wysocki
6884ed64eeSRafael J. WysockiWhat:		/sys/power/image_size
6984ed64eeSRafael J. WysockiDate:		August 2006
7084ed64eeSRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
7184ed64eeSRafael J. WysockiDescription:
7284ed64eeSRafael J. Wysocki		The /sys/power/image_size file controls the size of the image
7384ed64eeSRafael J. Wysocki		created by the suspend-to-disk mechanism.  It can be written a
7484ed64eeSRafael J. Wysocki		string representing a non-negative integer that will be used
7584ed64eeSRafael J. Wysocki		as an upper limit of the image size, in bytes.  The kernel's
7684ed64eeSRafael J. Wysocki		suspend-to-disk code will do its best to ensure the image size
7784ed64eeSRafael J. Wysocki		will not exceed this number.  However, if it turns out to be
7884ed64eeSRafael J. Wysocki		impossible, the kernel will try to suspend anyway using the
7984ed64eeSRafael J. Wysocki		smallest image possible.  In particular, if "0" is written to
8084ed64eeSRafael J. Wysocki		this file, the suspend image will be as small as possible.
8184ed64eeSRafael J. Wysocki
8284ed64eeSRafael J. Wysocki		Reading from this file will display the current image size
8384ed64eeSRafael J. Wysocki		limit, which is set to 500 MB by default.
8484ed64eeSRafael J. Wysocki
8584ed64eeSRafael J. WysockiWhat:		/sys/power/pm_trace
8684ed64eeSRafael J. WysockiDate:		August 2006
8784ed64eeSRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
8884ed64eeSRafael J. WysockiDescription:
8984ed64eeSRafael J. Wysocki		The /sys/power/pm_trace file controls the code which saves the
9084ed64eeSRafael J. Wysocki		last PM event point in the RTC across reboots, so that you can
9184ed64eeSRafael J. Wysocki		debug a machine that just hangs during suspend (or more
9284ed64eeSRafael J. Wysocki		commonly, during resume).  Namely, the RTC is only used to save
9384ed64eeSRafael J. Wysocki		the last PM event point if this file contains '1'.  Initially
9484ed64eeSRafael J. Wysocki		it contains '0' which may be changed to '1' by writing a
9584ed64eeSRafael J. Wysocki		string representing a nonzero integer into it.
9684ed64eeSRafael J. Wysocki
9784ed64eeSRafael J. Wysocki		To use this debugging feature you should attempt to suspend
9884ed64eeSRafael J. Wysocki		the machine, then reboot it and run
9984ed64eeSRafael J. Wysocki
10084ed64eeSRafael J. Wysocki		dmesg -s 1000000 | grep 'hash matches'
10184ed64eeSRafael J. Wysocki
102d33ac60bSJames Hogan		If you do not get any matches (or they appear to be false
103d33ac60bSJames Hogan		positives), it is possible that the last PM event point
104d33ac60bSJames Hogan		referred to a device created by a loadable kernel module.  In
105d33ac60bSJames Hogan		this case cat /sys/power/pm_trace_dev_match (see below) after
106d33ac60bSJames Hogan		your system is started up and the kernel modules are loaded.
107d33ac60bSJames Hogan
10884ed64eeSRafael J. Wysocki		CAUTION: Using it will cause your machine's real-time (CMOS)
10984ed64eeSRafael J. Wysocki		clock to be set to a random invalid time after a resume.
1100e06b4a8SRafael J. Wysocki
111d33ac60bSJames HoganWhat;		/sys/power/pm_trace_dev_match
112d33ac60bSJames HoganDate:		October 2010
113d33ac60bSJames HoganContact:	James Hogan <james@albanarts.com>
114d33ac60bSJames HoganDescription:
115d33ac60bSJames Hogan		The /sys/power/pm_trace_dev_match file contains the name of the
116d33ac60bSJames Hogan		device associated with the last PM event point saved in the RTC
117d33ac60bSJames Hogan		across reboots when pm_trace has been used.  More precisely it
118d33ac60bSJames Hogan		contains the list of current devices (including those
119d33ac60bSJames Hogan		registered by loadable kernel modules since boot) which match
120d33ac60bSJames Hogan		the device hash in the RTC at boot, with a newline after each
121d33ac60bSJames Hogan		one.
122d33ac60bSJames Hogan
123d33ac60bSJames Hogan		The advantage of this file over the hash matches printed to the
124d33ac60bSJames Hogan		kernel log (see /sys/power/pm_trace), is that it includes
125d33ac60bSJames Hogan		devices created after boot by loadable kernel modules.
126d33ac60bSJames Hogan
127d33ac60bSJames Hogan		Due to the small hash size necessary to fit in the RTC, it is
128d33ac60bSJames Hogan		possible that more than one device matches the hash, in which
129d33ac60bSJames Hogan		case further investigation is required to determine which
130d33ac60bSJames Hogan		device is causing the problem.  Note that genuine RTC clock
131d33ac60bSJames Hogan		values (such as when pm_trace has not been used), can still
132d33ac60bSJames Hogan		match a device and output it's name here.
133d33ac60bSJames Hogan
1340e06b4a8SRafael J. WysockiWhat:		/sys/power/pm_async
1350e06b4a8SRafael J. WysockiDate:		January 2009
1360e06b4a8SRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
1370e06b4a8SRafael J. WysockiDescription:
1380e06b4a8SRafael J. Wysocki		The /sys/power/pm_async file controls the switch allowing the
1390e06b4a8SRafael J. Wysocki		user space to enable or disable asynchronous suspend and resume
1400e06b4a8SRafael J. Wysocki		of devices.  If enabled, this feature will cause some device
1410e06b4a8SRafael J. Wysocki		drivers' suspend and resume callbacks to be executed in parallel
1420e06b4a8SRafael J. Wysocki		with each other and with the main suspend thread.  It is enabled
1430e06b4a8SRafael J. Wysocki		if this file contains "1", which is the default.  It may be
1440e06b4a8SRafael J. Wysocki		disabled by writing "0" to this file, in which case all devices
1450e06b4a8SRafael J. Wysocki		will be suspended and resumed synchronously.
146c125e96fSRafael J. Wysocki
147c125e96fSRafael J. WysockiWhat:		/sys/power/wakeup_count
148c125e96fSRafael J. WysockiDate:		July 2010
149c125e96fSRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
150c125e96fSRafael J. WysockiDescription:
151c125e96fSRafael J. Wysocki		The /sys/power/wakeup_count file allows user space to put the
152c125e96fSRafael J. Wysocki		system into a sleep state while taking into account the
153c125e96fSRafael J. Wysocki		concurrent arrival of wakeup events.  Reading from it returns
154c125e96fSRafael J. Wysocki		the current number of registered wakeup events and it blocks if
155c125e96fSRafael J. Wysocki		some wakeup events are being processed at the time the file is
156c125e96fSRafael J. Wysocki		read from.  Writing to it will only succeed if the current
157c125e96fSRafael J. Wysocki		number of wakeup events is equal to the written value and, if
158c125e96fSRafael J. Wysocki		successful, will make the kernel abort a subsequent transition
159c125e96fSRafael J. Wysocki		to a sleep state if any wakeup events are reported after the
160c125e96fSRafael J. Wysocki		write has returned.
161ddeb6487SRafael J. Wysocki
162ddeb6487SRafael J. WysockiWhat:		/sys/power/reserved_size
163ddeb6487SRafael J. WysockiDate:		May 2011
164ddeb6487SRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
165ddeb6487SRafael J. WysockiDescription:
166ddeb6487SRafael J. Wysocki		The /sys/power/reserved_size file allows user space to control
167ddeb6487SRafael J. Wysocki		the amount of memory reserved for allocations made by device
168ddeb6487SRafael J. Wysocki		drivers during the "device freeze" stage of hibernation.  It can
169ddeb6487SRafael J. Wysocki		be written a string representing a non-negative integer that
170ddeb6487SRafael J. Wysocki		will be used as the amount of memory to reserve for allocations
171ddeb6487SRafael J. Wysocki		made by device drivers' "freeze" callbacks, in bytes.
172ddeb6487SRafael J. Wysocki
173ddeb6487SRafael J. Wysocki		Reading from this file will display the current value, which is
174ddeb6487SRafael J. Wysocki		set to 1 MB by default.
1757483b4a4SRafael J. Wysocki
1767483b4a4SRafael J. WysockiWhat:		/sys/power/autosleep
1777483b4a4SRafael J. WysockiDate:		April 2012
1787483b4a4SRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
1797483b4a4SRafael J. WysockiDescription:
1807483b4a4SRafael J. Wysocki		The /sys/power/autosleep file can be written one of the strings
1817483b4a4SRafael J. Wysocki		returned by reads from /sys/power/state.  If that happens, a
1827483b4a4SRafael J. Wysocki		work item attempting to trigger a transition of the system to
1837483b4a4SRafael J. Wysocki		the sleep state represented by that string is queued up.  This
1847483b4a4SRafael J. Wysocki		attempt will only succeed if there are no active wakeup sources
1857483b4a4SRafael J. Wysocki		in the system at that time.  After every execution, regardless
1867483b4a4SRafael J. Wysocki		of whether or not the attempt to put the system to sleep has
1877483b4a4SRafael J. Wysocki		succeeded, the work item requeues itself until user space
1887483b4a4SRafael J. Wysocki		writes "off" to /sys/power/autosleep.
1897483b4a4SRafael J. Wysocki
1907483b4a4SRafael J. Wysocki		Reading from this file causes the last string successfully
1917483b4a4SRafael J. Wysocki		written to it to be returned.
192*b86ff982SRafael J. Wysocki
193*b86ff982SRafael J. WysockiWhat:		/sys/power/wake_lock
194*b86ff982SRafael J. WysockiDate:		February 2012
195*b86ff982SRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
196*b86ff982SRafael J. WysockiDescription:
197*b86ff982SRafael J. Wysocki		The /sys/power/wake_lock file allows user space to create
198*b86ff982SRafael J. Wysocki		wakeup source objects and activate them on demand (if one of
199*b86ff982SRafael J. Wysocki		those wakeup sources is active, reads from the
200*b86ff982SRafael J. Wysocki		/sys/power/wakeup_count file block or return false).  When a
201*b86ff982SRafael J. Wysocki		string without white space is written to /sys/power/wake_lock,
202*b86ff982SRafael J. Wysocki		it will be assumed to represent a wakeup source name.  If there
203*b86ff982SRafael J. Wysocki		is a wakeup source object with that name, it will be activated
204*b86ff982SRafael J. Wysocki		(unless active already).  Otherwise, a new wakeup source object
205*b86ff982SRafael J. Wysocki		will be registered, assigned the given name and activated.
206*b86ff982SRafael J. Wysocki		If a string written to /sys/power/wake_lock contains white
207*b86ff982SRafael J. Wysocki		space, the part of the string preceding the white space will be
208*b86ff982SRafael J. Wysocki		regarded as a wakeup source name and handled as descrived above.
209*b86ff982SRafael J. Wysocki		The other part of the string will be regarded as a timeout (in
210*b86ff982SRafael J. Wysocki		nanoseconds) such that the wakeup source will be automatically
211*b86ff982SRafael J. Wysocki		deactivated after it has expired.  The timeout, if present, is
212*b86ff982SRafael J. Wysocki		set regardless of the current state of the wakeup source object
213*b86ff982SRafael J. Wysocki		in question.
214*b86ff982SRafael J. Wysocki
215*b86ff982SRafael J. Wysocki		Reads from this file return a string consisting of the names of
216*b86ff982SRafael J. Wysocki		wakeup sources created with the help of it that are active at
217*b86ff982SRafael J. Wysocki		the moment, separated with spaces.
218*b86ff982SRafael J. Wysocki
219*b86ff982SRafael J. Wysocki
220*b86ff982SRafael J. WysockiWhat:		/sys/power/wake_unlock
221*b86ff982SRafael J. WysockiDate:		February 2012
222*b86ff982SRafael J. WysockiContact:	Rafael J. Wysocki <rjw@sisk.pl>
223*b86ff982SRafael J. WysockiDescription:
224*b86ff982SRafael J. Wysocki		The /sys/power/wake_unlock file allows user space to deactivate
225*b86ff982SRafael J. Wysocki		wakeup sources created with the help of /sys/power/wake_lock.
226*b86ff982SRafael J. Wysocki		When a string is written to /sys/power/wake_unlock, it will be
227*b86ff982SRafael J. Wysocki		assumed to represent the name of a wakeup source to deactivate.
228*b86ff982SRafael J. Wysocki		If a wakeup source object of that name exists and is active at
229*b86ff982SRafael J. Wysocki		the moment, it will be deactivated.
230*b86ff982SRafael J. Wysocki
231*b86ff982SRafael J. Wysocki		Reads from this file return a string consisting of the names of
232*b86ff982SRafael J. Wysocki		wakeup sources created with the help of /sys/power/wake_lock
233*b86ff982SRafael J. Wysocki		that are inactive at the moment, separated with spaces.
234