xref: /openbmc/linux/Documentation/power/s2ram.rst (revision 0898782247ae533d1f4e47a06bc5d4870931b284)
1*151f4e2bSMauro Carvalho Chehab========================
2*151f4e2bSMauro Carvalho ChehabHow to get s2ram working
3*151f4e2bSMauro Carvalho Chehab========================
4*151f4e2bSMauro Carvalho Chehab
5*151f4e2bSMauro Carvalho Chehab2006 Linus Torvalds
6*151f4e2bSMauro Carvalho Chehab2006 Pavel Machek
7*151f4e2bSMauro Carvalho Chehab
8*151f4e2bSMauro Carvalho Chehab1) Check suspend.sf.net, program s2ram there has long whitelist of
9*151f4e2bSMauro Carvalho Chehab   "known ok" machines, along with tricks to use on each one.
10*151f4e2bSMauro Carvalho Chehab
11*151f4e2bSMauro Carvalho Chehab2) If that does not help, try reading tricks.txt and
12*151f4e2bSMauro Carvalho Chehab   video.txt. Perhaps problem is as simple as broken module, and
13*151f4e2bSMauro Carvalho Chehab   simple module unload can fix it.
14*151f4e2bSMauro Carvalho Chehab
15*151f4e2bSMauro Carvalho Chehab3) You can use Linus' TRACE_RESUME infrastructure, described below.
16*151f4e2bSMauro Carvalho Chehab
17*151f4e2bSMauro Carvalho ChehabUsing TRACE_RESUME
18*151f4e2bSMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~
19*151f4e2bSMauro Carvalho Chehab
20*151f4e2bSMauro Carvalho ChehabI've been working at making the machines I have able to STR, and almost
21*151f4e2bSMauro Carvalho Chehabalways it's a driver that is buggy. Thank God for the suspend/resume
22*151f4e2bSMauro Carvalho Chehabdebugging - the thing that Chuck tried to disable. That's often the _only_
23*151f4e2bSMauro Carvalho Chehabway to debug these things, and it's actually pretty powerful (but
24*151f4e2bSMauro Carvalho Chehabtime-consuming - having to insert TRACE_RESUME() markers into the device
25*151f4e2bSMauro Carvalho Chehabdriver that doesn't resume and recompile and reboot).
26*151f4e2bSMauro Carvalho Chehab
27*151f4e2bSMauro Carvalho ChehabAnyway, the way to debug this for people who are interested (have a
28*151f4e2bSMauro Carvalho Chehabmachine that doesn't boot) is:
29*151f4e2bSMauro Carvalho Chehab
30*151f4e2bSMauro Carvalho Chehab - enable PM_DEBUG, and PM_TRACE
31*151f4e2bSMauro Carvalho Chehab
32*151f4e2bSMauro Carvalho Chehab - use a script like this::
33*151f4e2bSMauro Carvalho Chehab
34*151f4e2bSMauro Carvalho Chehab	#!/bin/sh
35*151f4e2bSMauro Carvalho Chehab	sync
36*151f4e2bSMauro Carvalho Chehab	echo 1 > /sys/power/pm_trace
37*151f4e2bSMauro Carvalho Chehab	echo mem > /sys/power/state
38*151f4e2bSMauro Carvalho Chehab
39*151f4e2bSMauro Carvalho Chehab   to suspend
40*151f4e2bSMauro Carvalho Chehab
41*151f4e2bSMauro Carvalho Chehab - if it doesn't come back up (which is usually the problem), reboot by
42*151f4e2bSMauro Carvalho Chehab   holding the power button down, and look at the dmesg output for things
43*151f4e2bSMauro Carvalho Chehab   like::
44*151f4e2bSMauro Carvalho Chehab
45*151f4e2bSMauro Carvalho Chehab	Magic number: 4:156:725
46*151f4e2bSMauro Carvalho Chehab	hash matches drivers/base/power/resume.c:28
47*151f4e2bSMauro Carvalho Chehab	hash matches device 0000:01:00.0
48*151f4e2bSMauro Carvalho Chehab
49*151f4e2bSMauro Carvalho Chehab   which means that the last trace event was just before trying to resume
50*151f4e2bSMauro Carvalho Chehab   device 0000:01:00.0. Then figure out what driver is controlling that
51*151f4e2bSMauro Carvalho Chehab   device (lspci and /sys/devices/pci* is your friend), and see if you can
52*151f4e2bSMauro Carvalho Chehab   fix it, disable it, or trace into its resume function.
53*151f4e2bSMauro Carvalho Chehab
54*151f4e2bSMauro Carvalho Chehab   If no device matches the hash (or any matches appear to be false positives),
55*151f4e2bSMauro Carvalho Chehab   the culprit may be a device from a loadable kernel module that is not loaded
56*151f4e2bSMauro Carvalho Chehab   until after the hash is checked. You can check the hash against the current
57*151f4e2bSMauro Carvalho Chehab   devices again after more modules are loaded using sysfs::
58*151f4e2bSMauro Carvalho Chehab
59*151f4e2bSMauro Carvalho Chehab	cat /sys/power/pm_trace_dev_match
60*151f4e2bSMauro Carvalho Chehab
61*151f4e2bSMauro Carvalho ChehabFor example, the above happens to be the VGA device on my EVO, which I
62*151f4e2bSMauro Carvalho Chehabused to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
63*151f4e2bSMauro Carvalho Chehabthat "radeonfb" simply cannot resume that device - it tries to set the
64*151f4e2bSMauro Carvalho ChehabPLL's, and it just _hangs_. Using the regular VGA console and letting X
65*151f4e2bSMauro Carvalho Chehabresume it instead works fine.
66*151f4e2bSMauro Carvalho Chehab
67*151f4e2bSMauro Carvalho ChehabNOTE
68*151f4e2bSMauro Carvalho Chehab====
69*151f4e2bSMauro Carvalho Chehabpm_trace uses the system's Real Time Clock (RTC) to save the magic number.
70*151f4e2bSMauro Carvalho ChehabReason for this is that the RTC is the only reliably available piece of
71*151f4e2bSMauro Carvalho Chehabhardware during resume operations where a value can be set that will
72*151f4e2bSMauro Carvalho Chehabsurvive a reboot.
73*151f4e2bSMauro Carvalho Chehab
74*151f4e2bSMauro Carvalho Chehabpm_trace is not compatible with asynchronous suspend, so it turns
75*151f4e2bSMauro Carvalho Chehabasynchronous suspend off (which may work around timing or
76*151f4e2bSMauro Carvalho Chehabordering-sensitive bugs).
77*151f4e2bSMauro Carvalho Chehab
78*151f4e2bSMauro Carvalho ChehabConsequence is that after a resume (even if it is successful) your system
79*151f4e2bSMauro Carvalho Chehabclock will have a value corresponding to the magic number instead of the
80*151f4e2bSMauro Carvalho Chehabcorrect date/time! It is therefore advisable to use a program like ntp-date
81*151f4e2bSMauro Carvalho Chehabor rdate to reset the correct date/time from an external time source when
82*151f4e2bSMauro Carvalho Chehabusing this trace option.
83*151f4e2bSMauro Carvalho Chehab
84*151f4e2bSMauro Carvalho ChehabAs the clock keeps ticking it is also essential that the reboot is done
85*151f4e2bSMauro Carvalho Chehabquickly after the resume failure. The trace option does not use the seconds
86*151f4e2bSMauro Carvalho Chehabor the low order bits of the minutes of the RTC, but a too long delay will
87*151f4e2bSMauro Carvalho Chehabcorrupt the magic value.
88