diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-30 08:19:46 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-30 20:49:47 -0400 |
commit | 942f40155a743f4204308d62405dacaa4bfadb11 (patch) | |
tree | c65e934016413151824dcb6b15e0f2ae6ce1d23d /kernel | |
parent | 8fd37a4c9822d58c93f764864582aa13112b1513 (diff) |
PM / hibernate / memory hotplug: Rework mutual exclusion
Since all of the memory hotplug operations have to be carried out
under device_hotplug_lock, they won't need to acquire pm_mutex if
device_hotplug_lock is held around hibernation.
For this reason, make the hibernation code acquire
device_hotplug_lock after freezing user space processes and
release it before thawing them. At the same tim drop the
lock_system_sleep() and unlock_system_sleep() calls from
lock_memory_hotplug() and unlock_memory_hotplug(), respectively.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/power/hibernate.c | 4 | ||||
-rw-r--r-- | kernel/power/user.c | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index d4e54053d009..0b78f72ad39d 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -652,6 +652,7 @@ int hibernate(void) | |||
652 | if (error) | 652 | if (error) |
653 | goto Exit; | 653 | goto Exit; |
654 | 654 | ||
655 | lock_device_hotplug(); | ||
655 | /* Allocate memory management structures */ | 656 | /* Allocate memory management structures */ |
656 | error = create_basic_memory_bitmaps(); | 657 | error = create_basic_memory_bitmaps(); |
657 | if (error) | 658 | if (error) |
@@ -685,6 +686,7 @@ int hibernate(void) | |||
685 | Free_bitmaps: | 686 | Free_bitmaps: |
686 | free_basic_memory_bitmaps(); | 687 | free_basic_memory_bitmaps(); |
687 | Thaw: | 688 | Thaw: |
689 | unlock_device_hotplug(); | ||
688 | thaw_processes(); | 690 | thaw_processes(); |
689 | 691 | ||
690 | /* Don't bother checking whether freezer_test_done is true */ | 692 | /* Don't bother checking whether freezer_test_done is true */ |
@@ -814,6 +816,7 @@ static int software_resume(void) | |||
814 | 816 | ||
815 | pr_debug("PM: Loading hibernation image.\n"); | 817 | pr_debug("PM: Loading hibernation image.\n"); |
816 | 818 | ||
819 | lock_device_hotplug(); | ||
817 | error = create_basic_memory_bitmaps(); | 820 | error = create_basic_memory_bitmaps(); |
818 | if (error) | 821 | if (error) |
819 | goto Thaw; | 822 | goto Thaw; |
@@ -827,6 +830,7 @@ static int software_resume(void) | |||
827 | swsusp_free(); | 830 | swsusp_free(); |
828 | free_basic_memory_bitmaps(); | 831 | free_basic_memory_bitmaps(); |
829 | Thaw: | 832 | Thaw: |
833 | unlock_device_hotplug(); | ||
830 | thaw_processes(); | 834 | thaw_processes(); |
831 | Finish: | 835 | Finish: |
832 | pm_notifier_call_chain(PM_POST_RESTORE); | 836 | pm_notifier_call_chain(PM_POST_RESTORE); |
diff --git a/kernel/power/user.c b/kernel/power/user.c index 63368163e98d..72e8f4fd616d 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -201,6 +201,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
201 | if (!mutex_trylock(&pm_mutex)) | 201 | if (!mutex_trylock(&pm_mutex)) |
202 | return -EBUSY; | 202 | return -EBUSY; |
203 | 203 | ||
204 | lock_device_hotplug(); | ||
204 | data = filp->private_data; | 205 | data = filp->private_data; |
205 | 206 | ||
206 | switch (cmd) { | 207 | switch (cmd) { |
@@ -373,6 +374,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
373 | 374 | ||
374 | } | 375 | } |
375 | 376 | ||
377 | unlock_device_hotplug(); | ||
376 | mutex_unlock(&pm_mutex); | 378 | mutex_unlock(&pm_mutex); |
377 | 379 | ||
378 | return error; | 380 | return error; |