.. | .. |
---|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 |
---|
| 2 | +.. include:: <isonum.txt> |
---|
| 3 | + |
---|
1 | 4 | =================== |
---|
2 | 5 | System Sleep States |
---|
3 | 6 | =================== |
---|
4 | 7 | |
---|
5 | | -:: |
---|
| 8 | +:Copyright: |copy| 2017 Intel Corporation |
---|
6 | 9 | |
---|
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 | + |
---|
8 | 12 | |
---|
9 | 13 | Sleep states are global low-power states of the entire system in which user |
---|
10 | 14 | space code cannot be executed and the overall system activity is significantly |
---|
.. | .. |
---|
149 | 153 | Basic ``sysfs`` Interfaces for System Suspend and Hibernation |
---|
150 | 154 | ============================================================= |
---|
151 | 155 | |
---|
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): |
---|
154 | 161 | |
---|
155 | 162 | ``state`` |
---|
156 | 163 | This file contains a list of strings representing sleep states supported |
---|
.. | .. |
---|
158 | 165 | to start a transition of the system into the sleep state represented by |
---|
159 | 166 | that string. |
---|
160 | 167 | |
---|
161 | | - In particular, the strings "disk", "freeze" and "standby" represent the |
---|
| 168 | + In particular, the "disk", "freeze" and "standby" strings represent the |
---|
162 | 169 | :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 |
---|
164 | 171 | is interpreted in accordance with the contents of the ``mem_sleep`` file |
---|
165 | 172 | described below. |
---|
166 | 173 | |
---|
.. | .. |
---|
173 | 180 | associated with the "mem" string in the ``state`` file described above. |
---|
174 | 181 | |
---|
175 | 182 | 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 |
---|
177 | 184 | <s2idle>` and, by convention, "shallow" and "deep" represent |
---|
178 | 185 | :ref:`standby <standby>` and :ref:`suspend-to-RAM <s2ram>`, |
---|
179 | 186 | respectively. |
---|
.. | .. |
---|
181 | 188 | Writing one of the listed strings into this file causes the system |
---|
182 | 189 | suspend variant represented by it to be associated with the "mem" string |
---|
183 | 190 | 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. |
---|
186 | 193 | |
---|
187 | 194 | If the kernel does not support system suspend, this file is not present. |
---|
188 | 195 | |
---|
189 | 196 | ``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: |
---|
193 | 202 | |
---|
194 | 203 | ``platform`` |
---|
195 | 204 | Put the system into a special low-power state (e.g. ACPI S4) to |
---|
196 | 205 | make additional wakeup options available and possibly allow the |
---|
197 | 206 | platform firmware to take a simplified initialization path after |
---|
198 | 207 | 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). |
---|
199 | 213 | |
---|
200 | 214 | ``shutdown`` |
---|
201 | 215 | Power off the system. |
---|
.. | .. |
---|
210 | 224 | the hibernation image and continue. Otherwise, use the image |
---|
211 | 225 | to restore the previous state of the system. |
---|
212 | 226 | |
---|
| 227 | + It is available if system suspend is supported. |
---|
| 228 | + |
---|
213 | 229 | ``test_resume`` |
---|
214 | 230 | Diagnostic operation. Load the image as though the system had |
---|
215 | 231 | just woken up from hibernation and the currently running kernel |
---|
216 | 232 | instance was a restore kernel and follow up with full system |
---|
217 | 233 | resume. |
---|
218 | 234 | |
---|
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 |
---|
220 | 236 | represented by it to be selected. |
---|
221 | 237 | |
---|
222 | | - The currently selected option is shown in square brackets which means |
---|
| 238 | + The currently selected option is shown in square brackets, which means |
---|
223 | 239 | 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`. |
---|
226 | 242 | |
---|
227 | 243 | 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. |
---|
228 | 273 | |
---|
229 | 274 | According to the above, there are two ways to make the system go into the |
---|
230 | 275 | :ref:`suspend-to-idle <s2idle>` state. The first one is to write "freeze" |
---|
.. | .. |
---|
240 | 285 | The default suspend variant (ie. the one to be used without writing anything |
---|
241 | 286 | into :file:`/sys/power/mem_sleep`) is either "deep" (on the majority of systems |
---|
242 | 287 | 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. |
---|