hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/Documentation/admin-guide/pm/sleep-states.rst
....@@ -1,10 +1,14 @@
1
+.. SPDX-License-Identifier: GPL-2.0
2
+.. include:: <isonum.txt>
3
+
14 ===================
25 System Sleep States
36 ===================
47
5
-::
8
+:Copyright: |copy| 2017 Intel Corporation
69
7
- Copyright (c) 2017 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10
+:Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
11
+
812
913 Sleep states are global low-power states of the entire system in which user
1014 space code cannot be executed and the overall system activity is significantly
....@@ -149,8 +153,11 @@
149153 Basic ``sysfs`` Interfaces for System Suspend and Hibernation
150154 =============================================================
151155
152
-The following files located in the :file:`/sys/power/` directory can be used by
153
-user space for sleep states control.
156
+The power management subsystem provides userspace with a unified ``sysfs``
157
+interface for system sleep regardless of the underlying system architecture or
158
+platform. That interface is located in the :file:`/sys/power/` directory
159
+(assuming that ``sysfs`` is mounted at :file:`/sys`) and it consists of the
160
+following attributes (files):
154161
155162 ``state``
156163 This file contains a list of strings representing sleep states supported
....@@ -158,9 +165,9 @@
158165 to start a transition of the system into the sleep state represented by
159166 that string.
160167
161
- In particular, the strings "disk", "freeze" and "standby" represent the
168
+ In particular, the "disk", "freeze" and "standby" strings represent the
162169 :ref:`hibernation <hibernation>`, :ref:`suspend-to-idle <s2idle>` and
163
- :ref:`standby <standby>` sleep states, respectively. The string "mem"
170
+ :ref:`standby <standby>` sleep states, respectively. The "mem" string
164171 is interpreted in accordance with the contents of the ``mem_sleep`` file
165172 described below.
166173
....@@ -173,7 +180,7 @@
173180 associated with the "mem" string in the ``state`` file described above.
174181
175182 The strings that may be present in this file are "s2idle", "shallow"
176
- and "deep". The string "s2idle" always represents :ref:`suspend-to-idle
183
+ and "deep". The "s2idle" string always represents :ref:`suspend-to-idle
177184 <s2idle>` and, by convention, "shallow" and "deep" represent
178185 :ref:`standby <standby>` and :ref:`suspend-to-RAM <s2ram>`,
179186 respectively.
....@@ -181,21 +188,28 @@
181188 Writing one of the listed strings into this file causes the system
182189 suspend variant represented by it to be associated with the "mem" string
183190 in the ``state`` file. The string representing the suspend variant
184
- currently associated with the "mem" string in the ``state`` file
185
- is listed in square brackets.
191
+ currently associated with the "mem" string in the ``state`` file is
192
+ shown in square brackets.
186193
187194 If the kernel does not support system suspend, this file is not present.
188195
189196 ``disk``
190
- This file contains a list of strings representing different operations
191
- that can be carried out after the hibernation image has been saved. The
192
- possible options are as follows:
197
+ This file controls the operating mode of hibernation (Suspend-to-Disk).
198
+ Specifically, it tells the kernel what to do after creating a
199
+ hibernation image.
200
+
201
+ Reading from it returns a list of supported options encoded as:
193202
194203 ``platform``
195204 Put the system into a special low-power state (e.g. ACPI S4) to
196205 make additional wakeup options available and possibly allow the
197206 platform firmware to take a simplified initialization path after
198207 wakeup.
208
+
209
+ It is only available if the platform provides a special
210
+ mechanism to put the system to sleep after creating a
211
+ hibernation image (platforms with ACPI do that as a rule, for
212
+ example).
199213
200214 ``shutdown``
201215 Power off the system.
....@@ -210,21 +224,52 @@
210224 the hibernation image and continue. Otherwise, use the image
211225 to restore the previous state of the system.
212226
227
+ It is available if system suspend is supported.
228
+
213229 ``test_resume``
214230 Diagnostic operation. Load the image as though the system had
215231 just woken up from hibernation and the currently running kernel
216232 instance was a restore kernel and follow up with full system
217233 resume.
218234
219
- Writing one of the listed strings into this file causes the option
235
+ Writing one of the strings listed above into this file causes the option
220236 represented by it to be selected.
221237
222
- The currently selected option is shown in square brackets which means
238
+ The currently selected option is shown in square brackets, which means
223239 that the operation represented by it will be carried out after creating
224
- and saving the image next time hibernation is triggered by writing
225
- ``disk`` to :file:`/sys/power/state`.
240
+ and saving the image when hibernation is triggered by writing ``disk``
241
+ to :file:`/sys/power/state`.
226242
227243 If the kernel does not support hibernation, this file is not present.
244
+
245
+``image_size``
246
+ This file controls the size of hibernation images.
247
+
248
+ It can be written a string representing a non-negative integer that will
249
+ be used as a best-effort upper limit of the image size, in bytes. The
250
+ hibernation core will do its best to ensure that the image size will not
251
+ exceed that number, but if that turns out to be impossible to achieve, a
252
+ hibernation image will still be created and its size will be as small as
253
+ possible. In particular, writing '0' to this file causes the size of
254
+ hibernation images to be minimum.
255
+
256
+ Reading from it returns the current image size limit, which is set to
257
+ around 2/5 of the available RAM size by default.
258
+
259
+``pm_trace``
260
+ This file controls the "PM trace" mechanism saving the last suspend
261
+ or resume event point in the RTC memory across reboots. It helps to
262
+ debug hard lockups or reboots due to device driver failures that occur
263
+ during system suspend or resume (which is more common) more effectively.
264
+
265
+ If it contains "1", the fingerprint of each suspend/resume event point
266
+ in turn will be stored in the RTC memory (overwriting the actual RTC
267
+ information), so it will survive a system crash if one occurs right
268
+ after storing it and it can be used later to identify the driver that
269
+ caused the crash to happen.
270
+
271
+ It contains "0" by default, which may be changed to "1" by writing a
272
+ string representing a nonzero integer into it.
228273
229274 According to the above, there are two ways to make the system go into the
230275 :ref:`suspend-to-idle <s2idle>` state. The first one is to write "freeze"
....@@ -240,6 +285,7 @@
240285 The default suspend variant (ie. the one to be used without writing anything
241286 into :file:`/sys/power/mem_sleep`) is either "deep" (on the majority of systems
242287 supporting :ref:`suspend-to-RAM <s2ram>`) or "s2idle", but it can be overridden
243
-by the value of the "mem_sleep_default" parameter in the kernel command line.
244
-On some ACPI-based systems, depending on the information in the ACPI tables, the
245
-default may be "s2idle" even if :ref:`suspend-to-RAM <s2ram>` is supported.
288
+by the value of the ``mem_sleep_default`` parameter in the kernel command line.
289
+On some systems with ACPI, depending on the information in the ACPI tables, the
290
+default may be "s2idle" even if :ref:`suspend-to-RAM <s2ram>` is supported in
291
+principle.