diff options
| author | Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> | 2011-12-07 16:29:54 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-12-08 17:22:29 -0500 |
| commit | bcda53faf5814c0c6025a0bd47108adfcbe9f199 (patch) | |
| tree | a8768204a16b24436f33fac00c1bb4dcfb4fafd5 /kernel | |
| parent | 9b6fc5dc879bc90f765db0e95eefcf123d0d06dd (diff) | |
PM / Sleep: Replace mutex_[un]lock(&pm_mutex) with [un]lock_system_sleep()
Using [un]lock_system_sleep() is safer than directly using mutex_[un]lock()
on 'pm_mutex', since the latter could lead to freezing failures. Hence convert
all the present users of mutex_[un]lock(&pm_mutex) to use these safe APIs
instead.
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/kexec.c | 4 | ||||
| -rw-r--r-- | kernel/power/hibernate.c | 16 | ||||
| -rw-r--r-- | kernel/power/main.c | 4 | ||||
| -rw-r--r-- | kernel/power/suspend.c | 4 | ||||
| -rw-r--r-- | kernel/power/user.c | 16 |
5 files changed, 22 insertions, 22 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c index dc7bc0829286..090ee10d9604 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
| @@ -1523,7 +1523,7 @@ int kernel_kexec(void) | |||
| 1523 | 1523 | ||
| 1524 | #ifdef CONFIG_KEXEC_JUMP | 1524 | #ifdef CONFIG_KEXEC_JUMP |
| 1525 | if (kexec_image->preserve_context) { | 1525 | if (kexec_image->preserve_context) { |
| 1526 | mutex_lock(&pm_mutex); | 1526 | lock_system_sleep(); |
| 1527 | pm_prepare_console(); | 1527 | pm_prepare_console(); |
| 1528 | error = freeze_processes(); | 1528 | error = freeze_processes(); |
| 1529 | if (error) { | 1529 | if (error) { |
| @@ -1576,7 +1576,7 @@ int kernel_kexec(void) | |||
| 1576 | thaw_processes(); | 1576 | thaw_processes(); |
| 1577 | Restore_console: | 1577 | Restore_console: |
| 1578 | pm_restore_console(); | 1578 | pm_restore_console(); |
| 1579 | mutex_unlock(&pm_mutex); | 1579 | unlock_system_sleep(); |
| 1580 | } | 1580 | } |
| 1581 | #endif | 1581 | #endif |
| 1582 | 1582 | ||
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 605149a6d219..6d6d28870335 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
| @@ -69,14 +69,14 @@ void hibernation_set_ops(const struct platform_hibernation_ops *ops) | |||
| 69 | WARN_ON(1); | 69 | WARN_ON(1); |
| 70 | return; | 70 | return; |
| 71 | } | 71 | } |
| 72 | mutex_lock(&pm_mutex); | 72 | lock_system_sleep(); |
| 73 | hibernation_ops = ops; | 73 | hibernation_ops = ops; |
| 74 | if (ops) | 74 | if (ops) |
| 75 | hibernation_mode = HIBERNATION_PLATFORM; | 75 | hibernation_mode = HIBERNATION_PLATFORM; |
| 76 | else if (hibernation_mode == HIBERNATION_PLATFORM) | 76 | else if (hibernation_mode == HIBERNATION_PLATFORM) |
| 77 | hibernation_mode = HIBERNATION_SHUTDOWN; | 77 | hibernation_mode = HIBERNATION_SHUTDOWN; |
| 78 | 78 | ||
| 79 | mutex_unlock(&pm_mutex); | 79 | unlock_system_sleep(); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static bool entering_platform_hibernation; | 82 | static bool entering_platform_hibernation; |
| @@ -597,7 +597,7 @@ int hibernate(void) | |||
| 597 | { | 597 | { |
| 598 | int error; | 598 | int error; |
| 599 | 599 | ||
| 600 | mutex_lock(&pm_mutex); | 600 | lock_system_sleep(); |
| 601 | /* The snapshot device should not be opened while we're running */ | 601 | /* The snapshot device should not be opened while we're running */ |
| 602 | if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { | 602 | if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { |
| 603 | error = -EBUSY; | 603 | error = -EBUSY; |
| @@ -665,7 +665,7 @@ int hibernate(void) | |||
| 665 | pm_restore_console(); | 665 | pm_restore_console(); |
| 666 | atomic_inc(&snapshot_device_available); | 666 | atomic_inc(&snapshot_device_available); |
| 667 | Unlock: | 667 | Unlock: |
| 668 | mutex_unlock(&pm_mutex); | 668 | unlock_system_sleep(); |
| 669 | return error; | 669 | return error; |
| 670 | } | 670 | } |
| 671 | 671 | ||
| @@ -893,7 +893,7 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
| 893 | p = memchr(buf, '\n', n); | 893 | p = memchr(buf, '\n', n); |
| 894 | len = p ? p - buf : n; | 894 | len = p ? p - buf : n; |
| 895 | 895 | ||
| 896 | mutex_lock(&pm_mutex); | 896 | lock_system_sleep(); |
| 897 | for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) { | 897 | for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) { |
| 898 | if (len == strlen(hibernation_modes[i]) | 898 | if (len == strlen(hibernation_modes[i]) |
| 899 | && !strncmp(buf, hibernation_modes[i], len)) { | 899 | && !strncmp(buf, hibernation_modes[i], len)) { |
| @@ -919,7 +919,7 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
| 919 | if (!error) | 919 | if (!error) |
| 920 | pr_debug("PM: Hibernation mode set to '%s'\n", | 920 | pr_debug("PM: Hibernation mode set to '%s'\n", |
| 921 | hibernation_modes[mode]); | 921 | hibernation_modes[mode]); |
| 922 | mutex_unlock(&pm_mutex); | 922 | unlock_system_sleep(); |
| 923 | return error ? error : n; | 923 | return error ? error : n; |
| 924 | } | 924 | } |
| 925 | 925 | ||
| @@ -946,9 +946,9 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
| 946 | if (maj != MAJOR(res) || min != MINOR(res)) | 946 | if (maj != MAJOR(res) || min != MINOR(res)) |
| 947 | goto out; | 947 | goto out; |
| 948 | 948 | ||
| 949 | mutex_lock(&pm_mutex); | 949 | lock_system_sleep(); |
| 950 | swsusp_resume_device = res; | 950 | swsusp_resume_device = res; |
| 951 | mutex_unlock(&pm_mutex); | 951 | unlock_system_sleep(); |
| 952 | printk(KERN_INFO "PM: Starting manual resume from disk\n"); | 952 | printk(KERN_INFO "PM: Starting manual resume from disk\n"); |
| 953 | noresume = 0; | 953 | noresume = 0; |
| 954 | software_resume(); | 954 | software_resume(); |
diff --git a/kernel/power/main.c b/kernel/power/main.c index 7d36fb31e4c4..9824b41e5a18 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
| @@ -116,7 +116,7 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
| 116 | p = memchr(buf, '\n', n); | 116 | p = memchr(buf, '\n', n); |
| 117 | len = p ? p - buf : n; | 117 | len = p ? p - buf : n; |
| 118 | 118 | ||
| 119 | mutex_lock(&pm_mutex); | 119 | lock_system_sleep(); |
| 120 | 120 | ||
| 121 | level = TEST_FIRST; | 121 | level = TEST_FIRST; |
| 122 | for (s = &pm_tests[level]; level <= TEST_MAX; s++, level++) | 122 | for (s = &pm_tests[level]; level <= TEST_MAX; s++, level++) |
| @@ -126,7 +126,7 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
| 126 | break; | 126 | break; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | mutex_unlock(&pm_mutex); | 129 | unlock_system_sleep(); |
| 130 | 130 | ||
| 131 | return error ? error : n; | 131 | return error ? error : n; |
| 132 | } | 132 | } |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index d336b27d1104..4fd51beed879 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
| @@ -42,9 +42,9 @@ static const struct platform_suspend_ops *suspend_ops; | |||
| 42 | */ | 42 | */ |
| 43 | void suspend_set_ops(const struct platform_suspend_ops *ops) | 43 | void suspend_set_ops(const struct platform_suspend_ops *ops) |
| 44 | { | 44 | { |
| 45 | mutex_lock(&pm_mutex); | 45 | lock_system_sleep(); |
| 46 | suspend_ops = ops; | 46 | suspend_ops = ops; |
| 47 | mutex_unlock(&pm_mutex); | 47 | unlock_system_sleep(); |
| 48 | } | 48 | } |
| 49 | EXPORT_SYMBOL_GPL(suspend_set_ops); | 49 | EXPORT_SYMBOL_GPL(suspend_set_ops); |
| 50 | 50 | ||
diff --git a/kernel/power/user.c b/kernel/power/user.c index 06ea33df8560..98ade217da6c 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
| @@ -71,7 +71,7 @@ static int snapshot_open(struct inode *inode, struct file *filp) | |||
| 71 | struct snapshot_data *data; | 71 | struct snapshot_data *data; |
| 72 | int error; | 72 | int error; |
| 73 | 73 | ||
| 74 | mutex_lock(&pm_mutex); | 74 | lock_system_sleep(); |
| 75 | 75 | ||
| 76 | if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { | 76 | if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { |
| 77 | error = -EBUSY; | 77 | error = -EBUSY; |
| @@ -123,7 +123,7 @@ static int snapshot_open(struct inode *inode, struct file *filp) | |||
| 123 | data->platform_support = 0; | 123 | data->platform_support = 0; |
| 124 | 124 | ||
| 125 | Unlock: | 125 | Unlock: |
| 126 | mutex_unlock(&pm_mutex); | 126 | unlock_system_sleep(); |
| 127 | 127 | ||
| 128 | return error; | 128 | return error; |
| 129 | } | 129 | } |
| @@ -132,7 +132,7 @@ static int snapshot_release(struct inode *inode, struct file *filp) | |||
| 132 | { | 132 | { |
| 133 | struct snapshot_data *data; | 133 | struct snapshot_data *data; |
| 134 | 134 | ||
| 135 | mutex_lock(&pm_mutex); | 135 | lock_system_sleep(); |
| 136 | 136 | ||
| 137 | swsusp_free(); | 137 | swsusp_free(); |
| 138 | free_basic_memory_bitmaps(); | 138 | free_basic_memory_bitmaps(); |
| @@ -146,7 +146,7 @@ static int snapshot_release(struct inode *inode, struct file *filp) | |||
| 146 | PM_POST_HIBERNATION : PM_POST_RESTORE); | 146 | PM_POST_HIBERNATION : PM_POST_RESTORE); |
| 147 | atomic_inc(&snapshot_device_available); | 147 | atomic_inc(&snapshot_device_available); |
| 148 | 148 | ||
| 149 | mutex_unlock(&pm_mutex); | 149 | unlock_system_sleep(); |
| 150 | 150 | ||
| 151 | return 0; | 151 | return 0; |
| 152 | } | 152 | } |
| @@ -158,7 +158,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf, | |||
| 158 | ssize_t res; | 158 | ssize_t res; |
| 159 | loff_t pg_offp = *offp & ~PAGE_MASK; | 159 | loff_t pg_offp = *offp & ~PAGE_MASK; |
| 160 | 160 | ||
| 161 | mutex_lock(&pm_mutex); | 161 | lock_system_sleep(); |
| 162 | 162 | ||
| 163 | data = filp->private_data; | 163 | data = filp->private_data; |
| 164 | if (!data->ready) { | 164 | if (!data->ready) { |
| @@ -179,7 +179,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf, | |||
| 179 | *offp += res; | 179 | *offp += res; |
| 180 | 180 | ||
| 181 | Unlock: | 181 | Unlock: |
| 182 | mutex_unlock(&pm_mutex); | 182 | unlock_system_sleep(); |
| 183 | 183 | ||
| 184 | return res; | 184 | return res; |
| 185 | } | 185 | } |
| @@ -191,7 +191,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf, | |||
| 191 | ssize_t res; | 191 | ssize_t res; |
| 192 | loff_t pg_offp = *offp & ~PAGE_MASK; | 192 | loff_t pg_offp = *offp & ~PAGE_MASK; |
| 193 | 193 | ||
| 194 | mutex_lock(&pm_mutex); | 194 | lock_system_sleep(); |
| 195 | 195 | ||
| 196 | data = filp->private_data; | 196 | data = filp->private_data; |
| 197 | 197 | ||
| @@ -208,7 +208,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf, | |||
| 208 | if (res > 0) | 208 | if (res > 0) |
| 209 | *offp += res; | 209 | *offp += res; |
| 210 | unlock: | 210 | unlock: |
| 211 | mutex_unlock(&pm_mutex); | 211 | unlock_system_sleep(); |
| 212 | 212 | ||
| 213 | return res; | 213 | return res; |
| 214 | } | 214 | } |
