1
+ =================================
1
2
Debugging hibernation and suspend
3
+ =================================
4
+
2
5
(C) 2007 Rafael J. Wysocki <
[email protected] >, GPL
3
6
4
7
1. Testing hibernation (aka suspend to disk or STD)
8
+ ===================================================
5
9
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::
7
11
8
- # echo reboot > /sys/power/disk
9
- # echo disk > /sys/power/state
12
+ # echo reboot > /sys/power/disk
13
+ # echo disk > /sys/power/state
10
14
11
15
and the system should create a hibernation image, reboot, resume and get back to
12
16
the 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,
15
19
because some problems only show up on a second attempt at suspending and
16
20
resuming the system.] Moreover, hibernating in the "reboot" and "shutdown"
17
21
modes 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::
20
25
21
- # echo platform > /sys/power/disk
22
- # echo disk > /sys/power/state
26
+ # echo platform > /sys/power/disk
27
+ # echo disk > /sys/power/state
23
28
24
29
which is the default and recommended mode of hibernation.
25
30
26
31
Unfortunately, the "platform" mode of hibernation does not work on some systems
27
32
with broken BIOSes. In such cases the "shutdown" mode of hibernation might
28
- work:
33
+ work::
29
34
30
- # echo shutdown > /sys/power/disk
31
- # echo disk > /sys/power/state
35
+ # echo shutdown > /sys/power/disk
36
+ # echo disk > /sys/power/state
32
37
33
38
(it is similar to the "reboot" mode, but it requires you to press the power
34
39
button to make the system resume).
@@ -37,43 +42,46 @@ If neither "platform" nor "shutdown" hibernation mode works, you will need to
37
42
identify what goes wrong.
38
43
39
44
a) Test modes of hibernation
45
+ ----------------------------
40
46
41
47
To find out why hibernation fails on your system, you can use a special testing
42
48
facility available if the kernel is compiled with CONFIG_PM_DEBUG set. Then,
43
49
there is the file /sys/power/pm_test that can be used to make the hibernation
44
50
core run in a test mode. There are 5 test modes available:
45
51
46
52
freezer
47
- - test the freezing of processes
53
+ - test the freezing of processes
48
54
49
55
devices
50
- - test the freezing of processes and suspending of devices
56
+ - test the freezing of processes and suspending of devices
51
57
52
58
platform
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 ]_
55
61
56
62
processors
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
59
65
60
66
core
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 ]
64
72
65
- (*) the platform global control methods are only available on ACPI systems
73
+ the platform global control methods are only available on ACPI systems
66
74
and are only tested if the hibernation mode is set to "platform"
67
75
68
76
To use one of them it is necessary to write the corresponding string to
69
77
/sys/power/pm_test (eg. "devices" to test the freezing of processes and
70
78
suspending devices) and issue the standard hibernation commands. For example,
71
79
to use the "devices" test mode along with the "platform" mode of hibernation,
72
- you should do the following:
80
+ you should do the following::
73
81
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
77
85
78
86
Then, the kernel will try to freeze processes, suspend devices, wait a few
79
87
seconds (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
108
116
or resume its device (in the latter case the system may hang or become unstable
109
117
after the test, so please take that into consideration). To find this driver,
110
118
you can carry out a binary search according to the rules:
119
+
111
120
- 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),
114
123
- if the test succeeds, load a half of the drivers you have unloaded most
115
- recently and repeat.
124
+ recently and repeat.
116
125
117
126
Once you have found the failing driver (there can be more than just one of
118
127
them), 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
146
155
please report it anyway.
147
156
148
157
b) Testing minimal configuration
158
+ --------------------------------
149
159
150
160
If all of the hibernation test modes work, you can boot the system with the
151
161
"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
165
175
before hibernation, and please report the problem with it(them).
166
176
167
177
c) Using the "test_resume" hibernation option
178
+ ---------------------------------------------
168
179
169
180
/sys/power/disk generally tells the kernel what to do after creating a
170
181
hibernation image. One of the available options is "test_resume" which
171
182
causes the just created image to be used for immediate restoration. Namely,
172
- after doing:
183
+ after doing::
173
184
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
176
187
177
188
a hibernation image will be created and a resume from it will be triggered
178
189
immediately 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
190
201
kernels.
191
202
192
203
d) Advanced debugging
204
+ ---------------------
193
205
194
206
In case that hibernation does not work on your system even in the minimal
195
207
configuration 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
200
212
information about the reasons of the suspend (resume) failure. Alternatively,
201
213
it may be possible to use a FireWire port for debugging with firescope
202
214
(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 .
204
216
205
217
2. Testing suspend to RAM (STR)
218
+ ===============================
206
219
207
220
To verify that the STR works, it is generally more convenient to use the s2ram
208
221
tool 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
230
243
you run s2ram), and please report the problems with them.
231
244
232
245
There 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
+
234
248
# mount -t debugfs none /sys/kernel/debug
235
249
# cat /sys/kernel/debug/suspend_stats
236
250
success: 20
@@ -248,6 +262,7 @@ example of its output.
248
262
-16
249
263
last_failed_step: suspend
250
264
suspend
265
+
251
266
Field success means the success number of suspend to RAM, and field fail means
252
267
the failure number. Others are the failure number of different steps of suspend
253
268
to RAM. suspend_stats just lists the last 2 failed devices, error number and
0 commit comments