ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / Documentation / power / swsusp.txt
1 From kernel/suspend.c:
2
3  * BIG FAT WARNING *********************************************************
4  *
5  * If you have unsupported (*) devices using DMA...
6  *                              ...say goodbye to your data.
7  *
8  * If you touch anything on disk between suspend and resume...
9  *                              ...kiss your data goodbye.
10  *
11  * If your disk driver does not support suspend... (IDE does)
12  *                              ...you'd better find out how to get along
13  *                                 without your data.
14  *
15  * (*) pm interface support is needed to make it safe.
16
17 You need to append resume=/dev/your_swap_partition to kernel command
18 line. Then you suspend by echo 4 > /proc/acpi/sleep.
19
20 Pavel's unreliable guide to swsusp mess
21 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
23 There are currently two versions of swap suspend in the kernel, the old
24 "Pavel's" version in kernel/power/swsusp.c and the new "Patrick's"
25 version in kernel/power/pmdisk.c. They provide the same functionality;
26 the old version looks ugly but was tested, while the new version looks
27 nicer but did not receive so much testing. echo 4 > /proc/acpi/sleep
28 calls the old version, echo disk > /sys/power/state calls the new one.
29
30 [In the future, when the new version is stable enough, two things can
31 happen:
32
33 * the new version is moved into swsusp.c, and swsusp is renamed to swap
34   suspend (Pavel prefers this)
35
36 * pmdisk is kept as is and swsusp.c is removed from the kernel]
37
38
39
40 Article about goals and implementation of Software Suspend for Linux
41 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 Author: G\82ábor Kuti
43 Last revised: 2003-10-20 by Pavel Machek
44
45 Idea and goals to achieve
46
47 Nowadays it is common in several laptops that they have a suspend button. It
48 saves the state of the machine to a filesystem or to a partition and switches
49 to standby mode. Later resuming the machine the saved state is loaded back to
50 ram and the machine can continue its work. It has two real benefits. First we
51 save ourselves the time machine goes down and later boots up, energy costs
52 real high when running from batteries. The other gain is that we don't have to
53 interrupt our programs so processes that are calculating something for a long
54 time shouldn't need to be written interruptible.
55
56 Using the code
57
58 You have two ways to use this code. The first one is is with a patched
59 SysVinit (my patch is against 2.76 and available at my home page). You
60 might call 'swsusp' or 'shutdown -z <time>'. Next way is to echo 4 >
61 /proc/acpi/sleep.
62
63 Either way it saves the state of the machine into active swaps and then
64 reboots.  You must explicitly specify the swap partition to resume from with
65 ``resume='' kernel option. If signature is found it loads and restores saved
66 state. If the option ``noresume'' is specified as a boot parameter, it skips
67 the resuming.
68
69 In the meantime while the system is suspended you should not touch any of the
70 hardware!
71
72 About the code
73
74 Things to implement
75 - SMP support. I've done an SMP support but since I don't have access to a kind
76   of this one I cannot test it. Please SMP people test it.  .. Tested it,
77   doesn't work. Had no time to figure out why. There is some mess with
78   interrupts AFAIK..
79 - We should only make a copy of data related to kernel segment, since any
80   process data won't be changed.
81 - Should make more sanity checks. Or are these enough?
82
83 Not so important ideas for implementing
84
85 - If a real time process is running then don't suspend the machine.
86 - Support for adding/removing hardware while suspended?
87 - We should not free pages at the beginning so aggressively, most of them
88   go there anyway..
89
90 Drivers that need support
91 - pc_keyb -- perhaps we can wait for vojtech's input patches
92 - do IDE cdroms need some kind of support?
93 - IDE CD-RW -- how to deal with that?
94
95 Sleep states summary (thanx, Ducrot)
96 ====================================
97
98 In a really perfect world:
99 echo 1 > /proc/acpi/sleep       # for standby
100 echo 2 > /proc/acpi/sleep       # for suspend to ram
101 echo 3 > /proc/acpi/sleep       # for suspend to ram, but with more power conservative
102 echo 4 > /proc/acpi/sleep       # for suspend to disk
103 echo 5 > /proc/acpi/sleep       # for shutdown unfriendly the system
104
105 and perhaps
106 echo 4b > /proc/acpi/sleep      # for suspend to disk via s4bios
107
108
109 FAQ:
110
111 Q: well, suspending a server is IMHO a really stupid thing,
112 but... (Diego Zuccato):
113
114 A: You bought new UPS for your server. How do you install it without
115 bringing machine down? Suspend to disk, rearrange power cables,
116 resume.
117
118 You have your server on UPS. Power died, and UPS is indicating 30
119 seconds to failure. What do you do? Suspend to disk.
120
121 Ethernet card in your server died. You want to replace it. Your
122 server is not hotplug capable. What do you do? Suspend to disk,
123 replace ethernet card, resume. If you are fast your users will not
124 even see broken connections.
125
126 Any other idea you might have tell me!
127
128 Contacting the author
129 If you have any question or any patch that solves the above or detected
130 problems please contact me at seasons@falcon.sch.bme.hu. I might delay
131 answering, sorry about that.
132