aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/hibernate.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/power/hibernate.c')
-rw-r--r--kernel/power/hibernate.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 8dc31e02ae12..7a931a90e4a2 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -326,7 +326,6 @@ static int create_image(int platform_mode)
326int hibernation_snapshot(int platform_mode) 326int hibernation_snapshot(int platform_mode)
327{ 327{
328 int error; 328 int error;
329 gfp_t saved_mask;
330 329
331 error = platform_begin(platform_mode); 330 error = platform_begin(platform_mode);
332 if (error) 331 if (error)
@@ -338,7 +337,7 @@ int hibernation_snapshot(int platform_mode)
338 goto Close; 337 goto Close;
339 338
340 suspend_console(); 339 suspend_console();
341 saved_mask = clear_gfp_allowed_mask(GFP_IOFS); 340 pm_restrict_gfp_mask();
342 error = dpm_suspend_start(PMSG_FREEZE); 341 error = dpm_suspend_start(PMSG_FREEZE);
343 if (error) 342 if (error)
344 goto Recover_platform; 343 goto Recover_platform;
@@ -347,7 +346,10 @@ int hibernation_snapshot(int platform_mode)
347 goto Recover_platform; 346 goto Recover_platform;
348 347
349 error = create_image(platform_mode); 348 error = create_image(platform_mode);
350 /* Control returns here after successful restore */ 349 /*
350 * Control returns here (1) after the image has been created or the
351 * image creation has failed and (2) after a successful restore.
352 */
351 353
352 Resume_devices: 354 Resume_devices:
353 /* We may need to release the preallocated image pages here. */ 355 /* We may need to release the preallocated image pages here. */
@@ -356,7 +358,10 @@ int hibernation_snapshot(int platform_mode)
356 358
357 dpm_resume_end(in_suspend ? 359 dpm_resume_end(in_suspend ?
358 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); 360 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
359 set_gfp_allowed_mask(saved_mask); 361
362 if (error || !in_suspend)
363 pm_restore_gfp_mask();
364
360 resume_console(); 365 resume_console();
361 Close: 366 Close:
362 platform_end(platform_mode); 367 platform_end(platform_mode);
@@ -451,17 +456,16 @@ static int resume_target_kernel(bool platform_mode)
451int hibernation_restore(int platform_mode) 456int hibernation_restore(int platform_mode)
452{ 457{
453 int error; 458 int error;
454 gfp_t saved_mask;
455 459
456 pm_prepare_console(); 460 pm_prepare_console();
457 suspend_console(); 461 suspend_console();
458 saved_mask = clear_gfp_allowed_mask(GFP_IOFS); 462 pm_restrict_gfp_mask();
459 error = dpm_suspend_start(PMSG_QUIESCE); 463 error = dpm_suspend_start(PMSG_QUIESCE);
460 if (!error) { 464 if (!error) {
461 error = resume_target_kernel(platform_mode); 465 error = resume_target_kernel(platform_mode);
462 dpm_resume_end(PMSG_RECOVER); 466 dpm_resume_end(PMSG_RECOVER);
463 } 467 }
464 set_gfp_allowed_mask(saved_mask); 468 pm_restore_gfp_mask();
465 resume_console(); 469 resume_console();
466 pm_restore_console(); 470 pm_restore_console();
467 return error; 471 return error;
@@ -475,7 +479,6 @@ int hibernation_restore(int platform_mode)
475int hibernation_platform_enter(void) 479int hibernation_platform_enter(void)
476{ 480{
477 int error; 481 int error;
478 gfp_t saved_mask;
479 482
480 if (!hibernation_ops) 483 if (!hibernation_ops)
481 return -ENOSYS; 484 return -ENOSYS;
@@ -491,7 +494,6 @@ int hibernation_platform_enter(void)
491 494
492 entering_platform_hibernation = true; 495 entering_platform_hibernation = true;
493 suspend_console(); 496 suspend_console();
494 saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
495 error = dpm_suspend_start(PMSG_HIBERNATE); 497 error = dpm_suspend_start(PMSG_HIBERNATE);
496 if (error) { 498 if (error) {
497 if (hibernation_ops->recover) 499 if (hibernation_ops->recover)
@@ -535,7 +537,6 @@ int hibernation_platform_enter(void)
535 Resume_devices: 537 Resume_devices:
536 entering_platform_hibernation = false; 538 entering_platform_hibernation = false;
537 dpm_resume_end(PMSG_RESTORE); 539 dpm_resume_end(PMSG_RESTORE);
538 set_gfp_allowed_mask(saved_mask);
539 resume_console(); 540 resume_console();
540 541
541 Close: 542 Close:
@@ -643,6 +644,7 @@ int hibernate(void)
643 swsusp_free(); 644 swsusp_free();
644 if (!error) 645 if (!error)
645 power_down(); 646 power_down();
647 pm_restore_gfp_mask();
646 } else { 648 } else {
647 pr_debug("PM: Image restored successfully.\n"); 649 pr_debug("PM: Image restored successfully.\n");
648 } 650 }