diff options
Diffstat (limited to 'kernel/power/hibernate.c')
| -rw-r--r-- | kernel/power/hibernate.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index b26f5f1e773e..c9c759d5a15c 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
| @@ -39,7 +39,7 @@ static int resume_delay; | |||
| 39 | static char resume_file[256] = CONFIG_PM_STD_PARTITION; | 39 | static char resume_file[256] = CONFIG_PM_STD_PARTITION; |
| 40 | dev_t swsusp_resume_device; | 40 | dev_t swsusp_resume_device; |
| 41 | sector_t swsusp_resume_block; | 41 | sector_t swsusp_resume_block; |
| 42 | int in_suspend __nosavedata; | 42 | __visible int in_suspend __nosavedata; |
| 43 | 43 | ||
| 44 | enum { | 44 | enum { |
| 45 | HIBERNATION_INVALID, | 45 | HIBERNATION_INVALID, |
| @@ -644,22 +644,23 @@ int hibernate(void) | |||
| 644 | if (error) | 644 | if (error) |
| 645 | goto Exit; | 645 | goto Exit; |
| 646 | 646 | ||
| 647 | /* Allocate memory management structures */ | ||
| 648 | error = create_basic_memory_bitmaps(); | ||
| 649 | if (error) | ||
| 650 | goto Exit; | ||
| 651 | |||
| 652 | printk(KERN_INFO "PM: Syncing filesystems ... "); | 647 | printk(KERN_INFO "PM: Syncing filesystems ... "); |
| 653 | sys_sync(); | 648 | sys_sync(); |
| 654 | printk("done.\n"); | 649 | printk("done.\n"); |
| 655 | 650 | ||
| 656 | error = freeze_processes(); | 651 | error = freeze_processes(); |
| 657 | if (error) | 652 | if (error) |
| 658 | goto Free_bitmaps; | 653 | goto Exit; |
| 654 | |||
| 655 | lock_device_hotplug(); | ||
| 656 | /* Allocate memory management structures */ | ||
| 657 | error = create_basic_memory_bitmaps(); | ||
| 658 | if (error) | ||
| 659 | goto Thaw; | ||
| 659 | 660 | ||
| 660 | error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM); | 661 | error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM); |
| 661 | if (error || freezer_test_done) | 662 | if (error || freezer_test_done) |
| 662 | goto Thaw; | 663 | goto Free_bitmaps; |
| 663 | 664 | ||
| 664 | if (in_suspend) { | 665 | if (in_suspend) { |
| 665 | unsigned int flags = 0; | 666 | unsigned int flags = 0; |
| @@ -682,14 +683,14 @@ int hibernate(void) | |||
| 682 | pr_debug("PM: Image restored successfully.\n"); | 683 | pr_debug("PM: Image restored successfully.\n"); |
| 683 | } | 684 | } |
| 684 | 685 | ||
| 686 | Free_bitmaps: | ||
| 687 | free_basic_memory_bitmaps(); | ||
| 685 | Thaw: | 688 | Thaw: |
| 689 | unlock_device_hotplug(); | ||
| 686 | thaw_processes(); | 690 | thaw_processes(); |
| 687 | 691 | ||
| 688 | /* Don't bother checking whether freezer_test_done is true */ | 692 | /* Don't bother checking whether freezer_test_done is true */ |
| 689 | freezer_test_done = false; | 693 | freezer_test_done = false; |
| 690 | |||
| 691 | Free_bitmaps: | ||
| 692 | free_basic_memory_bitmaps(); | ||
| 693 | Exit: | 694 | Exit: |
| 694 | pm_notifier_call_chain(PM_POST_HIBERNATION); | 695 | pm_notifier_call_chain(PM_POST_HIBERNATION); |
| 695 | pm_restore_console(); | 696 | pm_restore_console(); |
| @@ -806,21 +807,20 @@ static int software_resume(void) | |||
| 806 | pm_prepare_console(); | 807 | pm_prepare_console(); |
| 807 | error = pm_notifier_call_chain(PM_RESTORE_PREPARE); | 808 | error = pm_notifier_call_chain(PM_RESTORE_PREPARE); |
| 808 | if (error) | 809 | if (error) |
| 809 | goto close_finish; | 810 | goto Close_Finish; |
| 810 | |||
| 811 | error = create_basic_memory_bitmaps(); | ||
| 812 | if (error) | ||
| 813 | goto close_finish; | ||
| 814 | 811 | ||
| 815 | pr_debug("PM: Preparing processes for restore.\n"); | 812 | pr_debug("PM: Preparing processes for restore.\n"); |
| 816 | error = freeze_processes(); | 813 | error = freeze_processes(); |
| 817 | if (error) { | 814 | if (error) |
| 818 | swsusp_close(FMODE_READ); | 815 | goto Close_Finish; |
| 819 | goto Done; | ||
| 820 | } | ||
| 821 | 816 | ||
| 822 | pr_debug("PM: Loading hibernation image.\n"); | 817 | pr_debug("PM: Loading hibernation image.\n"); |
| 823 | 818 | ||
| 819 | lock_device_hotplug(); | ||
| 820 | error = create_basic_memory_bitmaps(); | ||
| 821 | if (error) | ||
| 822 | goto Thaw; | ||
| 823 | |||
| 824 | error = swsusp_read(&flags); | 824 | error = swsusp_read(&flags); |
| 825 | swsusp_close(FMODE_READ); | 825 | swsusp_close(FMODE_READ); |
| 826 | if (!error) | 826 | if (!error) |
| @@ -828,9 +828,10 @@ static int software_resume(void) | |||
| 828 | 828 | ||
| 829 | printk(KERN_ERR "PM: Failed to load hibernation image, recovering.\n"); | 829 | printk(KERN_ERR "PM: Failed to load hibernation image, recovering.\n"); |
| 830 | swsusp_free(); | 830 | swsusp_free(); |
| 831 | thaw_processes(); | ||
| 832 | Done: | ||
| 833 | free_basic_memory_bitmaps(); | 831 | free_basic_memory_bitmaps(); |
| 832 | Thaw: | ||
| 833 | unlock_device_hotplug(); | ||
| 834 | thaw_processes(); | ||
| 834 | Finish: | 835 | Finish: |
| 835 | pm_notifier_call_chain(PM_POST_RESTORE); | 836 | pm_notifier_call_chain(PM_POST_RESTORE); |
| 836 | pm_restore_console(); | 837 | pm_restore_console(); |
| @@ -840,7 +841,7 @@ static int software_resume(void) | |||
| 840 | mutex_unlock(&pm_mutex); | 841 | mutex_unlock(&pm_mutex); |
| 841 | pr_debug("PM: Hibernation image not present or could not be loaded.\n"); | 842 | pr_debug("PM: Hibernation image not present or could not be loaded.\n"); |
| 842 | return error; | 843 | return error; |
| 843 | close_finish: | 844 | Close_Finish: |
| 844 | swsusp_close(FMODE_READ); | 845 | swsusp_close(FMODE_READ); |
| 845 | goto Finish; | 846 | goto Finish; |
| 846 | } | 847 | } |
