← Documents Documentation/power/s2ram.rst GitHub 원문 ↗

Linux 6.18.37 · Power

How to get s2ram working

Suspend-to-RAM 실패를 whitelist, module 점검, TRACE_RESUME와 RTC magic number로 진단하는 절차입니다.

Source pathDocumentation/power/s2ram.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

s2ram.rst:1-87

Suspend-to-RAM 실패를 whitelist, module 점검, TRACE_RESUME와 RTC magic number로 진단하는 절차입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

s2ram 문제의 첫 점검

1-16

이 문서는 Linus Torvalds와 Pavel Machek가 정리한 suspend-to-RAM(s2ram) 진단 절차입니다. 먼저 `suspend.sf.net`의 s2ram program이 제공하는 정상 동작 machine whitelist와 machine별 우회법을 확인합니다.

해결되지 않으면 `tricks.txt`와 `video.txt`를 읽습니다. 고장 난 module 하나가 원인이라 단순히 unload하는 것만으로 해결될 수 있습니다. 마지막으로 아래의 Linus `TRACE_RESUME` infrastructure로 resume 실패 지점을 추적합니다.

s2ram 진단 순서
suspend.sf.net whitelisttricks.txt + video.txtsuspect module unloadTRACE_RESUME instrumentation

가벼운 호환성 확인에서 driver 내부 추적 순으로 범위를 좁힙니다.

========================
How to get s2ram working
========================

2006 Linus Torvalds
2006 Pavel Machek

1) Check suspend.sf.net, program s2ram there has long whitelist of
   "known ok" machines, along with tricks to use on each one.

2) If that does not help, try reading tricks.txt and
   video.txt. Perhaps problem is as simple as broken module, and
   simple module unload can fix it.

3) You can use Linus' TRACE_RESUME infrastructure, described below.

TRACE_RESUME 사용법

17-66

STR 실패는 대개 buggy driver이며 suspend/resume debugging이 유일한 진단 수단인 경우가 많습니다. 강력하지만 resume하지 못하는 driver에 `TRACE_RESUME()` marker를 넣고 compile과 reboot를 반복해야 하므로 시간이 듭니다.

`PM_DEBUG`와 `PM_TRACE`를 enable한 뒤 script에서 `sync`, `echo 1 > /sys/power/pm_trace`, `echo mem > /sys/power/state`를 차례로 실행해 suspend합니다.

Resume하지 못하면 전원 버튼으로 빠르게 reboot하고 `dmesg`의 magic number와 hash match를 확인합니다. 예제의 마지막 trace event는 `0000:01:00.0` device resume 직전입니다. `lspci`와 `/sys/devices/pci*`로 driver를 찾아 수정·disable하거나 resume function 내부에 marker를 더 넣습니다.

Hash와 일치하는 device가 없거나 false positive라면 hash 검사 뒤에 load되는 kernel module의 device일 수 있습니다. Module을 더 load한 후 `cat /sys/power/pm_trace_dev_match`로 현재 device에 다시 대조합니다.

문서의 EVO 예제에서는 ATI Radeon mobility VGA를 다루던 `radeonfb`가 PLL 설정 중 hang되어 resume하지 못했습니다. Regular VGA console을 쓰고 X가 resume하도록 하자 정상 동작했습니다.

TRACE_RESUME 결과 해석
관찰다음 조치
device hash matchlspci와 sysfs로 driver 식별
match 없음module load 후 pm_trace_dev_match 재검사
resume function에서 hangmarker를 더 세분화하거나 driver disable/수정

마지막 marker에서 문제 driver를 좁혀 갑니다.

Using TRACE_RESUME
~~~~~~~~~~~~~~~~~~

I've been working at making the machines I have able to STR, and almost
always it's a driver that is buggy. Thank God for the suspend/resume
debugging - the thing that Chuck tried to disable. That's often the _only_
way to debug these things, and it's actually pretty powerful (but
time-consuming - having to insert TRACE_RESUME() markers into the device
driver that doesn't resume and recompile and reboot).

Anyway, the way to debug this for people who are interested (have a
machine that doesn't boot) is:

 - enable PM_DEBUG, and PM_TRACE

 - use a script like this::

        #!/bin/sh
        sync
        echo 1 > /sys/power/pm_trace
        echo mem > /sys/power/state

   to suspend

 - if it doesn't come back up (which is usually the problem), reboot by
   holding the power button down, and look at the dmesg output for things
   like::

        Magic number: 4:156:725
        hash matches drivers/base/power/resume.c:28
        hash matches device 0000:01:00.0

   which means that the last trace event was just before trying to resume
   device 0000:01:00.0. Then figure out what driver is controlling that
   device (lspci and /sys/devices/pci* is your friend), and see if you can
   fix it, disable it, or trace into its resume function.

   If no device matches the hash (or any matches appear to be false positives),
   the culprit may be a device from a loadable kernel module that is not loaded
   until after the hash is checked. You can check the hash against the current
   devices again after more modules are loaded using sysfs::

        cat /sys/power/pm_trace_dev_match

For example, the above happens to be the VGA device on my EVO, which I
used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
that "radeonfb" simply cannot resume that device - it tries to set the
PLL's, and it just _hangs_. Using the regular VGA console and letting X
resume it instead works fine.

pm_trace의 RTC 제약

67-87

`pm_trace`는 reboot 뒤에도 값을 보존하면서 resume 중 확실히 사용할 수 있는 hardware가 RTC(Real Time Clock)뿐이므로 magic number를 system RTC에 저장합니다.

`pm_trace`는 asynchronous suspend와 호환되지 않아 이를 끕니다. 따라서 timing 또는 ordering bug가 우연히 가려질 수도 있습니다.

Resume이 성공해도 system clock에는 올바른 날짜·시간 대신 magic number에 대응하는 값이 남습니다. `ntp-date`나 `rdate`로 외부 time source에서 시간을 복원해야 합니다. RTC는 계속 진행하므로 실패 뒤 reboot도 빨리 해야 하며, 너무 늦으면 seconds와 minute 하위 bit를 쓰지 않더라도 magic value가 손상됩니다.

pm_trace 부작용
영향대응
RTC 시간 손상ntp-date 또는 rdate로 복구
Async suspend offtiming/order bug가 가려질 수 있음
reboot 지연magic value 손상 전에 빠르게 reboot

진단 성공 여부와 무관하게 RTC와 suspend timing에 영향을 줍니다.

NOTE
====
pm_trace uses the system's Real Time Clock (RTC) to save the magic number.
Reason for this is that the RTC is the only reliably available piece of
hardware during resume operations where a value can be set that will
survive a reboot.

pm_trace is not compatible with asynchronous suspend, so it turns
asynchronous suspend off (which may work around timing or
ordering-sensitive bugs).

Consequence is that after a resume (even if it is successful) your system
clock will have a value corresponding to the magic number instead of the
correct date/time! It is therefore advisable to use a program like ntp-date
or rdate to reset the correct date/time from an external time source when
using this trace option.

As the clock keeps ticking it is also essential that the reboot is done
quickly after the resume failure. The trace option does not use the seconds
or the low order bits of the minutes of the RTC, but a too long delay will
corrupt the magic value.