aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/hibernate.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-05-20 01:36:52 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-05-20 01:36:52 -0400
commit880102e78547c1db158a17e36cf0cdd98e7ad710 (patch)
tree3fff9cc54c44dafe275cfabefb96c589e08d971d /kernel/power/hibernate.c
parent3d07f0e83d4323d2cd45cc583f7cf1957aca3cac (diff)
parent39ab05c8e0b519ff0a04a869f065746e6e8c3d95 (diff)
Merge remote branch 'origin/master' into merge
Manual merge of arch/powerpc/kernel/smp.c and add missing scheduler_ipi() call to arch/powerpc/platforms/cell/interrupt.c Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'kernel/power/hibernate.c')
-rw-r--r--kernel/power/hibernate.c58
1 files changed, 38 insertions, 20 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 50aae660174d..f9bec56d8825 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -272,12 +272,7 @@ static int create_image(int platform_mode)
272 272
273 local_irq_disable(); 273 local_irq_disable();
274 274
275 error = sysdev_suspend(PMSG_FREEZE); 275 error = syscore_suspend();
276 if (!error) {
277 error = syscore_suspend();
278 if (error)
279 sysdev_resume();
280 }
281 if (error) { 276 if (error) {
282 printk(KERN_ERR "PM: Some system devices failed to power down, " 277 printk(KERN_ERR "PM: Some system devices failed to power down, "
283 "aborting hibernation\n"); 278 "aborting hibernation\n");
@@ -302,7 +297,6 @@ static int create_image(int platform_mode)
302 297
303 Power_up: 298 Power_up:
304 syscore_resume(); 299 syscore_resume();
305 sysdev_resume();
306 /* NOTE: dpm_resume_noirq() is just a resume() for devices 300 /* NOTE: dpm_resume_noirq() is just a resume() for devices
307 * that suspended with irqs off ... no overall powerup. 301 * that suspended with irqs off ... no overall powerup.
308 */ 302 */
@@ -333,20 +327,25 @@ static int create_image(int platform_mode)
333 327
334int hibernation_snapshot(int platform_mode) 328int hibernation_snapshot(int platform_mode)
335{ 329{
330 pm_message_t msg = PMSG_RECOVER;
336 int error; 331 int error;
337 332
338 error = platform_begin(platform_mode); 333 error = platform_begin(platform_mode);
339 if (error) 334 if (error)
340 goto Close; 335 goto Close;
341 336
337 error = dpm_prepare(PMSG_FREEZE);
338 if (error)
339 goto Complete_devices;
340
342 /* Preallocate image memory before shutting down devices. */ 341 /* Preallocate image memory before shutting down devices. */
343 error = hibernate_preallocate_memory(); 342 error = hibernate_preallocate_memory();
344 if (error) 343 if (error)
345 goto Close; 344 goto Complete_devices;
346 345
347 suspend_console(); 346 suspend_console();
348 pm_restrict_gfp_mask(); 347 pm_restrict_gfp_mask();
349 error = dpm_suspend_start(PMSG_FREEZE); 348 error = dpm_suspend(PMSG_FREEZE);
350 if (error) 349 if (error)
351 goto Recover_platform; 350 goto Recover_platform;
352 351
@@ -364,13 +363,17 @@ int hibernation_snapshot(int platform_mode)
364 if (error || !in_suspend) 363 if (error || !in_suspend)
365 swsusp_free(); 364 swsusp_free();
366 365
367 dpm_resume_end(in_suspend ? 366 msg = in_suspend ? (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE;
368 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); 367 dpm_resume(msg);
369 368
370 if (error || !in_suspend) 369 if (error || !in_suspend)
371 pm_restore_gfp_mask(); 370 pm_restore_gfp_mask();
372 371
373 resume_console(); 372 resume_console();
373
374 Complete_devices:
375 dpm_complete(msg);
376
374 Close: 377 Close:
375 platform_end(platform_mode); 378 platform_end(platform_mode);
376 return error; 379 return error;
@@ -409,12 +412,7 @@ static int resume_target_kernel(bool platform_mode)
409 412
410 local_irq_disable(); 413 local_irq_disable();
411 414
412 error = sysdev_suspend(PMSG_QUIESCE); 415 error = syscore_suspend();
413 if (!error) {
414 error = syscore_suspend();
415 if (error)
416 sysdev_resume();
417 }
418 if (error) 416 if (error)
419 goto Enable_irqs; 417 goto Enable_irqs;
420 418
@@ -442,7 +440,6 @@ static int resume_target_kernel(bool platform_mode)
442 touch_softlockup_watchdog(); 440 touch_softlockup_watchdog();
443 441
444 syscore_resume(); 442 syscore_resume();
445 sysdev_resume();
446 443
447 Enable_irqs: 444 Enable_irqs:
448 local_irq_enable(); 445 local_irq_enable();
@@ -528,7 +525,6 @@ int hibernation_platform_enter(void)
528 goto Platform_finish; 525 goto Platform_finish;
529 526
530 local_irq_disable(); 527 local_irq_disable();
531 sysdev_suspend(PMSG_HIBERNATE);
532 syscore_suspend(); 528 syscore_suspend();
533 if (pm_wakeup_pending()) { 529 if (pm_wakeup_pending()) {
534 error = -EAGAIN; 530 error = -EAGAIN;
@@ -541,7 +537,6 @@ int hibernation_platform_enter(void)
541 537
542 Power_up: 538 Power_up:
543 syscore_resume(); 539 syscore_resume();
544 sysdev_resume();
545 local_irq_enable(); 540 local_irq_enable();
546 enable_nonboot_cpus(); 541 enable_nonboot_cpus();
547 542
@@ -982,10 +977,33 @@ static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *att
982 977
983power_attr(image_size); 978power_attr(image_size);
984 979
980static ssize_t reserved_size_show(struct kobject *kobj,
981 struct kobj_attribute *attr, char *buf)
982{
983 return sprintf(buf, "%lu\n", reserved_size);
984}
985
986static ssize_t reserved_size_store(struct kobject *kobj,
987 struct kobj_attribute *attr,
988 const char *buf, size_t n)
989{
990 unsigned long size;
991
992 if (sscanf(buf, "%lu", &size) == 1) {
993 reserved_size = size;
994 return n;
995 }
996
997 return -EINVAL;
998}
999
1000power_attr(reserved_size);
1001
985static struct attribute * g[] = { 1002static struct attribute * g[] = {
986 &disk_attr.attr, 1003 &disk_attr.attr,
987 &resume_attr.attr, 1004 &resume_attr.attr,
988 &image_size_attr.attr, 1005 &image_size_attr.attr,
1006 &reserved_size_attr.attr,
989 NULL, 1007 NULL,
990}; 1008};
991 1009