diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/async.c | 20 | ||||
| -rw-r--r-- | kernel/futex.c | 24 | ||||
| -rw-r--r-- | kernel/kexec.c | 2 | ||||
| -rw-r--r-- | kernel/power/disk.c | 21 | ||||
| -rw-r--r-- | kernel/power/main.c | 7 |
5 files changed, 29 insertions, 45 deletions
diff --git a/kernel/async.c b/kernel/async.c index 968ef9457d4e..50540301ed0f 100644 --- a/kernel/async.c +++ b/kernel/async.c | |||
| @@ -92,19 +92,23 @@ extern int initcall_debug; | |||
| 92 | static async_cookie_t __lowest_in_progress(struct list_head *running) | 92 | static async_cookie_t __lowest_in_progress(struct list_head *running) |
| 93 | { | 93 | { |
| 94 | struct async_entry *entry; | 94 | struct async_entry *entry; |
| 95 | async_cookie_t ret = next_cookie; /* begin with "infinity" value */ | ||
| 96 | |||
| 95 | if (!list_empty(running)) { | 97 | if (!list_empty(running)) { |
| 96 | entry = list_first_entry(running, | 98 | entry = list_first_entry(running, |
| 97 | struct async_entry, list); | 99 | struct async_entry, list); |
| 98 | return entry->cookie; | 100 | ret = entry->cookie; |
| 99 | } else if (!list_empty(&async_pending)) { | ||
| 100 | entry = list_first_entry(&async_pending, | ||
| 101 | struct async_entry, list); | ||
| 102 | return entry->cookie; | ||
| 103 | } else { | ||
| 104 | /* nothing in progress... next_cookie is "infinity" */ | ||
| 105 | return next_cookie; | ||
| 106 | } | 101 | } |
| 107 | 102 | ||
| 103 | if (!list_empty(&async_pending)) { | ||
| 104 | list_for_each_entry(entry, &async_pending, list) | ||
| 105 | if (entry->running == running) { | ||
| 106 | ret = entry->cookie; | ||
| 107 | break; | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | return ret; | ||
| 108 | } | 112 | } |
| 109 | 113 | ||
| 110 | static async_cookie_t lowest_in_progress(struct list_head *running) | 114 | static async_cookie_t lowest_in_progress(struct list_head *running) |
diff --git a/kernel/futex.c b/kernel/futex.c index eef8cd26b5e5..d546b2d53a62 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -193,6 +193,7 @@ static void drop_futex_key_refs(union futex_key *key) | |||
| 193 | * @uaddr: virtual address of the futex | 193 | * @uaddr: virtual address of the futex |
| 194 | * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED | 194 | * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED |
| 195 | * @key: address where result is stored. | 195 | * @key: address where result is stored. |
| 196 | * @rw: mapping needs to be read/write (values: VERIFY_READ, VERIFY_WRITE) | ||
| 196 | * | 197 | * |
| 197 | * Returns a negative error code or 0 | 198 | * Returns a negative error code or 0 |
| 198 | * The key words are stored in *key on success. | 199 | * The key words are stored in *key on success. |
| @@ -203,7 +204,8 @@ static void drop_futex_key_refs(union futex_key *key) | |||
| 203 | * | 204 | * |
| 204 | * lock_page() might sleep, the caller should not hold a spinlock. | 205 | * lock_page() might sleep, the caller should not hold a spinlock. |
| 205 | */ | 206 | */ |
| 206 | static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) | 207 | static int |
| 208 | get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw) | ||
| 207 | { | 209 | { |
| 208 | unsigned long address = (unsigned long)uaddr; | 210 | unsigned long address = (unsigned long)uaddr; |
| 209 | struct mm_struct *mm = current->mm; | 211 | struct mm_struct *mm = current->mm; |
| @@ -226,7 +228,7 @@ static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) | |||
| 226 | * but access_ok() should be faster than find_vma() | 228 | * but access_ok() should be faster than find_vma() |
| 227 | */ | 229 | */ |
| 228 | if (!fshared) { | 230 | if (!fshared) { |
| 229 | if (unlikely(!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))) | 231 | if (unlikely(!access_ok(rw, uaddr, sizeof(u32)))) |
| 230 | return -EFAULT; | 232 | return -EFAULT; |
| 231 | key->private.mm = mm; | 233 | key->private.mm = mm; |
| 232 | key->private.address = address; | 234 | key->private.address = address; |
| @@ -235,7 +237,7 @@ static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key) | |||
| 235 | } | 237 | } |
| 236 | 238 | ||
| 237 | again: | 239 | again: |
| 238 | err = get_user_pages_fast(address, 1, 0, &page); | 240 | err = get_user_pages_fast(address, 1, rw == VERIFY_WRITE, &page); |
| 239 | if (err < 0) | 241 | if (err < 0) |
| 240 | return err; | 242 | return err; |
| 241 | 243 | ||
| @@ -677,7 +679,7 @@ static int futex_wake(u32 __user *uaddr, int fshared, int nr_wake, u32 bitset) | |||
| 677 | if (!bitset) | 679 | if (!bitset) |
| 678 | return -EINVAL; | 680 | return -EINVAL; |
| 679 | 681 | ||
| 680 | ret = get_futex_key(uaddr, fshared, &key); | 682 | ret = get_futex_key(uaddr, fshared, &key, VERIFY_READ); |
| 681 | if (unlikely(ret != 0)) | 683 | if (unlikely(ret != 0)) |
| 682 | goto out; | 684 | goto out; |
| 683 | 685 | ||
| @@ -723,10 +725,10 @@ futex_wake_op(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, | |||
| 723 | int ret, op_ret; | 725 | int ret, op_ret; |
| 724 | 726 | ||
| 725 | retry: | 727 | retry: |
| 726 | ret = get_futex_key(uaddr1, fshared, &key1); | 728 | ret = get_futex_key(uaddr1, fshared, &key1, VERIFY_READ); |
| 727 | if (unlikely(ret != 0)) | 729 | if (unlikely(ret != 0)) |
| 728 | goto out; | 730 | goto out; |
| 729 | ret = get_futex_key(uaddr2, fshared, &key2); | 731 | ret = get_futex_key(uaddr2, fshared, &key2, VERIFY_WRITE); |
| 730 | if (unlikely(ret != 0)) | 732 | if (unlikely(ret != 0)) |
| 731 | goto out_put_key1; | 733 | goto out_put_key1; |
| 732 | 734 | ||
| @@ -814,10 +816,10 @@ static int futex_requeue(u32 __user *uaddr1, int fshared, u32 __user *uaddr2, | |||
| 814 | int ret, drop_count = 0; | 816 | int ret, drop_count = 0; |
| 815 | 817 | ||
| 816 | retry: | 818 | retry: |
| 817 | ret = get_futex_key(uaddr1, fshared, &key1); | 819 | ret = get_futex_key(uaddr1, fshared, &key1, VERIFY_READ); |
| 818 | if (unlikely(ret != 0)) | 820 | if (unlikely(ret != 0)) |
| 819 | goto out; | 821 | goto out; |
| 820 | ret = get_futex_key(uaddr2, fshared, &key2); | 822 | ret = get_futex_key(uaddr2, fshared, &key2, VERIFY_READ); |
| 821 | if (unlikely(ret != 0)) | 823 | if (unlikely(ret != 0)) |
| 822 | goto out_put_key1; | 824 | goto out_put_key1; |
| 823 | 825 | ||
| @@ -1140,7 +1142,7 @@ static int futex_wait(u32 __user *uaddr, int fshared, | |||
| 1140 | q.bitset = bitset; | 1142 | q.bitset = bitset; |
| 1141 | retry: | 1143 | retry: |
| 1142 | q.key = FUTEX_KEY_INIT; | 1144 | q.key = FUTEX_KEY_INIT; |
| 1143 | ret = get_futex_key(uaddr, fshared, &q.key); | 1145 | ret = get_futex_key(uaddr, fshared, &q.key, VERIFY_READ); |
| 1144 | if (unlikely(ret != 0)) | 1146 | if (unlikely(ret != 0)) |
| 1145 | goto out; | 1147 | goto out; |
| 1146 | 1148 | ||
| @@ -1330,7 +1332,7 @@ static int futex_lock_pi(u32 __user *uaddr, int fshared, | |||
| 1330 | q.pi_state = NULL; | 1332 | q.pi_state = NULL; |
| 1331 | retry: | 1333 | retry: |
| 1332 | q.key = FUTEX_KEY_INIT; | 1334 | q.key = FUTEX_KEY_INIT; |
| 1333 | ret = get_futex_key(uaddr, fshared, &q.key); | 1335 | ret = get_futex_key(uaddr, fshared, &q.key, VERIFY_WRITE); |
| 1334 | if (unlikely(ret != 0)) | 1336 | if (unlikely(ret != 0)) |
| 1335 | goto out; | 1337 | goto out; |
| 1336 | 1338 | ||
| @@ -1594,7 +1596,7 @@ retry: | |||
| 1594 | if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) | 1596 | if ((uval & FUTEX_TID_MASK) != task_pid_vnr(current)) |
| 1595 | return -EPERM; | 1597 | return -EPERM; |
| 1596 | 1598 | ||
| 1597 | ret = get_futex_key(uaddr, fshared, &key); | 1599 | ret = get_futex_key(uaddr, fshared, &key, VERIFY_WRITE); |
| 1598 | if (unlikely(ret != 0)) | 1600 | if (unlikely(ret != 0)) |
| 1599 | goto out; | 1601 | goto out; |
| 1600 | 1602 | ||
diff --git a/kernel/kexec.c b/kernel/kexec.c index 5a758c6e4950..e4983770913b 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
| @@ -1451,7 +1451,6 @@ int kernel_kexec(void) | |||
| 1451 | error = device_suspend(PMSG_FREEZE); | 1451 | error = device_suspend(PMSG_FREEZE); |
| 1452 | if (error) | 1452 | if (error) |
| 1453 | goto Resume_console; | 1453 | goto Resume_console; |
| 1454 | device_pm_lock(); | ||
| 1455 | /* At this point, device_suspend() has been called, | 1454 | /* At this point, device_suspend() has been called, |
| 1456 | * but *not* device_power_down(). We *must* | 1455 | * but *not* device_power_down(). We *must* |
| 1457 | * device_power_down() now. Otherwise, drivers for | 1456 | * device_power_down() now. Otherwise, drivers for |
| @@ -1489,7 +1488,6 @@ int kernel_kexec(void) | |||
| 1489 | enable_nonboot_cpus(); | 1488 | enable_nonboot_cpus(); |
| 1490 | device_power_up(PMSG_RESTORE); | 1489 | device_power_up(PMSG_RESTORE); |
| 1491 | Resume_devices: | 1490 | Resume_devices: |
| 1492 | device_pm_unlock(); | ||
| 1493 | device_resume(PMSG_RESTORE); | 1491 | device_resume(PMSG_RESTORE); |
| 1494 | Resume_console: | 1492 | Resume_console: |
| 1495 | resume_console(); | 1493 | resume_console(); |
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index b0dc9e7a0d17..5cb080e7eebd 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
| @@ -215,8 +215,6 @@ static int create_image(int platform_mode) | |||
| 215 | if (error) | 215 | if (error) |
| 216 | return error; | 216 | return error; |
| 217 | 217 | ||
| 218 | device_pm_lock(); | ||
| 219 | |||
| 220 | /* At this point, device_suspend() has been called, but *not* | 218 | /* At this point, device_suspend() has been called, but *not* |
| 221 | * device_power_down(). We *must* call device_power_down() now. | 219 | * device_power_down(). We *must* call device_power_down() now. |
| 222 | * Otherwise, drivers for some devices (e.g. interrupt controllers) | 220 | * Otherwise, drivers for some devices (e.g. interrupt controllers) |
| @@ -227,7 +225,7 @@ static int create_image(int platform_mode) | |||
| 227 | if (error) { | 225 | if (error) { |
| 228 | printk(KERN_ERR "PM: Some devices failed to power down, " | 226 | printk(KERN_ERR "PM: Some devices failed to power down, " |
| 229 | "aborting hibernation\n"); | 227 | "aborting hibernation\n"); |
| 230 | goto Unlock; | 228 | return error; |
| 231 | } | 229 | } |
| 232 | 230 | ||
| 233 | error = platform_pre_snapshot(platform_mode); | 231 | error = platform_pre_snapshot(platform_mode); |
| @@ -280,9 +278,6 @@ static int create_image(int platform_mode) | |||
| 280 | device_power_up(in_suspend ? | 278 | device_power_up(in_suspend ? |
| 281 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); | 279 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); |
| 282 | 280 | ||
| 283 | Unlock: | ||
| 284 | device_pm_unlock(); | ||
| 285 | |||
| 286 | return error; | 281 | return error; |
| 287 | } | 282 | } |
| 288 | 283 | ||
| @@ -344,13 +339,11 @@ static int resume_target_kernel(bool platform_mode) | |||
| 344 | { | 339 | { |
| 345 | int error; | 340 | int error; |
| 346 | 341 | ||
| 347 | device_pm_lock(); | ||
| 348 | |||
| 349 | error = device_power_down(PMSG_QUIESCE); | 342 | error = device_power_down(PMSG_QUIESCE); |
| 350 | if (error) { | 343 | if (error) { |
| 351 | printk(KERN_ERR "PM: Some devices failed to power down, " | 344 | printk(KERN_ERR "PM: Some devices failed to power down, " |
| 352 | "aborting resume\n"); | 345 | "aborting resume\n"); |
| 353 | goto Unlock; | 346 | return error; |
| 354 | } | 347 | } |
| 355 | 348 | ||
| 356 | error = platform_pre_restore(platform_mode); | 349 | error = platform_pre_restore(platform_mode); |
| @@ -403,9 +396,6 @@ static int resume_target_kernel(bool platform_mode) | |||
| 403 | 396 | ||
| 404 | device_power_up(PMSG_RECOVER); | 397 | device_power_up(PMSG_RECOVER); |
| 405 | 398 | ||
| 406 | Unlock: | ||
| 407 | device_pm_unlock(); | ||
| 408 | |||
| 409 | return error; | 399 | return error; |
| 410 | } | 400 | } |
| 411 | 401 | ||
| @@ -464,11 +454,9 @@ int hibernation_platform_enter(void) | |||
| 464 | goto Resume_devices; | 454 | goto Resume_devices; |
| 465 | } | 455 | } |
| 466 | 456 | ||
| 467 | device_pm_lock(); | ||
| 468 | |||
| 469 | error = device_power_down(PMSG_HIBERNATE); | 457 | error = device_power_down(PMSG_HIBERNATE); |
| 470 | if (error) | 458 | if (error) |
| 471 | goto Unlock; | 459 | goto Resume_devices; |
| 472 | 460 | ||
| 473 | error = hibernation_ops->prepare(); | 461 | error = hibernation_ops->prepare(); |
| 474 | if (error) | 462 | if (error) |
| @@ -493,9 +481,6 @@ int hibernation_platform_enter(void) | |||
| 493 | 481 | ||
| 494 | device_power_up(PMSG_RESTORE); | 482 | device_power_up(PMSG_RESTORE); |
| 495 | 483 | ||
| 496 | Unlock: | ||
| 497 | device_pm_unlock(); | ||
| 498 | |||
| 499 | Resume_devices: | 484 | Resume_devices: |
| 500 | entering_platform_hibernation = false; | 485 | entering_platform_hibernation = false; |
| 501 | device_resume(PMSG_RESTORE); | 486 | device_resume(PMSG_RESTORE); |
diff --git a/kernel/power/main.c b/kernel/power/main.c index f99ed6a75eac..868028280d13 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
| @@ -289,12 +289,10 @@ static int suspend_enter(suspend_state_t state) | |||
| 289 | { | 289 | { |
| 290 | int error; | 290 | int error; |
| 291 | 291 | ||
| 292 | device_pm_lock(); | ||
| 293 | |||
| 294 | if (suspend_ops->prepare) { | 292 | if (suspend_ops->prepare) { |
| 295 | error = suspend_ops->prepare(); | 293 | error = suspend_ops->prepare(); |
| 296 | if (error) | 294 | if (error) |
| 297 | goto Done; | 295 | return error; |
| 298 | } | 296 | } |
| 299 | 297 | ||
| 300 | error = device_power_down(PMSG_SUSPEND); | 298 | error = device_power_down(PMSG_SUSPEND); |
| @@ -343,9 +341,6 @@ static int suspend_enter(suspend_state_t state) | |||
| 343 | if (suspend_ops->finish) | 341 | if (suspend_ops->finish) |
| 344 | suspend_ops->finish(); | 342 | suspend_ops->finish(); |
| 345 | 343 | ||
| 346 | Done: | ||
| 347 | device_pm_unlock(); | ||
| 348 | |||
| 349 | return error; | 344 | return error; |
| 350 | } | 345 | } |
| 351 | 346 | ||
