diff options
Diffstat (limited to 'Documentation/power')
-rw-r--r-- | Documentation/power/interface.txt | 13 | ||||
-rw-r--r-- | Documentation/power/pci.txt | 4 | ||||
-rw-r--r-- | Documentation/power/s2ram.txt | 56 | ||||
-rw-r--r-- | Documentation/power/states.txt | 2 | ||||
-rw-r--r-- | Documentation/power/swsusp-and-swap-files.txt | 60 | ||||
-rw-r--r-- | Documentation/power/swsusp.txt | 20 | ||||
-rw-r--r-- | Documentation/power/userland-swsusp.txt | 64 |
7 files changed, 189 insertions, 30 deletions
diff --git a/Documentation/power/interface.txt b/Documentation/power/interface.txt index a66bec222b16..74311d7e0f3c 100644 --- a/Documentation/power/interface.txt +++ b/Documentation/power/interface.txt | |||
@@ -30,6 +30,17 @@ testing). The system will support either 'firmware' or 'platform', and | |||
30 | that is known a priori. But, the user may choose 'shutdown' or | 30 | that is known a priori. But, the user may choose 'shutdown' or |
31 | 'reboot' as alternatives. | 31 | 'reboot' as alternatives. |
32 | 32 | ||
33 | Additionally, /sys/power/disk can be used to turn on one of the two testing | ||
34 | modes of the suspend-to-disk mechanism: 'testproc' or 'test'. If the | ||
35 | suspend-to-disk mechanism is in the 'testproc' mode, writing 'disk' to | ||
36 | /sys/power/state will cause the kernel to disable nonboot CPUs and freeze | ||
37 | tasks, wait for 5 seconds, unfreeze tasks and enable nonboot CPUs. If it is | ||
38 | in the 'test' mode, writing 'disk' to /sys/power/state will cause the kernel | ||
39 | to disable nonboot CPUs and freeze tasks, shrink memory, suspend devices, wait | ||
40 | for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then, | ||
41 | we are able to look in the log messages and work out, for example, which code | ||
42 | is being slow and which device drivers are misbehaving. | ||
43 | |||
33 | Reading from this file will display what the mode is currently set | 44 | Reading from this file will display what the mode is currently set |
34 | to. Writing to this file will accept one of | 45 | to. Writing to this file will accept one of |
35 | 46 | ||
@@ -37,6 +48,8 @@ to. Writing to this file will accept one of | |||
37 | 'platform' | 48 | 'platform' |
38 | 'shutdown' | 49 | 'shutdown' |
39 | 'reboot' | 50 | 'reboot' |
51 | 'testproc' | ||
52 | 'test' | ||
40 | 53 | ||
41 | It will only change to 'firmware' or 'platform' if the system supports | 54 | It will only change to 'firmware' or 'platform' if the system supports |
42 | it. | 55 | it. |
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt index 24edf25b3bb7..c750f9f2e76e 100644 --- a/Documentation/power/pci.txt +++ b/Documentation/power/pci.txt | |||
@@ -153,7 +153,7 @@ Description: | |||
153 | events, which is implicit if it doesn't even support it in the first | 153 | events, which is implicit if it doesn't even support it in the first |
154 | place). | 154 | place). |
155 | 155 | ||
156 | Note that the PMC Register in the device's PM Capabilties has a bitmask | 156 | Note that the PMC Register in the device's PM Capabilities has a bitmask |
157 | of the states it supports generating PME# from. D3hot is bit 3 and | 157 | of the states it supports generating PME# from. D3hot is bit 3 and |
158 | D3cold is bit 4. So, while a value of 4 as the state may not seem | 158 | D3cold is bit 4. So, while a value of 4 as the state may not seem |
159 | semantically correct, it is. | 159 | semantically correct, it is. |
@@ -268,7 +268,7 @@ to wake the system up. (However, it is possible that a device may support | |||
268 | some non-standard way of generating a wake event on sleep.) | 268 | some non-standard way of generating a wake event on sleep.) |
269 | 269 | ||
270 | Bits 15:11 of the PMC (Power Mgmt Capabilities) Register in a device's | 270 | Bits 15:11 of the PMC (Power Mgmt Capabilities) Register in a device's |
271 | PM Capabilties describe what power states the device supports generating a | 271 | PM Capabilities describe what power states the device supports generating a |
272 | wake event from: | 272 | wake event from: |
273 | 273 | ||
274 | +------------------+ | 274 | +------------------+ |
diff --git a/Documentation/power/s2ram.txt b/Documentation/power/s2ram.txt new file mode 100644 index 000000000000..b05f512130ea --- /dev/null +++ b/Documentation/power/s2ram.txt | |||
@@ -0,0 +1,56 @@ | |||
1 | How to get s2ram working | ||
2 | ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
3 | 2006 Linus Torvalds | ||
4 | 2006 Pavel Machek | ||
5 | |||
6 | 1) Check suspend.sf.net, program s2ram there has long whitelist of | ||
7 | "known ok" machines, along with tricks to use on each one. | ||
8 | |||
9 | 2) If that does not help, try reading tricks.txt and | ||
10 | video.txt. Perhaps problem is as simple as broken module, and | ||
11 | simple module unload can fix it. | ||
12 | |||
13 | 3) You can use Linus' TRACE_RESUME infrastructure, described below. | ||
14 | |||
15 | Using TRACE_RESUME | ||
16 | ~~~~~~~~~~~~~~~~~~ | ||
17 | |||
18 | I've been working at making the machines I have able to STR, and almost | ||
19 | always it's a driver that is buggy. Thank God for the suspend/resume | ||
20 | debugging - the thing that Chuck tried to disable. That's often the _only_ | ||
21 | way to debug these things, and it's actually pretty powerful (but | ||
22 | time-consuming - having to insert TRACE_RESUME() markers into the device | ||
23 | driver that doesn't resume and recompile and reboot). | ||
24 | |||
25 | Anyway, the way to debug this for people who are interested (have a | ||
26 | machine that doesn't boot) is: | ||
27 | |||
28 | - enable PM_DEBUG, and PM_TRACE | ||
29 | |||
30 | - use a script like this: | ||
31 | |||
32 | #!/bin/sh | ||
33 | sync | ||
34 | echo 1 > /sys/power/pm_trace | ||
35 | echo mem > /sys/power/state | ||
36 | |||
37 | to suspend | ||
38 | |||
39 | - if it doesn't come back up (which is usually the problem), reboot by | ||
40 | holding the power button down, and look at the dmesg output for things | ||
41 | like | ||
42 | |||
43 | Magic number: 4:156:725 | ||
44 | hash matches drivers/base/power/resume.c:28 | ||
45 | hash matches device 0000:01:00.0 | ||
46 | |||
47 | which means that the last trace event was just before trying to resume | ||
48 | device 0000:01:00.0. Then figure out what driver is controlling that | ||
49 | device (lspci and /sys/devices/pci* is your friend), and see if you can | ||
50 | fix it, disable it, or trace into its resume function. | ||
51 | |||
52 | For example, the above happens to be the VGA device on my EVO, which I | ||
53 | used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out | ||
54 | that "radeonfb" simply cannot resume that device - it tries to set the | ||
55 | PLL's, and it just _hangs_. Using the regular VGA console and letting X | ||
56 | resume it instead works fine. | ||
diff --git a/Documentation/power/states.txt b/Documentation/power/states.txt index 3e5e5d3ff419..0931a330d362 100644 --- a/Documentation/power/states.txt +++ b/Documentation/power/states.txt | |||
@@ -62,7 +62,7 @@ setup via another operating system for it to use. Despite the | |||
62 | inconvenience, this method requires minimal work by the kernel, since | 62 | inconvenience, this method requires minimal work by the kernel, since |
63 | the firmware will also handle restoring memory contents on resume. | 63 | the firmware will also handle restoring memory contents on resume. |
64 | 64 | ||
65 | If the kernel is responsible for persistantly saving state, a mechanism | 65 | If the kernel is responsible for persistently saving state, a mechanism |
66 | called 'swsusp' (Swap Suspend) is used to write memory contents to | 66 | called 'swsusp' (Swap Suspend) is used to write memory contents to |
67 | free swap space. swsusp has some restrictive requirements, but should | 67 | free swap space. swsusp has some restrictive requirements, but should |
68 | work in most cases. Some, albeit outdated, documentation can be found | 68 | work in most cases. Some, albeit outdated, documentation can be found |
diff --git a/Documentation/power/swsusp-and-swap-files.txt b/Documentation/power/swsusp-and-swap-files.txt new file mode 100644 index 000000000000..06f911a5f885 --- /dev/null +++ b/Documentation/power/swsusp-and-swap-files.txt | |||
@@ -0,0 +1,60 @@ | |||
1 | Using swap files with software suspend (swsusp) | ||
2 | (C) 2006 Rafael J. Wysocki <rjw@sisk.pl> | ||
3 | |||
4 | The Linux kernel handles swap files almost in the same way as it handles swap | ||
5 | partitions and there are only two differences between these two types of swap | ||
6 | areas: | ||
7 | (1) swap files need not be contiguous, | ||
8 | (2) the header of a swap file is not in the first block of the partition that | ||
9 | holds it. From the swsusp's point of view (1) is not a problem, because it is | ||
10 | already taken care of by the swap-handling code, but (2) has to be taken into | ||
11 | consideration. | ||
12 | |||
13 | In principle the location of a swap file's header may be determined with the | ||
14 | help of appropriate filesystem driver. Unfortunately, however, it requires the | ||
15 | filesystem holding the swap file to be mounted, and if this filesystem is | ||
16 | journaled, it cannot be mounted during resume from disk. For this reason to | ||
17 | identify a swap file swsusp uses the name of the partition that holds the file | ||
18 | and the offset from the beginning of the partition at which the swap file's | ||
19 | header is located. For convenience, this offset is expressed in <PAGE_SIZE> | ||
20 | units. | ||
21 | |||
22 | In order to use a swap file with swsusp, you need to: | ||
23 | |||
24 | 1) Create the swap file and make it active, eg. | ||
25 | |||
26 | # dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k> | ||
27 | # mkswap <swap_file_path> | ||
28 | # swapon <swap_file_path> | ||
29 | |||
30 | 2) Use an application that will bmap the swap file with the help of the | ||
31 | FIBMAP ioctl and determine the location of the file's swap header, as the | ||
32 | offset, in <PAGE_SIZE> units, from the beginning of the partition which | ||
33 | holds the swap file. | ||
34 | |||
35 | 3) Add the following parameters to the kernel command line: | ||
36 | |||
37 | resume=<swap_file_partition> resume_offset=<swap_file_offset> | ||
38 | |||
39 | where <swap_file_partition> is the partition on which the swap file is located | ||
40 | and <swap_file_offset> is the offset of the swap header determined by the | ||
41 | application in 2) (of course, this step may be carried out automatically | ||
42 | by the same application that determies the swap file's header offset using the | ||
43 | FIBMAP ioctl) | ||
44 | |||
45 | OR | ||
46 | |||
47 | Use a userland suspend application that will set the partition and offset | ||
48 | with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in | ||
49 | Documentation/power/userland-swsusp.txt (this is the only method to suspend | ||
50 | to a swap file allowing the resume to be initiated from an initrd or initramfs | ||
51 | image). | ||
52 | |||
53 | Now, swsusp will use the swap file in the same way in which it would use a swap | ||
54 | partition. In particular, the swap file has to be active (ie. be present in | ||
55 | /proc/swaps) so that it can be used for suspending. | ||
56 | |||
57 | Note that if the swap file used for suspending is deleted and recreated, | ||
58 | the location of its header need not be the same as before. Thus every time | ||
59 | this happens the value of the "resume_offset=" kernel command line parameter | ||
60 | has to be updated. | ||
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt index 9ea2208b43b5..0761ff6c57ed 100644 --- a/Documentation/power/swsusp.txt +++ b/Documentation/power/swsusp.txt | |||
@@ -153,7 +153,7 @@ add: | |||
153 | 153 | ||
154 | If the thread is needed for writing the image to storage, you should | 154 | If the thread is needed for writing the image to storage, you should |
155 | instead set the PF_NOFREEZE process flag when creating the thread (and | 155 | instead set the PF_NOFREEZE process flag when creating the thread (and |
156 | be very carefull). | 156 | be very careful). |
157 | 157 | ||
158 | 158 | ||
159 | Q: What is the difference between "platform", "shutdown" and | 159 | Q: What is the difference between "platform", "shutdown" and |
@@ -297,20 +297,12 @@ system is shut down or suspended. Additionally use the encrypted | |||
297 | suspend image to prevent sensitive data from being stolen after | 297 | suspend image to prevent sensitive data from being stolen after |
298 | resume. | 298 | resume. |
299 | 299 | ||
300 | Q: Why can't we suspend to a swap file? | 300 | Q: Can I suspend to a swap file? |
301 | 301 | ||
302 | A: Because accessing swap file needs the filesystem mounted, and | 302 | A: Generally, yes, you can. However, it requires you to use the "resume=" and |
303 | filesystem might do something wrong (like replaying the journal) | 303 | "resume_offset=" kernel command line parameters, so the resume from a swap file |
304 | during mount. | 304 | cannot be initiated from an initrd or initramfs image. See |
305 | 305 | swsusp-and-swap-files.txt for details. | |
306 | There are few ways to get that fixed: | ||
307 | |||
308 | 1) Probably could be solved by modifying every filesystem to support | ||
309 | some kind of "really read-only!" option. Patches welcome. | ||
310 | |||
311 | 2) suspend2 gets around that by storing absolute positions in on-disk | ||
312 | image (and blocksize), with resume parameter pointing directly to | ||
313 | suspend header. | ||
314 | 306 | ||
315 | Q: Is there a maximum system RAM size that is supported by swsusp? | 307 | Q: Is there a maximum system RAM size that is supported by swsusp? |
316 | 308 | ||
diff --git a/Documentation/power/userland-swsusp.txt b/Documentation/power/userland-swsusp.txt index 64755e9285db..000556c932e9 100644 --- a/Documentation/power/userland-swsusp.txt +++ b/Documentation/power/userland-swsusp.txt | |||
@@ -9,9 +9,8 @@ done it already. | |||
9 | Now, to use the userland interface for software suspend you need special | 9 | Now, to use the userland interface for software suspend you need special |
10 | utilities that will read/write the system memory snapshot from/to the | 10 | utilities that will read/write the system memory snapshot from/to the |
11 | kernel. Such utilities are available, for example, from | 11 | kernel. Such utilities are available, for example, from |
12 | <http://www.sisk.pl/kernel/utilities/suspend>. You may want to have | 12 | <http://suspend.sourceforge.net>. You may want to have a look at them if you |
13 | a look at them if you are going to develop your own suspend/resume | 13 | are going to develop your own suspend/resume utilities. |
14 | utilities. | ||
15 | 14 | ||
16 | The interface consists of a character device providing the open(), | 15 | The interface consists of a character device providing the open(), |
17 | release(), read(), and write() operations as well as several ioctl() | 16 | release(), read(), and write() operations as well as several ioctl() |
@@ -21,9 +20,9 @@ be read from /sys/class/misc/snapshot/dev. | |||
21 | 20 | ||
22 | The device can be open either for reading or for writing. If open for | 21 | The device can be open either for reading or for writing. If open for |
23 | reading, it is considered to be in the suspend mode. Otherwise it is | 22 | reading, it is considered to be in the suspend mode. Otherwise it is |
24 | assumed to be in the resume mode. The device cannot be open for reading | 23 | assumed to be in the resume mode. The device cannot be open for simultaneous |
25 | and writing. It is also impossible to have the device open more than once | 24 | reading and writing. It is also impossible to have the device open more than |
26 | at a time. | 25 | once at a time. |
27 | 26 | ||
28 | The ioctl() commands recognized by the device are: | 27 | The ioctl() commands recognized by the device are: |
29 | 28 | ||
@@ -69,9 +68,46 @@ SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with | |||
69 | SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument | 68 | SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument |
70 | should specify the device's major and minor numbers in the old | 69 | should specify the device's major and minor numbers in the old |
71 | two-byte format, as returned by the stat() function in the .st_rdev | 70 | two-byte format, as returned by the stat() function in the .st_rdev |
72 | member of the stat structure); it is recommended to always use this | 71 | member of the stat structure) |
73 | call, because the code to set the resume partition could be removed from | 72 | |
74 | future kernels | 73 | SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in <PAGE_SIZE> |
74 | units) from the beginning of the partition at which the swap header is | ||
75 | located (the last ioctl() argument should point to a struct | ||
76 | resume_swap_area, as defined in kernel/power/power.h, containing the | ||
77 | resume device specification, as for the SNAPSHOT_SET_SWAP_FILE ioctl(), | ||
78 | and the offset); for swap partitions the offset is always 0, but it is | ||
79 | different to zero for swap files (please see | ||
80 | Documentation/swsusp-and-swap-files.txt for details). | ||
81 | The SNAPSHOT_SET_SWAP_AREA ioctl() is considered as a replacement for | ||
82 | SNAPSHOT_SET_SWAP_FILE which is regarded as obsolete. It is | ||
83 | recommended to always use this call, because the code to set the resume | ||
84 | partition may be removed from future kernels | ||
85 | |||
86 | SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to | ||
87 | immediately enter the suspend-to-RAM state, so this call must always | ||
88 | be preceded by the SNAPSHOT_FREEZE call and it is also necessary | ||
89 | to use the SNAPSHOT_UNFREEZE call after the system wakes up. This call | ||
90 | is needed to implement the suspend-to-both mechanism in which the | ||
91 | suspend image is first created, as though the system had been suspended | ||
92 | to disk, and then the system is suspended to RAM (this makes it possible | ||
93 | to resume the system from RAM if there's enough battery power or restore | ||
94 | its state on the basis of the saved suspend image otherwise) | ||
95 | |||
96 | SNAPSHOT_PMOPS - enable the usage of the pmops->prepare, pmops->enter and | ||
97 | pmops->finish methods (the in-kernel swsusp knows these as the "platform | ||
98 | method") which are needed on many machines to (among others) speed up | ||
99 | the resume by letting the BIOS skip some steps or to let the system | ||
100 | recognise the correct state of the hardware after the resume (in | ||
101 | particular on many machines this ensures that unplugged AC | ||
102 | adapters get correctly detected and that kacpid does not run wild after | ||
103 | the resume). The last ioctl() argument can take one of the three | ||
104 | values, defined in kernel/power/power.h: | ||
105 | PMOPS_PREPARE - make the kernel carry out the | ||
106 | pm_ops->prepare(PM_SUSPEND_DISK) operation | ||
107 | PMOPS_ENTER - make the kernel power off the system by calling | ||
108 | pm_ops->enter(PM_SUSPEND_DISK) | ||
109 | PMOPS_FINISH - make the kernel carry out the | ||
110 | pm_ops->finish(PM_SUSPEND_DISK) operation | ||
75 | 111 | ||
76 | The device's read() operation can be used to transfer the snapshot image from | 112 | The device's read() operation can be used to transfer the snapshot image from |
77 | the kernel. It has the following limitations: | 113 | the kernel. It has the following limitations: |
@@ -91,10 +127,12 @@ unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are | |||
91 | still frozen when the device is being closed). | 127 | still frozen when the device is being closed). |
92 | 128 | ||
93 | Currently it is assumed that the userland utilities reading/writing the | 129 | Currently it is assumed that the userland utilities reading/writing the |
94 | snapshot image from/to the kernel will use a swap partition, called the resume | 130 | snapshot image from/to the kernel will use a swap parition, called the resume |
95 | partition, as storage space. However, this is not really required, as they | 131 | partition, or a swap file as storage space (if a swap file is used, the resume |
96 | can use, for example, a special (blank) suspend partition or a file on a partition | 132 | partition is the partition that holds this file). However, this is not really |
97 | that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and mounted afterwards. | 133 | required, as they can use, for example, a special (blank) suspend partition or |
134 | a file on a partition that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and | ||
135 | mounted afterwards. | ||
98 | 136 | ||
99 | These utilities SHOULD NOT make any assumptions regarding the ordering of | 137 | These utilities SHOULD NOT make any assumptions regarding the ordering of |
100 | data within the snapshot image, except for the image header that MAY be | 138 | data within the snapshot image, except for the image header that MAY be |