aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-02-01 22:29:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-02-01 22:29:57 -0500
commit687fcdf741e4a268c2c7bac8b3734de761bb9719 (patch)
tree82603cd0f892b13d4252cc525ecaec99bb86c0cd /Documentation
parent215e871aaa3d94540121a3809d80d0c5e5686e4f (diff)
parenta6eb84bc1e069e1d285167e09035ed6c27978feb (diff)
Merge branch 'suspend' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'suspend' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (38 commits) suspend: cleanup reference to swsusp_pg_dir[] PM: Remove obsolete /sys/devices/.../power/state docs Hibernation: Invoke suspend notifications after console switch Suspend: Invoke suspend notifications after console switch Suspend: Clean up suspend_64.c Suspend: Add config option to disable the freezer if architecture wants that ACPI: Print message before calling _PTS ACPI hibernation: Call _PTS before suspending devices Hibernation: Introduce begin() and end() callbacks ACPI suspend: Call _PTS before suspending devices ACPI: Separate disabling of GPEs from _PTS ACPI: Separate invocations of _GTS and _BFS from _PTS and _WAK Suspend: Introduce begin() and end() callbacks suspend: fix ia64 allmodconfig build ACPI: clear GPE earily in resume to avoid warning Suspend: Clean up Kconfig (V2) Hibernation: Clean up Kconfig (V2) Hibernation: Update messages Suspend: Use common prefix in messages Hibernation: Remove unnecessary variable declaration ...
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/kernel-parameters.txt5
-rw-r--r--Documentation/power/basic-pm-debugging.txt216
-rw-r--r--Documentation/power/devices.txt49
-rw-r--r--Documentation/power/drivers-testing.txt30
-rw-r--r--Documentation/power/notifiers.txt8
-rw-r--r--Documentation/power/userland-swsusp.txt82
6 files changed, 216 insertions, 174 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 92c40d174355..cf3868956f1e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -168,6 +168,11 @@ and is between 256 and 4096 characters. It is defined in the file
168 acpi_irq_isa= [HW,ACPI] If irq_balance, mark listed IRQs used by ISA 168 acpi_irq_isa= [HW,ACPI] If irq_balance, mark listed IRQs used by ISA
169 Format: <irq>,<irq>... 169 Format: <irq>,<irq>...
170 170
171 acpi_new_pts_ordering [HW,ACPI]
172 Enforce the ACPI 2.0 ordering of the _PTS control
173 method wrt putting devices into low power states
174 default: pre ACPI 2.0 ordering of _PTS
175
171 acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT 176 acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT
172 177
173 acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS 178 acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS
diff --git a/Documentation/power/basic-pm-debugging.txt b/Documentation/power/basic-pm-debugging.txt
index 57aef2f6e0de..1555001bc733 100644
--- a/Documentation/power/basic-pm-debugging.txt
+++ b/Documentation/power/basic-pm-debugging.txt
@@ -1,45 +1,111 @@
1Debugging suspend and resume 1Debugging hibernation and suspend
2 (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL 2 (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL
3 3
41. Testing suspend to disk (STD) 41. Testing hibernation (aka suspend to disk or STD)
5 5
6To verify that the STD works, you can try to suspend in the "reboot" mode: 6To check if hibernation works, you can try to hibernate in the "reboot" mode:
7 7
8# echo reboot > /sys/power/disk 8# echo reboot > /sys/power/disk
9# echo disk > /sys/power/state 9# echo disk > /sys/power/state
10 10
11and the system should suspend, reboot, resume and get back to the command prompt 11and the system should create a hibernation image, reboot, resume and get back to
12where you have started the transition. If that happens, the STD is most likely 12the command prompt where you have started the transition. If that happens,
13to work correctly, but you need to repeat the test at least a couple of times in 13hibernation is most likely to work correctly. Still, you need to repeat the
14a row for confidence. This is necessary, because some problems only show up on 14test at least a couple of times in a row for confidence. [This is necessary,
15a second attempt at suspending and resuming the system. You should also test 15because some problems only show up on a second attempt at suspending and
16the "platform" and "shutdown" modes of suspend: 16resuming the system.] Moreover, hibernating in the "reboot" and "shutdown"
17modes causes the PM core to skip some platform-related callbacks which on ACPI
18systems might be necessary to make hibernation work. Thus, if you machine fails
19to hibernate or resume in the "reboot" mode, you should try the "platform" mode:
17 20
18# echo platform > /sys/power/disk 21# echo platform > /sys/power/disk
19# echo disk > /sys/power/state 22# echo disk > /sys/power/state
20 23
21or 24which is the default and recommended mode of hibernation.
25
26Unfortunately, the "platform" mode of hibernation does not work on some systems
27with broken BIOSes. In such cases the "shutdown" mode of hibernation might
28work:
22 29
23# echo shutdown > /sys/power/disk 30# echo shutdown > /sys/power/disk
24# echo disk > /sys/power/state 31# echo disk > /sys/power/state
25 32
26in which cases you will have to press the power button to make the system 33(it is similar to the "reboot" mode, but it requires you to press the power
27resume. If that does not work, you will need to identify what goes wrong. 34button to make the system resume).
35
36If neither "platform" nor "shutdown" hibernation mode works, you will need to
37identify what goes wrong.
38
39a) Test modes of hibernation
40
41To find out why hibernation fails on your system, you can use a special testing
42facility available if the kernel is compiled with CONFIG_PM_DEBUG set. Then,
43there is the file /sys/power/pm_test that can be used to make the hibernation
44core run in a test mode. There are 5 test modes available:
45
46freezer
47- test the freezing of processes
48
49devices
50- test the freezing of processes and suspending of devices
28 51
29a) Test mode of STD 52platform
53- test the freezing of processes, suspending of devices and platform
54 global control methods(*)
30 55
31To verify if there are any drivers that cause problems you can run the STD 56processors
32in the test mode: 57- test the freezing of processes, suspending of devices, platform
58 global control methods(*) and the disabling of nonboot CPUs
33 59
34# echo test > /sys/power/disk 60core
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
64
65(*) the platform global control methods are only available on ACPI systems
66 and are only tested if the hibernation mode is set to "platform"
67
68To use one of them it is necessary to write the corresponding string to
69/sys/power/pm_test (eg. "devices" to test the freezing of processes and
70suspending devices) and issue the standard hibernation commands. For example,
71to use the "devices" test mode along with the "platform" mode of hibernation,
72you should do the following:
73
74# echo devices > /sys/power/pm_test
75# echo platform > /sys/power/disk
35# echo disk > /sys/power/state 76# echo disk > /sys/power/state
36 77
37in which case the system should freeze tasks, suspend devices, disable nonboot 78Then, the kernel will try to freeze processes, suspend devices, wait 5 seconds,
38CPUs (if any), wait for 5 seconds, enable nonboot CPUs, resume devices, thaw 79resume devices and thaw processes. If "platform" is written to
39tasks and return to your command prompt. If that fails, most likely there is 80/sys/power/pm_test , then after suspending devices the kernel will additionally
40a driver that fails to either suspend or resume (in the latter case the system 81invoke the global control methods (eg. ACPI global control methods) used to
41may hang or be unstable after the test, so please take that into consideration). 82prepare the platform firmware for hibernation. Next, it will wait 5 seconds and
42To find this driver, you can carry out a binary search according to the rules: 83invoke the platform (eg. ACPI) global methods used to cancel hibernation etc.
84
85Writing "none" to /sys/power/pm_test causes the kernel to switch to the normal
86hibernation/suspend operations. Also, when open for reading, /sys/power/pm_test
87contains a space-separated list of all available tests (including "none" that
88represents the normal functionality) in which the current test level is
89indicated by square brackets.
90
91Generally, as you can see, each test level is more "invasive" than the previous
92one and the "core" level tests the hardware and drivers as deeply as possible
93without creating a hibernation image. Obviously, if the "devices" test fails,
94the "platform" test will fail as well and so on. Thus, as a rule of thumb, you
95should try the test modes starting from "freezer", through "devices", "platform"
96and "processors" up to "core" (repeat the test on each level a couple of times
97to make sure that any random factors are avoided).
98
99If the "freezer" test fails, there is a task that cannot be frozen (in that case
100it usually is possible to identify the offending task by analysing the output of
101dmesg obtained after the failing test). Failure at this level usually means
102that there is a problem with the tasks freezer subsystem that should be
103reported.
104
105If the "devices" test fails, most likely there is a driver that cannot suspend
106or resume its device (in the latter case the system may hang or become unstable
107after the test, so please take that into consideration). To find this driver,
108you can carry out a binary search according to the rules:
43- if the test fails, unload a half of the drivers currently loaded and repeat 109- if the test fails, unload a half of the drivers currently loaded and repeat
44(that would probably involve rebooting the system, so always note what drivers 110(that would probably involve rebooting the system, so always note what drivers
45have been loaded before the test), 111have been loaded before the test),
@@ -47,23 +113,46 @@ have been loaded before the test),
47recently and repeat. 113recently and repeat.
48 114
49Once you have found the failing driver (there can be more than just one of 115Once you have found the failing driver (there can be more than just one of
50them), you have to unload it every time before the STD transition. In that case 116them), you have to unload it every time before hibernation. In that case please
51please make sure to report the problem with the driver. 117make sure to report the problem with the driver.
52 118
53It is also possible that a cycle can still fail after you have unloaded 119It is also possible that the "devices" test will still fail after you have
54all modules. In that case, you would want to look in your kernel configuration 120unloaded all modules. In that case, you may want to look in your kernel
55for the drivers that can be compiled as modules (testing again with them as 121configuration for the drivers that can be compiled as modules (and test again
56modules), and possibly also try boot time options such as "noapic" or "noacpi". 122with these drivers compiled as modules). You may also try to use some special
123kernel command line options such as "noapic", "noacpi" or even "acpi=off".
124
125If the "platform" test fails, there is a problem with the handling of the
126platform (eg. ACPI) firmware on your system. In that case the "platform" mode
127of hibernation is not likely to work. You can try the "shutdown" mode, but that
128is rather a poor man's workaround.
129
130If the "processors" test fails, the disabling/enabling of nonboot CPUs does not
131work (of course, this only may be an issue on SMP systems) and the problem
132should be reported. In that case you can also try to switch the nonboot CPUs
133off and on using the /sys/devices/system/cpu/cpu*/online sysfs attributes and
134see if that works.
135
136If the "core" test fails, which means that suspending of the system/platform
137devices has failed (these devices are suspended on one CPU with interrupts off),
138the problem is most probably hardware-related and serious, so it should be
139reported.
140
141A failure of any of the "platform", "processors" or "core" tests may cause your
142system to hang or become unstable, so please beware. Such a failure usually
143indicates a serious problem that very well may be related to the hardware, but
144please report it anyway.
57 145
58b) Testing minimal configuration 146b) Testing minimal configuration
59 147
60If the test mode of STD works, you can boot the system with "init=/bin/bash" 148If all of the hibernation test modes work, you can boot the system with the
61and attempt to suspend in the "reboot", "shutdown" and "platform" modes. If 149"init=/bin/bash" command line parameter and attempt to hibernate in the
62that does not work, there probably is a problem with a driver statically 150"reboot", "shutdown" and "platform" modes. If that does not work, there
63compiled into the kernel and you can try to compile more drivers as modules, 151probably is a problem with a driver statically compiled into the kernel and you
64so that they can be tested individually. Otherwise, there is a problem with a 152can try to compile more drivers as modules, so that they can be tested
65modular driver and you can find it by loading a half of the modules you normally 153individually. Otherwise, there is a problem with a modular driver and you can
66use and binary searching in accordance with the algorithm: 154find it by loading a half of the modules you normally use and binary searching
155in accordance with the algorithm:
67- if there are n modules loaded and the attempt to suspend and resume fails, 156- if there are n modules loaded and the attempt to suspend and resume fails,
68unload n/2 of the modules and try again (that would probably involve rebooting 157unload n/2 of the modules and try again (that would probably involve rebooting
69the system), 158the system),
@@ -71,19 +160,19 @@ the system),
71load n/2 modules more and try again. 160load n/2 modules more and try again.
72 161
73Again, if you find the offending module(s), it(they) must be unloaded every time 162Again, if you find the offending module(s), it(they) must be unloaded every time
74before the STD transition, and please report the problem with it(them). 163before hibernation, and please report the problem with it(them).
75 164
76c) Advanced debugging 165c) Advanced debugging
77 166
78In case the STD does not work on your system even in the minimal configuration 167In case that hibernation does not work on your system even in the minimal
79and compiling more drivers as modules is not practical or some modules cannot 168configuration and compiling more drivers as modules is not practical or some
80be unloaded, you can use one of the more advanced debugging techniques to find 169modules cannot be unloaded, you can use one of the more advanced debugging
81the problem. First, if there is a serial port in your box, you can boot the 170techniques to find the problem. First, if there is a serial port in your box,
82kernel with the 'no_console_suspend' parameter and try to log kernel 171you can boot the kernel with the 'no_console_suspend' parameter and try to log
83messages using the serial console. This may provide you with some information 172kernel messages using the serial console. This may provide you with some
84about the reasons of the suspend (resume) failure. Alternatively, it may be 173information about the reasons of the suspend (resume) failure. Alternatively,
85possible to use a FireWire port for debugging with firescope 174it may be possible to use a FireWire port for debugging with firescope
86(ftp://ftp.firstfloor.org/pub/ak/firescope/). On i386 it is also possible to 175(ftp://ftp.firstfloor.org/pub/ak/firescope/). On x86 it is also possible to
87use the PM_TRACE mechanism documented in Documentation/s2ram.txt . 176use the PM_TRACE mechanism documented in Documentation/s2ram.txt .
88 177
892. Testing suspend to RAM (STR) 1782. Testing suspend to RAM (STR)
@@ -91,16 +180,25 @@ use the PM_TRACE mechanism documented in Documentation/s2ram.txt .
91To verify that the STR works, it is generally more convenient to use the s2ram 180To verify that the STR works, it is generally more convenient to use the s2ram
92tool available from http://suspend.sf.net and documented at 181tool available from http://suspend.sf.net and documented at
93http://en.opensuse.org/s2ram . However, before doing that it is recommended to 182http://en.opensuse.org/s2ram . However, before doing that it is recommended to
94carry out the procedure described in section 1. 183carry out STR testing using the facility described in section 1.
95 184
96Assume you have resolved the problems with the STD and you have found some 185Namely, after writing "freezer", "devices", "platform", "processors", or "core"
97failing drivers. These drivers are also likely to fail during the STR or 186into /sys/power/pm_test (available if the kernel is compiled with
98during the resume, so it is better to unload them every time before the STR 187CONFIG_PM_DEBUG set) the suspend code will work in the test mode corresponding
99transition. Now, you can follow the instructions at 188to given string. The STR test modes are defined in the same way as for
100http://en.opensuse.org/s2ram to test the system, but if it does not work 189hibernation, so please refer to Section 1 for more information about them. In
101"out of the box", you may need to boot it with "init=/bin/bash" and test 190particular, the "core" test allows you to test everything except for the actual
102s2ram in the minimal configuration. In that case, you may be able to search 191invocation of the platform firmware in order to put the system into the sleep
103for failing drivers by following the procedure analogous to the one described in 192state.
1041b). If you find some failing drivers, you will have to unload them every time 193
105before the STR transition (ie. before you run s2ram), and please report the 194Among other things, the testing with the help of /sys/power/pm_test may allow
106problems with them. 195you to identify drivers that fail to suspend or resume their devices. They
196should be unloaded every time before an STR transition.
197
198Next, you can follow the instructions at http://en.opensuse.org/s2ram to test
199the system, but if it does not work "out of the box", you may need to boot it
200with "init=/bin/bash" and test s2ram in the minimal configuration. In that
201case, you may be able to search for failing drivers by following the procedure
202analogous to the one described in section 1. If you find some failing drivers,
203you will have to unload them every time before an STR transition (ie. before
204you run s2ram), and please report the problems with them.
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
index d0e79d5820a5..c53d26361919 100644
--- a/Documentation/power/devices.txt
+++ b/Documentation/power/devices.txt
@@ -502,52 +502,3 @@ If the CPU can have a "cpufreq" driver, there also may be opportunities
502to shift to lower voltage settings and reduce the power cost of executing 502to shift to lower voltage settings and reduce the power cost of executing
503a given number of instructions. (Without voltage adjustment, it's rare 503a given number of instructions. (Without voltage adjustment, it's rare
504for cpufreq to save much power; the cost-per-instruction must go down.) 504for cpufreq to save much power; the cost-per-instruction must go down.)
505
506
507/sys/devices/.../power/state files
508==================================
509For now you can also test some of this functionality using sysfs.
510
511 DEPRECATED: USE "power/state" ONLY FOR DRIVER TESTING, AND
512 AVOID USING dev->power.power_state IN DRIVERS.
513
514 THESE WILL BE REMOVED. IF THE "power/state" FILE GETS REPLACED,
515 IT WILL BECOME SOMETHING COUPLED TO THE BUS OR DRIVER.
516
517In each device's directory, there is a 'power' directory, which contains
518at least a 'state' file. The value of this field is effectively boolean,
519PM_EVENT_ON or PM_EVENT_SUSPEND.
520
521 * Reading from this file displays a value corresponding to
522 the power.power_state.event field. All nonzero values are
523 displayed as "2", corresponding to a low power state; zero
524 is displayed as "0", corresponding to normal operation.
525
526 * Writing to this file initiates a transition using the
527 specified event code number; only '0', '2', and '3' are
528 accepted (without a newline); '2' and '3' are both
529 mapped to PM_EVENT_SUSPEND.
530
531On writes, the PM core relies on that recorded event code and the device/bus
532capabilities to determine whether it uses a partial suspend() or resume()
533sequence to change things so that the recorded event corresponds to the
534numeric parameter.
535
536 - If the bus requires the irqs-disabled suspend_late()/resume_early()
537 phases, writes fail because those operations are not supported here.
538
539 - If the recorded value is the expected value, nothing is done.
540
541 - If the recorded value is nonzero, the device is partially resumed,
542 using the bus.resume() and/or class.resume() methods.
543
544 - If the target value is nonzero, the device is partially suspended,
545 using the class.suspend() and/or bus.suspend() methods and the
546 PM_EVENT_SUSPEND message.
547
548Drivers have no way to tell whether their suspend() and resume() calls
549have come through the sysfs power/state file or as part of entering a
550system sleep state, except that when accessed through sysfs the normal
551parent/child sequencing rules are ignored. Drivers (such as bus, bridge,
552or hub drivers) which expose child devices may need to enforce those rules
553on their own.
diff --git a/Documentation/power/drivers-testing.txt b/Documentation/power/drivers-testing.txt
index e4bdcaee24e4..7f7a737f7f9f 100644
--- a/Documentation/power/drivers-testing.txt
+++ b/Documentation/power/drivers-testing.txt
@@ -6,9 +6,9 @@ Testing suspend and resume support in device drivers
6Unfortunately, to effectively test the support for the system-wide suspend and 6Unfortunately, to effectively test the support for the system-wide suspend and
7resume transitions in a driver, it is necessary to suspend and resume a fully 7resume transitions in a driver, it is necessary to suspend and resume a fully
8functional system with this driver loaded. Moreover, that should be done 8functional system with this driver loaded. Moreover, that should be done
9several times, preferably several times in a row, and separately for the suspend 9several times, preferably several times in a row, and separately for hibernation
10to disk (STD) and the suspend to RAM (STR) transitions, because each of these 10(aka suspend to disk or STD) and suspend to RAM (STR), because each of these
11cases involves different ordering of operations and different interactions with 11cases involves slightly different operations and different interactions with
12the machine's BIOS. 12the machine's BIOS.
13 13
14Of course, for this purpose the test system has to be known to suspend and 14Of course, for this purpose the test system has to be known to suspend and
@@ -22,20 +22,24 @@ for more information about the debugging of suspend/resume functionality.
22Once you have resolved the suspend/resume-related problems with your test system 22Once you have resolved the suspend/resume-related problems with your test system
23without the new driver, you are ready to test it: 23without the new driver, you are ready to test it:
24 24
25a) Build the driver as a module, load it and try the STD in the test mode (see: 25a) Build the driver as a module, load it and try the test modes of hibernation
26Documents/power/basic-pm-debugging.txt, 1a)). 26 (see: Documents/power/basic-pm-debugging.txt, 1).
27 27
28b) Load the driver and attempt to suspend to disk in the "reboot", "shutdown" 28b) Load the driver and attempt to hibernate in the "reboot", "shutdown" and
29and "platform" modes (see: Documents/power/basic-pm-debugging.txt, 1). 29 "platform" modes (see: Documents/power/basic-pm-debugging.txt, 1).
30 30
31c) Compile the driver directly into the kernel and try the STD in the test mode. 31c) Compile the driver directly into the kernel and try the test modes of
32 hibernation.
32 33
33d) Attempt to suspend to disk with the driver compiled directly into the kernel 34d) Attempt to hibernate with the driver compiled directly into the kernel
34in the "reboot", "shutdown" and "platform" modes. 35 in the "reboot", "shutdown" and "platform" modes.
35 36
36e) Attempt to suspend to RAM using the s2ram tool with the driver loaded (see: 37e) Try the test modes of suspend (see: Documents/power/basic-pm-debugging.txt,
37Documents/power/basic-pm-debugging.txt, 2). As far as the STR tests are 38 2). [As far as the STR tests are concerned, it should not matter whether or
38concerned, it should not matter whether or not the driver is built as a module. 39 not the driver is built as a module.]
40
41f) Attempt to suspend to RAM using the s2ram tool with the driver loaded
42 (see: Documents/power/basic-pm-debugging.txt, 2).
39 43
40Each of the above tests should be repeated several times and the STD tests 44Each of the above tests should be repeated several times and the STD tests
41should be mixed with the STR tests. If any of them fails, the driver cannot be 45should be mixed with the STR tests. If any of them fails, the driver cannot be
diff --git a/Documentation/power/notifiers.txt b/Documentation/power/notifiers.txt
index 9293e4bc857c..ae1b7ec07684 100644
--- a/Documentation/power/notifiers.txt
+++ b/Documentation/power/notifiers.txt
@@ -28,6 +28,14 @@ PM_POST_HIBERNATION The system memory state has been restored from a
28 hibernation. Device drivers' .resume() callbacks have 28 hibernation. Device drivers' .resume() callbacks have
29 been executed and tasks have been thawed. 29 been executed and tasks have been thawed.
30 30
31PM_RESTORE_PREPARE The system is going to restore a hibernation image.
32 If all goes well the restored kernel will issue a
33 PM_POST_HIBERNATION notification.
34
35PM_POST_RESTORE An error occurred during the hibernation restore.
36 Device drivers' .resume() callbacks have been executed
37 and tasks have been thawed.
38
31PM_SUSPEND_PREPARE The system is preparing for a suspend. 39PM_SUSPEND_PREPARE The system is preparing for a suspend.
32 40
33PM_POST_SUSPEND The system has just resumed or an error occured during 41PM_POST_SUSPEND The system has just resumed or an error occured during
diff --git a/Documentation/power/userland-swsusp.txt b/Documentation/power/userland-swsusp.txt
index e00c6cf09e85..7b99636564c8 100644
--- a/Documentation/power/userland-swsusp.txt
+++ b/Documentation/power/userland-swsusp.txt
@@ -14,7 +14,7 @@ are going to develop your own suspend/resume utilities.
14 14
15The interface consists of a character device providing the open(), 15The interface consists of a character device providing the open(),
16release(), read(), and write() operations as well as several ioctl() 16release(), read(), and write() operations as well as several ioctl()
17commands defined in kernel/power/power.h. The major and minor 17commands defined in include/linux/suspend_ioctls.h . The major and minor
18numbers of the device are, respectively, 10 and 231, and they can 18numbers of the device are, respectively, 10 and 231, and they can
19be read from /sys/class/misc/snapshot/dev. 19be read from /sys/class/misc/snapshot/dev.
20 20
@@ -27,17 +27,17 @@ once at a time.
27The ioctl() commands recognized by the device are: 27The ioctl() commands recognized by the device are:
28 28
29SNAPSHOT_FREEZE - freeze user space processes (the current process is 29SNAPSHOT_FREEZE - freeze user space processes (the current process is
30 not frozen); this is required for SNAPSHOT_ATOMIC_SNAPSHOT 30 not frozen); this is required for SNAPSHOT_CREATE_IMAGE
31 and SNAPSHOT_ATOMIC_RESTORE to succeed 31 and SNAPSHOT_ATOMIC_RESTORE to succeed
32 32
33SNAPSHOT_UNFREEZE - thaw user space processes frozen by SNAPSHOT_FREEZE 33SNAPSHOT_UNFREEZE - thaw user space processes frozen by SNAPSHOT_FREEZE
34 34
35SNAPSHOT_ATOMIC_SNAPSHOT - create a snapshot of the system memory; the 35SNAPSHOT_CREATE_IMAGE - create a snapshot of the system memory; the
36 last argument of ioctl() should be a pointer to an int variable, 36 last argument of ioctl() should be a pointer to an int variable,
37 the value of which will indicate whether the call returned after 37 the value of which will indicate whether the call returned after
38 creating the snapshot (1) or after restoring the system memory state 38 creating the snapshot (1) or after restoring the system memory state
39 from it (0) (after resume the system finds itself finishing the 39 from it (0) (after resume the system finds itself finishing the
40 SNAPSHOT_ATOMIC_SNAPSHOT ioctl() again); after the snapshot 40 SNAPSHOT_CREATE_IMAGE ioctl() again); after the snapshot
41 has been created the read() operation can be used to transfer 41 has been created the read() operation can be used to transfer
42 it out of the kernel 42 it out of the kernel
43 43
@@ -49,39 +49,37 @@ SNAPSHOT_ATOMIC_RESTORE - restore the system memory state from the
49 49
50SNAPSHOT_FREE - free memory allocated for the snapshot image 50SNAPSHOT_FREE - free memory allocated for the snapshot image
51 51
52SNAPSHOT_SET_IMAGE_SIZE - set the preferred maximum size of the image 52SNAPSHOT_PREF_IMAGE_SIZE - set the preferred maximum size of the image
53 (the kernel will do its best to ensure the image size will not exceed 53 (the kernel will do its best to ensure the image size will not exceed
54 this number, but if it turns out to be impossible, the kernel will 54 this number, but if it turns out to be impossible, the kernel will
55 create the smallest image possible) 55 create the smallest image possible)
56 56
57SNAPSHOT_AVAIL_SWAP - return the amount of available swap in bytes (the last 57SNAPSHOT_GET_IMAGE_SIZE - return the actual size of the hibernation image
58 argument should be a pointer to an unsigned int variable that will 58
59SNAPSHOT_AVAIL_SWAP_SIZE - return the amount of available swap in bytes (the
60 last argument should be a pointer to an unsigned int variable that will
59 contain the result if the call is successful). 61 contain the result if the call is successful).
60 62
61SNAPSHOT_GET_SWAP_PAGE - allocate a swap page from the resume partition 63SNAPSHOT_ALLOC_SWAP_PAGE - allocate a swap page from the resume partition
62 (the last argument should be a pointer to a loff_t variable that 64 (the last argument should be a pointer to a loff_t variable that
63 will contain the swap page offset if the call is successful) 65 will contain the swap page offset if the call is successful)
64 66
65SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with 67SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated by
66 SNAPSHOT_GET_SWAP_PAGE 68 SNAPSHOT_ALLOC_SWAP_PAGE
67
68SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument
69 should specify the device's major and minor numbers in the old
70 two-byte format, as returned by the stat() function in the .st_rdev
71 member of the stat structure)
72 69
73SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in <PAGE_SIZE> 70SNAPSHOT_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 71 units) from the beginning of the partition at which the swap header is
75 located (the last ioctl() argument should point to a struct 72 located (the last ioctl() argument should point to a struct
76 resume_swap_area, as defined in kernel/power/power.h, containing the 73 resume_swap_area, as defined in kernel/power/suspend_ioctls.h,
77 resume device specification, as for the SNAPSHOT_SET_SWAP_FILE ioctl(), 74 containing the resume device specification and the offset); for swap
78 and the offset); for swap partitions the offset is always 0, but it is 75 partitions the offset is always 0, but it is different from zero for
79 different to zero for swap files (please see 76 swap files (see Documentation/swsusp-and-swap-files.txt for details).
80 Documentation/swsusp-and-swap-files.txt for details). 77
81 The SNAPSHOT_SET_SWAP_AREA ioctl() is considered as a replacement for 78SNAPSHOT_PLATFORM_SUPPORT - enable/disable the hibernation platform support,
82 SNAPSHOT_SET_SWAP_FILE which is regarded as obsolete. It is 79 depending on the argument value (enable, if the argument is nonzero)
83 recommended to always use this call, because the code to set the resume 80
84 partition may be removed from future kernels 81SNAPSHOT_POWER_OFF - make the kernel transition the system to the hibernation
82 state (eg. ACPI S4) using the platform (eg. ACPI) driver
85 83
86SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to 84SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to
87 immediately enter the suspend-to-RAM state, so this call must always 85 immediately enter the suspend-to-RAM state, so this call must always
@@ -93,24 +91,6 @@ SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to
93 to resume the system from RAM if there's enough battery power or restore 91 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) 92 its state on the basis of the saved suspend image otherwise)
95 93
96SNAPSHOT_PMOPS - enable the usage of the hibernation_ops->prepare,
97 hibernate_ops->enter and hibernation_ops->finish methods (the in-kernel
98 swsusp knows these as the "platform method") which are needed on many
99 machines to (among others) speed up the resume by letting the BIOS skip
100 some steps or to let the system recognise the correct state of the
101 hardware after the resume (in particular on many machines this ensures
102 that unplugged AC adapters get correctly detected and that kacpid does
103 not run wild after the resume). The last ioctl() argument can take one
104 of the three values, defined in kernel/power/power.h:
105 PMOPS_PREPARE - make the kernel carry out the
106 hibernation_ops->prepare() operation
107 PMOPS_ENTER - make the kernel power off the system by calling
108 hibernation_ops->enter()
109 PMOPS_FINISH - make the kernel carry out the
110 hibernation_ops->finish() operation
111 Note that the actual constants are misnamed because they surface
112 internal kernel implementation details that have changed.
113
114The device's read() operation can be used to transfer the snapshot image from 94The device's read() operation can be used to transfer the snapshot image from
115the kernel. It has the following limitations: 95the kernel. It has the following limitations:
116- you cannot read() more than one virtual memory page at a time 96- you cannot read() more than one virtual memory page at a time
@@ -122,7 +102,7 @@ The device's write() operation is used for uploading the system memory snapshot
122into the kernel. It has the same limitations as the read() operation. 102into the kernel. It has the same limitations as the read() operation.
123 103
124The release() operation frees all memory allocated for the snapshot image 104The release() operation frees all memory allocated for the snapshot image
125and all swap pages allocated with SNAPSHOT_GET_SWAP_PAGE (if any). 105and all swap pages allocated with SNAPSHOT_ALLOC_SWAP_PAGE (if any).
126Thus it is not necessary to use either SNAPSHOT_FREE or 106Thus it is not necessary to use either SNAPSHOT_FREE or
127SNAPSHOT_FREE_SWAP_PAGES before closing the device (in fact it will also 107SNAPSHOT_FREE_SWAP_PAGES before closing the device (in fact it will also
128unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are 108unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
@@ -133,16 +113,12 @@ snapshot image from/to the kernel will use a swap parition, called the resume
133partition, or a swap file as storage space (if a swap file is used, the resume 113partition, or a swap file as storage space (if a swap file is used, the resume
134partition is the partition that holds this file). However, this is not really 114partition is the partition that holds this file). However, this is not really
135required, as they can use, for example, a special (blank) suspend partition or 115required, as they can use, for example, a special (blank) suspend partition or
136a file on a partition that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and 116a file on a partition that is unmounted before SNAPSHOT_CREATE_IMAGE and
137mounted afterwards. 117mounted afterwards.
138 118
139These utilities SHOULD NOT make any assumptions regarding the ordering of 119These utilities MUST NOT make any assumptions regarding the ordering of
140data within the snapshot image, except for the image header that MAY be 120data within the snapshot image. The contents of the image are entirely owned
141assumed to start with an swsusp_info structure, as specified in 121by the kernel and its structure may be changed in future kernel releases.
142kernel/power/power.h. This structure MAY be used by the userland utilities
143to obtain some information about the snapshot image, such as the size
144of the snapshot image, including the metadata and the header itself,
145contained in the .size member of swsusp_info.
146 122
147The snapshot image MUST be written to the kernel unaltered (ie. all of the image 123The snapshot image MUST be written to the kernel unaltered (ie. all of the image
148data, metadata and header MUST be written in _exactly_ the same amount, form 124data, metadata and header MUST be written in _exactly_ the same amount, form
@@ -159,7 +135,7 @@ means, such as checksums, to ensure the integrity of the snapshot image.
159The suspending and resuming utilities MUST lock themselves in memory, 135The suspending and resuming utilities MUST lock themselves in memory,
160preferrably using mlockall(), before calling SNAPSHOT_FREEZE. 136preferrably using mlockall(), before calling SNAPSHOT_FREEZE.
161 137
162The suspending utility MUST check the value stored by SNAPSHOT_ATOMIC_SNAPSHOT 138The suspending utility MUST check the value stored by SNAPSHOT_CREATE_IMAGE
163in the memory location pointed to by the last argument of ioctl() and proceed 139in the memory location pointed to by the last argument of ioctl() and proceed
164in accordance with it: 140in accordance with it:
1651. If the value is 1 (ie. the system memory snapshot has just been 1411. If the value is 1 (ie. the system memory snapshot has just been
@@ -173,7 +149,7 @@ in accordance with it:
173 image has been saved. 149 image has been saved.
174 (b) The suspending utility SHOULD NOT attempt to perform any 150 (b) The suspending utility SHOULD NOT attempt to perform any
175 file system operations (including reads) on the file systems 151 file system operations (including reads) on the file systems
176 that were mounted before SNAPSHOT_ATOMIC_SNAPSHOT has been 152 that were mounted before SNAPSHOT_CREATE_IMAGE has been
177 called. However, it MAY mount a file system that was not 153 called. However, it MAY mount a file system that was not
178 mounted at that time and perform some operations on it (eg. 154 mounted at that time and perform some operations on it (eg.
179 use it for saving the image). 155 use it for saving the image).