aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/freezer.c4
-rw-r--r--kernel/power/hibernate.c16
-rw-r--r--kernel/power/main.c12
-rw-r--r--kernel/power/suspend.c4
-rw-r--r--kernel/power/swap.c4
-rw-r--r--kernel/power/user.c4
-rw-r--r--kernel/reboot.c6
7 files changed, 27 insertions, 23 deletions
diff --git a/kernel/freezer.c b/kernel/freezer.c
index 6f56a9e219fa..b162b74611e4 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -15,7 +15,9 @@
15atomic_t system_freezing_cnt = ATOMIC_INIT(0); 15atomic_t system_freezing_cnt = ATOMIC_INIT(0);
16EXPORT_SYMBOL(system_freezing_cnt); 16EXPORT_SYMBOL(system_freezing_cnt);
17 17
18/* indicate whether PM freezing is in effect, protected by pm_mutex */ 18/* indicate whether PM freezing is in effect, protected by
19 * system_transition_mutex
20 */
19bool pm_freezing; 21bool pm_freezing;
20bool pm_nosig_freezing; 22bool pm_nosig_freezing;
21 23
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 9c85c7822383..abef759de7c8 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -338,7 +338,7 @@ static int create_image(int platform_mode)
338 * hibernation_snapshot - Quiesce devices and create a hibernation image. 338 * hibernation_snapshot - Quiesce devices and create a hibernation image.
339 * @platform_mode: If set, use platform driver to prepare for the transition. 339 * @platform_mode: If set, use platform driver to prepare for the transition.
340 * 340 *
341 * This routine must be called with pm_mutex held. 341 * This routine must be called with system_transition_mutex held.
342 */ 342 */
343int hibernation_snapshot(int platform_mode) 343int hibernation_snapshot(int platform_mode)
344{ 344{
@@ -500,8 +500,9 @@ static int resume_target_kernel(bool platform_mode)
500 * hibernation_restore - Quiesce devices and restore from a hibernation image. 500 * hibernation_restore - Quiesce devices and restore from a hibernation image.
501 * @platform_mode: If set, use platform driver to prepare for the transition. 501 * @platform_mode: If set, use platform driver to prepare for the transition.
502 * 502 *
503 * This routine must be called with pm_mutex held. If it is successful, control 503 * This routine must be called with system_transition_mutex held. If it is
504 * reappears in the restored target kernel in hibernation_snapshot(). 504 * successful, control reappears in the restored target kernel in
505 * hibernation_snapshot().
505 */ 506 */
506int hibernation_restore(int platform_mode) 507int hibernation_restore(int platform_mode)
507{ 508{
@@ -638,6 +639,7 @@ static void power_down(void)
638 break; 639 break;
639 case HIBERNATION_PLATFORM: 640 case HIBERNATION_PLATFORM:
640 hibernation_platform_enter(); 641 hibernation_platform_enter();
642 /* Fall through */
641 case HIBERNATION_SHUTDOWN: 643 case HIBERNATION_SHUTDOWN:
642 if (pm_power_off) 644 if (pm_power_off)
643 kernel_power_off(); 645 kernel_power_off();
@@ -805,13 +807,13 @@ static int software_resume(void)
805 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs 807 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
806 * is configured into the kernel. Since the regular hibernate 808 * is configured into the kernel. Since the regular hibernate
807 * trigger path is via sysfs which takes a buffer mutex before 809 * trigger path is via sysfs which takes a buffer mutex before
808 * calling hibernate functions (which take pm_mutex) this can 810 * calling hibernate functions (which take system_transition_mutex)
809 * cause lockdep to complain about a possible ABBA deadlock 811 * this can cause lockdep to complain about a possible ABBA deadlock
810 * which cannot happen since we're in the boot code here and 812 * which cannot happen since we're in the boot code here and
811 * sysfs can't be invoked yet. Therefore, we use a subclass 813 * sysfs can't be invoked yet. Therefore, we use a subclass
812 * here to avoid lockdep complaining. 814 * here to avoid lockdep complaining.
813 */ 815 */
814 mutex_lock_nested(&pm_mutex, SINGLE_DEPTH_NESTING); 816 mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING);
815 817
816 if (swsusp_resume_device) 818 if (swsusp_resume_device)
817 goto Check_image; 819 goto Check_image;
@@ -899,7 +901,7 @@ static int software_resume(void)
899 atomic_inc(&snapshot_device_available); 901 atomic_inc(&snapshot_device_available);
900 /* For success case, the suspend path will release the lock */ 902 /* For success case, the suspend path will release the lock */
901 Unlock: 903 Unlock:
902 mutex_unlock(&pm_mutex); 904 mutex_unlock(&system_transition_mutex);
903 pm_pr_dbg("Hibernation image not present or could not be loaded.\n"); 905 pm_pr_dbg("Hibernation image not present or could not be loaded.\n");
904 return error; 906 return error;
905 Close_Finish: 907 Close_Finish:
diff --git a/kernel/power/main.c b/kernel/power/main.c
index d9706da10930..35b50823d83b 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -15,17 +15,16 @@
15#include <linux/workqueue.h> 15#include <linux/workqueue.h>
16#include <linux/debugfs.h> 16#include <linux/debugfs.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/suspend.h>
18 19
19#include "power.h" 20#include "power.h"
20 21
21DEFINE_MUTEX(pm_mutex);
22
23#ifdef CONFIG_PM_SLEEP 22#ifdef CONFIG_PM_SLEEP
24 23
25void lock_system_sleep(void) 24void lock_system_sleep(void)
26{ 25{
27 current->flags |= PF_FREEZER_SKIP; 26 current->flags |= PF_FREEZER_SKIP;
28 mutex_lock(&pm_mutex); 27 mutex_lock(&system_transition_mutex);
29} 28}
30EXPORT_SYMBOL_GPL(lock_system_sleep); 29EXPORT_SYMBOL_GPL(lock_system_sleep);
31 30
@@ -37,8 +36,9 @@ void unlock_system_sleep(void)
37 * 36 *
38 * Reason: 37 * Reason:
39 * Fundamentally, we just don't need it, because freezing condition 38 * Fundamentally, we just don't need it, because freezing condition
40 * doesn't come into effect until we release the pm_mutex lock, 39 * doesn't come into effect until we release the
41 * since the freezer always works with pm_mutex held. 40 * system_transition_mutex lock, since the freezer always works with
41 * system_transition_mutex held.
42 * 42 *
43 * More importantly, in the case of hibernation, 43 * More importantly, in the case of hibernation,
44 * unlock_system_sleep() gets called in snapshot_read() and 44 * unlock_system_sleep() gets called in snapshot_read() and
@@ -47,7 +47,7 @@ void unlock_system_sleep(void)
47 * enter the refrigerator, thus causing hibernation to lockup. 47 * enter the refrigerator, thus causing hibernation to lockup.
48 */ 48 */
49 current->flags &= ~PF_FREEZER_SKIP; 49 current->flags &= ~PF_FREEZER_SKIP;
50 mutex_unlock(&pm_mutex); 50 mutex_unlock(&system_transition_mutex);
51} 51}
52EXPORT_SYMBOL_GPL(unlock_system_sleep); 52EXPORT_SYMBOL_GPL(unlock_system_sleep);
53 53
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 87331565e505..9e13afe65a14 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -556,7 +556,7 @@ static int enter_state(suspend_state_t state)
556 } else if (!valid_state(state)) { 556 } else if (!valid_state(state)) {
557 return -EINVAL; 557 return -EINVAL;
558 } 558 }
559 if (!mutex_trylock(&pm_mutex)) 559 if (!mutex_trylock(&system_transition_mutex))
560 return -EBUSY; 560 return -EBUSY;
561 561
562 if (state == PM_SUSPEND_TO_IDLE) 562 if (state == PM_SUSPEND_TO_IDLE)
@@ -590,7 +590,7 @@ static int enter_state(suspend_state_t state)
590 pm_pr_dbg("Finishing wakeup.\n"); 590 pm_pr_dbg("Finishing wakeup.\n");
591 suspend_finish(); 591 suspend_finish();
592 Unlock: 592 Unlock:
593 mutex_unlock(&pm_mutex); 593 mutex_unlock(&system_transition_mutex);
594 return error; 594 return error;
595} 595}
596 596
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index c2bcf97d24c8..d7f6c1a288d3 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -923,7 +923,7 @@ int swsusp_write(unsigned int flags)
923 } 923 }
924 memset(&snapshot, 0, sizeof(struct snapshot_handle)); 924 memset(&snapshot, 0, sizeof(struct snapshot_handle));
925 error = snapshot_read_next(&snapshot); 925 error = snapshot_read_next(&snapshot);
926 if (error < PAGE_SIZE) { 926 if (error < (int)PAGE_SIZE) {
927 if (error >= 0) 927 if (error >= 0)
928 error = -EFAULT; 928 error = -EFAULT;
929 929
@@ -1483,7 +1483,7 @@ int swsusp_read(unsigned int *flags_p)
1483 1483
1484 memset(&snapshot, 0, sizeof(struct snapshot_handle)); 1484 memset(&snapshot, 0, sizeof(struct snapshot_handle));
1485 error = snapshot_write_next(&snapshot); 1485 error = snapshot_write_next(&snapshot);
1486 if (error < PAGE_SIZE) 1486 if (error < (int)PAGE_SIZE)
1487 return error < 0 ? error : -EFAULT; 1487 return error < 0 ? error : -EFAULT;
1488 header = (struct swsusp_info *)data_of(snapshot); 1488 header = (struct swsusp_info *)data_of(snapshot);
1489 error = get_swap_reader(&handle, flags_p); 1489 error = get_swap_reader(&handle, flags_p);
diff --git a/kernel/power/user.c b/kernel/power/user.c
index abd225550271..2d8b60a3c86b 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -216,7 +216,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
216 if (!capable(CAP_SYS_ADMIN)) 216 if (!capable(CAP_SYS_ADMIN))
217 return -EPERM; 217 return -EPERM;
218 218
219 if (!mutex_trylock(&pm_mutex)) 219 if (!mutex_trylock(&system_transition_mutex))
220 return -EBUSY; 220 return -EBUSY;
221 221
222 lock_device_hotplug(); 222 lock_device_hotplug();
@@ -394,7 +394,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
394 } 394 }
395 395
396 unlock_device_hotplug(); 396 unlock_device_hotplug();
397 mutex_unlock(&pm_mutex); 397 mutex_unlock(&system_transition_mutex);
398 398
399 return error; 399 return error;
400} 400}
diff --git a/kernel/reboot.c b/kernel/reboot.c
index e4ced883d8de..8fb44dec9ad7 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -294,7 +294,7 @@ void kernel_power_off(void)
294} 294}
295EXPORT_SYMBOL_GPL(kernel_power_off); 295EXPORT_SYMBOL_GPL(kernel_power_off);
296 296
297static DEFINE_MUTEX(reboot_mutex); 297DEFINE_MUTEX(system_transition_mutex);
298 298
299/* 299/*
300 * Reboot system call: for obvious reasons only root may call it, 300 * Reboot system call: for obvious reasons only root may call it,
@@ -338,7 +338,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
338 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) 338 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
339 cmd = LINUX_REBOOT_CMD_HALT; 339 cmd = LINUX_REBOOT_CMD_HALT;
340 340
341 mutex_lock(&reboot_mutex); 341 mutex_lock(&system_transition_mutex);
342 switch (cmd) { 342 switch (cmd) {
343 case LINUX_REBOOT_CMD_RESTART: 343 case LINUX_REBOOT_CMD_RESTART:
344 kernel_restart(NULL); 344 kernel_restart(NULL);
@@ -389,7 +389,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
389 ret = -EINVAL; 389 ret = -EINVAL;
390 break; 390 break;
391 } 391 }
392 mutex_unlock(&reboot_mutex); 392 mutex_unlock(&system_transition_mutex);
393 return ret; 393 return ret;
394} 394}
395 395