aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/disk.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-05-06 17:50:45 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:59 -0400
commit0709db6072c2e799eba1aa61bd19e0d7f38aa2cd (patch)
treee348c73adbfdcb46b05b23f36dc420ecdd62ca8a /kernel/power/disk.c
parent1525a2ad76f991eba9755f75c9b6d4d97abad25e (diff)
swsusp: use GFP_KERNEL for creating basic data structures
Make swsusp call create_basic_memory_bitmaps() before processes are frozen, so that GFP_KERNEL allocations can be made in it. Additionally, ensure that the swsusp's userland interface won't be used while either pm_suspend_disk() or software_resume() is being executed. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power/disk.c')
-rw-r--r--kernel/power/disk.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 403bc3722fee..e518379b667a 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -130,28 +130,33 @@ int pm_suspend_disk(void)
130{ 130{
131 int error; 131 int error;
132 132
133 /* The snapshot device should not be opened while we're running */
134 if (!atomic_add_unless(&snapshot_device_available, -1, 0))
135 return -EBUSY;
136
137 /* Allocate memory management structures */
138 error = create_basic_memory_bitmaps();
139 if (error)
140 goto Exit;
141
133 error = prepare_processes(); 142 error = prepare_processes();
134 if (error) 143 if (error)
135 return error; 144 goto Finish;
136 145
137 if (pm_disk_mode == PM_DISK_TESTPROC) { 146 if (pm_disk_mode == PM_DISK_TESTPROC) {
138 printk("swsusp debug: Waiting for 5 seconds.\n"); 147 printk("swsusp debug: Waiting for 5 seconds.\n");
139 mdelay(5000); 148 mdelay(5000);
140 goto Thaw; 149 goto Thaw;
141 } 150 }
142 /* Allocate memory management structures */
143 error = create_basic_memory_bitmaps();
144 if (error)
145 goto Thaw;
146 151
147 /* Free memory before shutting down devices. */ 152 /* Free memory before shutting down devices. */
148 error = swsusp_shrink_memory(); 153 error = swsusp_shrink_memory();
149 if (error) 154 if (error)
150 goto Finish; 155 goto Thaw;
151 156
152 error = platform_prepare(); 157 error = platform_prepare();
153 if (error) 158 if (error)
154 goto Finish; 159 goto Thaw;
155 160
156 suspend_console(); 161 suspend_console();
157 error = device_suspend(PMSG_FREEZE); 162 error = device_suspend(PMSG_FREEZE);
@@ -186,7 +191,7 @@ int pm_suspend_disk(void)
186 power_down(); 191 power_down();
187 else { 192 else {
188 swsusp_free(); 193 swsusp_free();
189 goto Finish; 194 goto Thaw;
190 } 195 }
191 } else { 196 } else {
192 pr_debug("PM: Image restored successfully.\n"); 197 pr_debug("PM: Image restored successfully.\n");
@@ -199,10 +204,12 @@ int pm_suspend_disk(void)
199 platform_finish(); 204 platform_finish();
200 device_resume(); 205 device_resume();
201 resume_console(); 206 resume_console();
202 Finish:
203 free_basic_memory_bitmaps();
204 Thaw: 207 Thaw:
205 unprepare_processes(); 208 unprepare_processes();
209 Finish:
210 free_basic_memory_bitmaps();
211 Exit:
212 atomic_inc(&snapshot_device_available);
206 return error; 213 return error;
207} 214}
208 215
@@ -250,9 +257,15 @@ static int software_resume(void)
250 if (error) 257 if (error)
251 goto Unlock; 258 goto Unlock;
252 259
260 /* The snapshot device should not be opened while we're running */
261 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
262 error = -EBUSY;
263 goto Unlock;
264 }
265
253 error = create_basic_memory_bitmaps(); 266 error = create_basic_memory_bitmaps();
254 if (error) 267 if (error)
255 goto Unlock; 268 goto Finish;
256 269
257 pr_debug("PM: Preparing processes for restore.\n"); 270 pr_debug("PM: Preparing processes for restore.\n");
258 error = prepare_processes(); 271 error = prepare_processes();
@@ -290,6 +303,8 @@ static int software_resume(void)
290 unprepare_processes(); 303 unprepare_processes();
291 Done: 304 Done:
292 free_basic_memory_bitmaps(); 305 free_basic_memory_bitmaps();
306 Finish:
307 atomic_inc(&snapshot_device_available);
293 /* For success case, the suspend path will release the lock */ 308 /* For success case, the suspend path will release the lock */
294 Unlock: 309 Unlock:
295 mutex_unlock(&pm_mutex); 310 mutex_unlock(&pm_mutex);