1+ =================================
12Debugging hibernation and suspend
3+ =================================
4+
25 (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL
36
471. Testing hibernation (aka suspend to disk or STD)
8+ ===================================================
59
6- To check if hibernation works, you can try to hibernate in the "reboot" mode:
10+ To check if hibernation works, you can try to hibernate in the "reboot" mode::
711
8- # echo reboot > /sys/power/disk
9- # echo disk > /sys/power/state
12+ # echo reboot > /sys/power/disk
13+ # echo disk > /sys/power/state
1014
1115and the system should create a hibernation image, reboot, resume and get back to
1216the command prompt where you have started the transition. If that happens,
@@ -15,20 +19,21 @@ test at least a couple of times in a row for confidence. [This is necessary,
1519because some problems only show up on a second attempt at suspending and
1620resuming the system.] Moreover, hibernating in the "reboot" and "shutdown"
1721modes causes the PM core to skip some platform-related callbacks which on ACPI
18- systems might be necessary to make hibernation work. Thus, if your machine fails
19- to hibernate or resume in the "reboot" mode, you should try the "platform" mode:
22+ systems might be necessary to make hibernation work. Thus, if your machine
23+ fails to hibernate or resume in the "reboot" mode, you should try the
24+ "platform" mode::
2025
21- # echo platform > /sys/power/disk
22- # echo disk > /sys/power/state
26+ # echo platform > /sys/power/disk
27+ # echo disk > /sys/power/state
2328
2429which is the default and recommended mode of hibernation.
2530
2631Unfortunately, the "platform" mode of hibernation does not work on some systems
2732with broken BIOSes. In such cases the "shutdown" mode of hibernation might
28- work:
33+ work::
2934
30- # echo shutdown > /sys/power/disk
31- # echo disk > /sys/power/state
35+ # echo shutdown > /sys/power/disk
36+ # echo disk > /sys/power/state
3237
3338(it is similar to the "reboot" mode, but it requires you to press the power
3439button to make the system resume).
@@ -37,43 +42,46 @@ If neither "platform" nor "shutdown" hibernation mode works, you will need to
3742identify what goes wrong.
3843
3944a) Test modes of hibernation
45+ ----------------------------
4046
4147To find out why hibernation fails on your system, you can use a special testing
4248facility available if the kernel is compiled with CONFIG_PM_DEBUG set. Then,
4349there is the file /sys/power/pm_test that can be used to make the hibernation
4450core run in a test mode. There are 5 test modes available:
4551
4652freezer
47- - test the freezing of processes
53+ - test the freezing of processes
4854
4955devices
50- - test the freezing of processes and suspending of devices
56+ - test the freezing of processes and suspending of devices
5157
5258platform
53- - test the freezing of processes, suspending of devices and platform
54- global control methods(*)
59+ - test the freezing of processes, suspending of devices and platform
60+ global control methods [ 1 ]_
5561
5662processors
57- - test the freezing of processes, suspending of devices, platform
58- global control methods(*) and the disabling of nonboot CPUs
63+ - test the freezing of processes, suspending of devices, platform
64+ global control methods [ 1 ]_ and the disabling of nonboot CPUs
5965
6066core
61- - test the freezing of processes, suspending of devices, platform global
62- control methods(*), the disabling of nonboot CPUs and suspending of
63- platform/system devices
67+ - test the freezing of processes, suspending of devices, platform global
68+ control methods\ [1 ]_, the disabling of nonboot CPUs and suspending
69+ of platform/system devices
70+
71+ .. [1 ]
6472
65- (*) the platform global control methods are only available on ACPI systems
73+ the platform global control methods are only available on ACPI systems
6674 and are only tested if the hibernation mode is set to "platform"
6775
6876 To use one of them it is necessary to write the corresponding string to
6977/sys/power/pm_test (eg. "devices" to test the freezing of processes and
7078suspending devices) and issue the standard hibernation commands. For example,
7179to use the "devices" test mode along with the "platform" mode of hibernation,
72- you should do the following:
80+ you should do the following::
7381
74- # echo devices > /sys/power/pm_test
75- # echo platform > /sys/power/disk
76- # echo disk > /sys/power/state
82+ # echo devices > /sys/power/pm_test
83+ # echo platform > /sys/power/disk
84+ # echo disk > /sys/power/state
7785
7886Then, the kernel will try to freeze processes, suspend devices, wait a few
7987seconds (5 by default, but configurable by the suspend.pm_test_delay module
@@ -108,11 +116,12 @@ If the "devices" test fails, most likely there is a driver that cannot suspend
108116or resume its device (in the latter case the system may hang or become unstable
109117after the test, so please take that into consideration). To find this driver,
110118you can carry out a binary search according to the rules:
119+
111120- if the test fails, unload a half of the drivers currently loaded and repeat
112- (that would probably involve rebooting the system, so always note what drivers
113- have been loaded before the test),
121+ (that would probably involve rebooting the system, so always note what drivers
122+ have been loaded before the test),
114123- if the test succeeds, load a half of the drivers you have unloaded most
115- recently and repeat.
124+ recently and repeat.
116125
117126Once you have found the failing driver (there can be more than just one of
118127them), you have to unload it every time before hibernation. In that case please
@@ -146,6 +155,7 @@ indicates a serious problem that very well may be related to the hardware, but
146155please report it anyway.
147156
148157b) Testing minimal configuration
158+ --------------------------------
149159
150160If all of the hibernation test modes work, you can boot the system with the
151161"init=/bin/bash" command line parameter and attempt to hibernate in the
@@ -165,14 +175,15 @@ Again, if you find the offending module(s), it(they) must be unloaded every time
165175before hibernation, and please report the problem with it(them).
166176
167177c) Using the "test_resume" hibernation option
178+ ---------------------------------------------
168179
169180/sys/power/disk generally tells the kernel what to do after creating a
170181hibernation image. One of the available options is "test_resume" which
171182causes the just created image to be used for immediate restoration. Namely,
172- after doing:
183+ after doing::
173184
174- # echo test_resume > /sys/power/disk
175- # echo disk > /sys/power/state
185+ # echo test_resume > /sys/power/disk
186+ # echo disk > /sys/power/state
176187
177188a hibernation image will be created and a resume from it will be triggered
178189immediately without involving the platform firmware in any way.
@@ -190,6 +201,7 @@ to resume may be related to the differences between the restore and image
190201kernels.
191202
192203d) Advanced debugging
204+ ---------------------
193205
194206In case that hibernation does not work on your system even in the minimal
195207configuration and compiling more drivers as modules is not practical or some
@@ -200,9 +212,10 @@ kernel messages using the serial console. This may provide you with some
200212information about the reasons of the suspend (resume) failure. Alternatively,
201213it may be possible to use a FireWire port for debugging with firescope
202214(http://v3.sk/~lkundrak/firescope/). On x86 it is also possible to
203- use the PM_TRACE mechanism documented in Documentation/power/s2ram.txt .
215+ use the PM_TRACE mechanism documented in Documentation/power/s2ram.rst .
204216
2052172. Testing suspend to RAM (STR)
218+ ===============================
206219
207220To verify that the STR works, it is generally more convenient to use the s2ram
208221tool available from http://suspend.sf.net and documented at
@@ -230,7 +243,8 @@ you will have to unload them every time before an STR transition (ie. before
230243you run s2ram), and please report the problems with them.
231244
232245There is a debugfs entry which shows the suspend to RAM statistics. Here is an
233- example of its output.
246+ example of its output::
247+
234248 # mount -t debugfs none /sys/kernel/debug
235249 # cat /sys/kernel/debug/suspend_stats
236250 success: 20
@@ -248,6 +262,7 @@ example of its output.
248262 -16
249263 last_failed_step: suspend
250264 suspend
265+
251266Field success means the success number of suspend to RAM, and field fail means
252267the failure number. Others are the failure number of different steps of suspend
253268to RAM. suspend_stats just lists the last 2 failed devices, error number and
0 commit comments