* pm-sleep: PM / Freezer: Remove references to TIF_FREEZE in comments PM / Sleep: Add more wakeup source initialization routines PM / Hibernate: Enable usermodehelpers in hibernate() error path PM / Sleep: Make __pm_stay_awake() delete wakeup source timers PM / Sleep: Fix race conditions related to wakeup source timer function PM / Sleep: Fix possible infinite loop during wakeup source destruction PM / Hibernate: print physical addresses consistently with other parts of kernel PM: Add comment describing relationships between PM callbacks to pm.h PM / Sleep: Drop suspend_stats_update() PM / Sleep: Make enter_state() in kernel/power/suspend.c static PM / Sleep: Unify kerneldoc comments in kernel/power/suspend.c PM / Sleep: Remove unnecessary label from suspend_freeze_processes() PM / Sleep: Do not check wakeup too often in try_to_freeze_tasks() PM / Sleep: Initialize wakeup source locks in wakeup_source_add() PM / Hibernate: Refactor and simplify freezer_test_done PM / Hibernate: Thaw kernel threads in hibernation_snapshot() in error/test path PM / Freezer / Docs: Document the beauty of freeze/thaw semantics PM / Suspend: Avoid code duplication in suspend statistics update PM / Sleep: Introduce generic callbacks for new device PM phases PM / Sleep: Introduce "late suspend" and "early resume" of devices
Showing the changes to kernel (10 of 20 files). Show all
Unified · Split
| @@ -424,7 +424,7 @@ void daemonize(const char *name, ...) · 423 unmodified lines | ||
| 424 | 424 | */ |
| 425 | 425 | exit_mm(current); |
| 426 | 426 | /* |
| 427 | − * We don't want to have TIF_FREEZE set if the system-wide hibernation | |
| 427 | + * We don't want to get frozen, in case system-wide hibernation | |
| 428 | 428 | * or suspend transition begins right now. |
| 429 | 429 | */ |
| 430 | 430 | current->flags |= (PF_NOFREEZE | PF_KTHREAD); |
| @@ -99,9 +99,9 @@ static void fake_signal_wake_up(struct task_struct *p) · 98 unmodified lines | ||
| 99 | 99 | * freeze_task - send a freeze request to given task |
| 100 | 100 | * @p: task to send the request to |
| 101 | 101 | * |
| 102 | − * If @p is freezing, the freeze request is sent by setting %TIF_FREEZE | |
| 103 | − * flag and either sending a fake signal to it or waking it up, depending | |
| 104 | − * on whether it has %PF_FREEZER_NOSIG set. | |
| 102 | + * If @p is freezing, the freeze request is sent either by sending a fake | |
| 103 | + * signal (if it's not a kernel thread) or waking it up (if it's a kernel | |
| 104 | + * thread). | |
| 105 | 105 | * |
| 106 | 106 | * RETURNS: |
| 107 | 107 | * %false, if @p is not freezing or already frozen; %true, otherwise |
| @@ -1546,13 +1546,13 @@ int kernel_kexec(void) · 1545 unmodified lines | ||
| 1546 | 1546 | if (error) |
| 1547 | 1547 | goto Resume_console; |
| 1548 | 1548 | /* At this point, dpm_suspend_start() has been called, |
| 1549 | − * but *not* dpm_suspend_noirq(). We *must* call | |
| 1550 | − * dpm_suspend_noirq() now. Otherwise, drivers for | |
| 1549 | + * but *not* dpm_suspend_end(). We *must* call | |
| 1550 | + * dpm_suspend_end() now. Otherwise, drivers for | |
| 1551 | 1551 | * some devices (e.g. interrupt controllers) become |
| 1552 | 1552 | * desynchronized with the actual state of the |
| 1553 | 1553 | * hardware at resume time, and evil weirdness ensues. |
| 1554 | 1554 | */ |
| 1555 | − error = dpm_suspend_noirq(PMSG_FREEZE); | |
| 1555 | + error = dpm_suspend_end(PMSG_FREEZE); | |
| 1556 | 1556 | if (error) |
| 1557 | 1557 | goto Resume_devices; |
| 1558 | 1558 | error = disable_nonboot_cpus(); |
| @@ -1579,7 +1579,7 @@ int kernel_kexec(void) · 20 unmodified lines | ||
| 1579 | 1579 | local_irq_enable(); |
| 1580 | 1580 | Enable_cpus: |
| 1581 | 1581 | enable_nonboot_cpus(); |
| 1582 | − dpm_resume_noirq(PMSG_RESTORE); | |
| 1582 | + dpm_resume_start(PMSG_RESTORE); | |
| 1583 | 1583 | Resume_devices: |
| 1584 | 1584 | dpm_resume_end(PMSG_RESTORE); |
| 1585 | 1585 | Resume_console: |
| @@ -245,8 +245,8 @@ void swsusp_show_speed(struct timeval *start, struct timeval *stop, · 244 unmodified lines | ||
| 245 | 245 | * create_image - Create a hibernation image. |
| 246 | 246 | * @platform_mode: Whether or not to use the platform driver. |
| 247 | 247 | * |
| 248 | − * Execute device drivers' .freeze_noirq() callbacks, create a hibernation image | |
| 249 | − * and execute the drivers' .thaw_noirq() callbacks. | |
| 248 | + * Execute device drivers' "late" and "noirq" freeze callbacks, create a | |
| 249 | + * hibernation image and run the drivers' "noirq" and "early" thaw callbacks. | |
| 250 | 250 | * |
| 251 | 251 | * Control reappears in this routine after the subsequent restore. |
| 252 | 252 | */ |
| @@ -254,7 +254,7 @@ static int create_image(int platform_mode) · 1 unmodified line | ||
| 254 | 254 | { |
| 255 | 255 | int error; |
| 256 | 256 | |
| 257 | − error = dpm_suspend_noirq(PMSG_FREEZE); | |
| 257 | + error = dpm_suspend_end(PMSG_FREEZE); | |
| 258 | 258 | if (error) { |
| 259 | 259 | printk(KERN_ERR "PM: Some devices failed to power down, " |
| 260 | 260 | "aborting hibernation\n"); |
| @@ -306,7 +306,7 @@ static int create_image(int platform_mode) · 45 unmodified lines | ||
| 306 | 306 | Platform_finish: |
| 307 | 307 | platform_finish(platform_mode); |
| 308 | 308 | |
| 309 | − dpm_resume_noirq(in_suspend ? | |
| 309 | + dpm_resume_start(in_suspend ? | |
| 310 | 310 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); |
| 311 | 311 | |
| 312 | 312 | return error; |
| @@ -343,13 +343,13 @@ int hibernation_snapshot(int platform_mode) · 30 unmodified lines | ||
| 343 | 343 | * successful freezer test. |
| 344 | 344 | */ |
| 345 | 345 | freezer_test_done = true; |
| 346 | − goto Cleanup; | |
| 346 | + goto Thaw; | |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | error = dpm_prepare(PMSG_FREEZE); |
| 350 | 350 | if (error) { |
| 351 | 351 | dpm_complete(PMSG_RECOVER); |
| 352 | − goto Cleanup; | |
| 352 | + goto Thaw; | |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | suspend_console(); |
| @@ -385,6 +385,8 @@ int hibernation_snapshot(int platform_mode) · 29 unmodified lines | ||
| 385 | 385 | platform_end(platform_mode); |
| 386 | 386 | return error; |
| 387 | 387 | |
| 388 | + Thaw: | |
| 389 | + thaw_kernel_threads(); | |
| 388 | 390 | Cleanup: |
| 389 | 391 | swsusp_free(); |
| 390 | 392 | goto Close; |
| @@ -394,16 +396,16 @@ int hibernation_snapshot(int platform_mode) · 3 unmodified lines | ||
| 394 | 396 | * resume_target_kernel - Restore system state from a hibernation image. |
| 395 | 397 | * @platform_mode: Whether or not to use the platform driver. |
| 396 | 398 | * |
| 397 | − * Execute device drivers' .freeze_noirq() callbacks, restore the contents of | |
| 398 | − * highmem that have not been restored yet from the image and run the low-level | |
| 399 | − * code that will restore the remaining contents of memory and switch to the | |
| 400 | − * just restored target kernel. | |
| 399 | + * Execute device drivers' "noirq" and "late" freeze callbacks, restore the | |
| 400 | + * contents of highmem that have not been restored yet from the image and run | |
| 401 | + * the low-level code that will restore the remaining contents of memory and | |
| 402 | + * switch to the just restored target kernel. | |
| 401 | 403 | */ |
| 402 | 404 | static int resume_target_kernel(bool platform_mode) |
| 403 | 405 | { |
| 404 | 406 | int error; |
| 405 | 407 | |
| 406 | − error = dpm_suspend_noirq(PMSG_QUIESCE); | |
| 408 | + error = dpm_suspend_end(PMSG_QUIESCE); | |
| 407 | 409 | if (error) { |
| 408 | 410 | printk(KERN_ERR "PM: Some devices failed to power down, " |
| 409 | 411 | "aborting resume\n"); |
| @@ -460,7 +462,7 @@ static int resume_target_kernel(bool platform_mode) · 50 unmodified lines | ||
| 460 | 462 | Cleanup: |
| 461 | 463 | platform_restore_cleanup(platform_mode); |
| 462 | 464 | |
| 463 | − dpm_resume_noirq(PMSG_RECOVER); | |
| 465 | + dpm_resume_start(PMSG_RECOVER); | |
| 464 | 466 | |
| 465 | 467 | return error; |
| 466 | 468 | } |
| @@ -518,7 +520,7 @@ int hibernation_platform_enter(void) · 51 unmodified lines | ||
| 518 | 520 | goto Resume_devices; |
| 519 | 521 | } |
| 520 | 522 | |
| 521 | − error = dpm_suspend_noirq(PMSG_HIBERNATE); | |
| 523 | + error = dpm_suspend_end(PMSG_HIBERNATE); | |
| 522 | 524 | if (error) |
| 523 | 525 | goto Resume_devices; |
| 524 | 526 | |
| @@ -549,7 +551,7 @@ int hibernation_platform_enter(void) · 24 unmodified lines | ||
| 549 | 551 | Platform_finish: |
| 550 | 552 | hibernation_ops->finish(); |
| 551 | 553 | |
| 552 | − dpm_resume_noirq(PMSG_RESTORE); | |
| 554 | + dpm_resume_start(PMSG_RESTORE); | |
| 553 | 555 | |
| 554 | 556 | Resume_devices: |
| 555 | 557 | entering_platform_hibernation = false; |
| @@ -616,7 +618,7 @@ int hibernate(void) · 60 unmodified lines | ||
| 616 | 618 | /* Allocate memory management structures */ |
| 617 | 619 | error = create_basic_memory_bitmaps(); |
| 618 | 620 | if (error) |
| 619 | − goto Exit; | |
| 621 | + goto Enable_umh; | |
| 620 | 622 | |
| 621 | 623 | printk(KERN_INFO "PM: Syncing filesystems ... "); |
| 622 | 624 | sys_sync(); |
| @@ -624,15 +626,11 @@ int hibernate(void) · 1 unmodified line | ||
| 624 | 626 | |
| 625 | 627 | error = freeze_processes(); |
| 626 | 628 | if (error) |
| 627 | − goto Finish; | |
| 629 | + goto Free_bitmaps; | |
| 628 | 630 | |
| 629 | 631 | error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM); |
| 630 | − if (error) | |
| 631 | − goto Thaw; | |
| 632 | − if (freezer_test_done) { | |
| 633 | − freezer_test_done = false; | |
| 632 | + if (error || freezer_test_done) | |
| 634 | 633 | goto Thaw; |
| 635 | − } | |
| 636 | 634 | |
| 637 | 635 | if (in_suspend) { |
| 638 | 636 | unsigned int flags = 0; |
| @@ -657,8 +655,13 @@ int hibernate(void) · 18 unmodified lines | ||
| 657 | 655 | |
| 658 | 656 | Thaw: |
| 659 | 657 | thaw_processes(); |
| 660 | − Finish: | |
| 658 | + | |
| 659 | + /* Don't bother checking whether freezer_test_done is true */ | |
| 660 | + freezer_test_done = false; | |
| 661 | + | |
| 662 | + Free_bitmaps: | |
| 661 | 663 | free_basic_memory_bitmaps(); |
| 664 | + Enable_umh: | |
| 662 | 665 | usermodehelper_enable(); |
| 663 | 666 | Exit: |
| 664 | 667 | pm_notifier_call_chain(PM_POST_HIBERNATION); |
| @@ -165,16 +165,20 @@ static int suspend_stats_show(struct seq_file *s, void *unused) · 164 unmodified lines | ||
| 165 | 165 | last_errno %= REC_FAILED_NUM; |
| 166 | 166 | last_step = suspend_stats.last_failed_step + REC_FAILED_NUM - 1; |
| 167 | 167 | last_step %= REC_FAILED_NUM; |
| 168 | − seq_printf(s, "%s: %d\n%s: %d\n%s: %d\n%s: %d\n" | |
| 169 | − "%s: %d\n%s: %d\n%s: %d\n%s: %d\n", | |
| 168 | + seq_printf(s, "%s: %d\n%s: %d\n%s: %d\n%s: %d\n%s: %d\n" | |
| 169 | + "%s: %d\n%s: %d\n%s: %d\n%s: %d\n%s: %d\n", | |
| 170 | 170 | "success", suspend_stats.success, |
| 171 | 171 | "fail", suspend_stats.fail, |
| 172 | 172 | "failed_freeze", suspend_stats.failed_freeze, |
| 173 | 173 | "failed_prepare", suspend_stats.failed_prepare, |
| 174 | 174 | "failed_suspend", suspend_stats.failed_suspend, |
| 175 | + "failed_suspend_late", | |
| 176 | + suspend_stats.failed_suspend_late, | |
| 175 | 177 | "failed_suspend_noirq", |
| 176 | 178 | suspend_stats.failed_suspend_noirq, |
| 177 | 179 | "failed_resume", suspend_stats.failed_resume, |
| 180 | + "failed_resume_early", | |
| 181 | + suspend_stats.failed_resume_early, | |
| 178 | 182 | "failed_resume_noirq", |
| 179 | 183 | suspend_stats.failed_resume_noirq); |
| 180 | 184 | seq_printf(s, "failures:\n last_failed_dev:\t%-s\n", |
| @@ -287,16 +291,10 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr, · 106 unmodified lines | ||
| 287 | 291 | |
| 288 | 292 | #ifdef CONFIG_SUSPEND |
| 289 | 293 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { |
| 290 | − if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) | |
| 294 | + if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) { | |
| 295 | + error = pm_suspend(state); | |
| 291 | 296 | break; |
| 292 | − } | |
| 293 | − if (state < PM_SUSPEND_MAX && *s) { | |
| 294 | − error = enter_state(state); | |
| 295 | − if (error) { | |
| 296 | − suspend_stats.fail++; | |
| 297 | − dpm_save_failed_errno(error); | |
| 298 | − } else | |
| 299 | − suspend_stats.success++; | |
| 297 | + } | |
| 300 | 298 | } |
| 301 | 299 | #endif |
| 302 | 300 | |
| @@ -177,13 +177,11 @@ extern const char *const pm_states[]; · 176 unmodified lines | ||
| 177 | 177 | |
| 178 | 178 | extern bool valid_state(suspend_state_t state); |
| 179 | 179 | extern int suspend_devices_and_enter(suspend_state_t state); |
| 180 | −extern int enter_state(suspend_state_t state); | |
| 181 | 180 | #else /* !CONFIG_SUSPEND */ |
| 182 | 181 | static inline int suspend_devices_and_enter(suspend_state_t state) |
| 183 | 182 | { |
| 184 | 183 | return -ENOSYS; |
| 185 | 184 | } |
| 186 | −static inline int enter_state(suspend_state_t state) { return -ENOSYS; } | |
| 187 | 185 | static inline bool valid_state(suspend_state_t state) { return false; } |
| 188 | 186 | #endif /* !CONFIG_SUSPEND */ |
| 189 | 187 | |
| @@ -234,16 +232,14 @@ static inline int suspend_freeze_processes(void) · 44 unmodified lines | ||
| 234 | 232 | int error; |
| 235 | 233 | |
| 236 | 234 | error = freeze_processes(); |
| 237 | − | |
| 238 | 235 | /* |
| 239 | 236 | * freeze_processes() automatically thaws every task if freezing |
| 240 | 237 | * fails. So we need not do anything extra upon error. |
| 241 | 238 | */ |
| 242 | 239 | if (error) |
| 243 | − goto Finish; | |
| 240 | + return error; | |
| 244 | 241 | |
| 245 | 242 | error = freeze_kernel_threads(); |
| 246 | − | |
| 247 | 243 | /* |
| 248 | 244 | * freeze_kernel_threads() thaws only kernel threads upon freezing |
| 249 | 245 | * failure. So we have to thaw the userspace tasks ourselves. |
| @@ -251,7 +247,6 @@ static inline int suspend_freeze_processes(void) · 1 unmodified line | ||
| 251 | 247 | if (error) |
| 252 | 248 | thaw_processes(); |
| 253 | 249 | |
| 254 | − Finish: | |
| 255 | 250 | return error; |
| 256 | 251 | } |
| 257 | 252 | |
| @@ -53,11 +53,9 @@ static int try_to_freeze_tasks(bool user_only) · 52 unmodified lines | ||
| 53 | 53 | * It is "frozen enough". If the task does wake |
| 54 | 54 | * up, it will immediately call try_to_freeze. |
| 55 | 55 | * |
| 56 | − * Because freeze_task() goes through p's | |
| 57 | − * scheduler lock after setting TIF_FREEZE, it's | |
| 58 | − * guaranteed that either we see TASK_RUNNING or | |
| 59 | − * try_to_stop() after schedule() in ptrace/signal | |
| 60 | − * stop sees TIF_FREEZE. | |
| 56 | + * Because freeze_task() goes through p's scheduler lock, it's | |
| 57 | + * guaranteed that TASK_STOPPED/TRACED -> TASK_RUNNING | |
| 58 | + * transition can't race with task state testing here. | |
| 61 | 59 | */ |
| 62 | 60 | if (!task_is_stopped_or_traced(p) && |
| 63 | 61 | !freezer_should_skip(p)) |
| @@ -98,13 +96,15 @@ static int try_to_freeze_tasks(bool user_only) · 34 unmodified lines | ||
| 98 | 96 | elapsed_csecs / 100, elapsed_csecs % 100, |
| 99 | 97 | todo - wq_busy, wq_busy); |
| 100 | 98 | |
| 101 | − read_lock(&tasklist_lock); | |
| 102 | − do_each_thread(g, p) { | |
| 103 | − if (!wakeup && !freezer_should_skip(p) && | |
| 104 | − p != current && freezing(p) && !frozen(p)) | |
| 105 | − sched_show_task(p); | |
| 106 | − } while_each_thread(g, p); | |
| 107 | − read_unlock(&tasklist_lock); | |
| 99 | + if (!wakeup) { | |
| 100 | + read_lock(&tasklist_lock); | |
| 101 | + do_each_thread(g, p) { | |
| 102 | + if (p != current && !freezer_should_skip(p) | |
| 103 | + && freezing(p) && !frozen(p)) | |
| 104 | + sched_show_task(p); | |
| 105 | + } while_each_thread(g, p); | |
| 106 | + read_unlock(&tasklist_lock); | |
| 107 | + } | |
| 108 | 108 | } else { |
| 109 | 109 | printk("(elapsed %d.%02d seconds) ", elapsed_csecs / 100, |
| 110 | 110 | elapsed_csecs % 100); |
| @@ -711,9 +711,10 @@ static void mark_nosave_pages(struct memory_bitmap *bm) · 710 unmodified lines | ||
| 711 | 711 | list_for_each_entry(region, &nosave_regions, list) { |
| 712 | 712 | unsigned long pfn; |
| 713 | 713 | |
| 714 | − pr_debug("PM: Marking nosave pages: %016lx - %016lx\n", | |
| 715 | − region->start_pfn << PAGE_SHIFT, | |
| 716 | − region->end_pfn << PAGE_SHIFT); | |
| 714 | + pr_debug("PM: Marking nosave pages: [mem %#010llx-%#010llx]\n", | |
| 715 | + (unsigned long long) region->start_pfn << PAGE_SHIFT, | |
| 716 | + ((unsigned long long) region->end_pfn << PAGE_SHIFT) | |
| 717 | + - 1); | |
| 717 | 718 | |
| 718 | 719 | for (pfn = region->start_pfn; pfn < region->end_pfn; pfn++) |
| 719 | 720 | if (pfn_valid(pfn)) { |
| @@ -37,8 +37,8 @@ const char *const pm_states[PM_SUSPEND_MAX] = { · 36 unmodified lines | ||
| 37 | 37 | static const struct platform_suspend_ops *suspend_ops; |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | − * suspend_set_ops - Set the global suspend method table. | |
| 41 | − * @ops: Pointer to ops structure. | |
| 40 | + * suspend_set_ops - Set the global suspend method table. | |
| 41 | + * @ops: Suspend operations to use. | |
| 42 | 42 | */ |
| 43 | 43 | void suspend_set_ops(const struct platform_suspend_ops *ops) |
| 44 | 44 | { |
| @@ -58,11 +58,11 @@ bool valid_state(suspend_state_t state) · 13 unmodified lines | ||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | − * suspend_valid_only_mem - generic memory-only valid callback | |
| 61 | + * suspend_valid_only_mem - Generic memory-only valid callback. | |
| 62 | 62 | * |
| 63 | − * Platform drivers that implement mem suspend only and only need | |
| 64 | − * to check for that in their .valid callback can use this instead | |
| 65 | − * of rolling their own .valid callback. | |
| 63 | + * Platform drivers that implement mem suspend only and only need to check for | |
| 64 | + * that in their .valid() callback can use this instead of rolling their own | |
| 65 | + * .valid() callback. | |
| 66 | 66 | */ |
| 67 | 67 | int suspend_valid_only_mem(suspend_state_t state) |
| 68 | 68 | { |
| @@ -83,10 +83,11 @@ static int suspend_test(int level) · 14 unmodified lines | ||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | − * suspend_prepare - Do prep work before entering low-power state. | |
| 86 | + * suspend_prepare - Prepare for entering system sleep state. | |
| 87 | 87 | * |
| 88 | − * This is common code that is called for each state that we're entering. | |
| 89 | − * Run suspend notifiers, allocate a console and stop all processes. | |
| 88 | + * Common code run for every system sleep state that can be entered (except for | |
| 89 | + * hibernation). Run suspend notifiers, allocate the "suspend" console and | |
| 90 | + * freeze processes. | |
| 90 | 91 | */ |
| 91 | 92 | static int suspend_prepare(void) |
| 92 | 93 | { |
| @@ -131,9 +132,9 @@ void __attribute__ ((weak)) arch_suspend_enable_irqs(void) · 38 unmodified lines | ||
| 131 | 132 | } |
| 132 | 133 | |
| 133 | 134 | /** |
| 134 | − * suspend_enter - enter the desired system sleep state. | |
| 135 | − * @state: State to enter | |
| 136 | − * @wakeup: Returns information that suspend should not be entered again. | |
| 135 | + * suspend_enter - Make the system enter the given sleep state. | |
| 136 | + * @state: System sleep state to enter. | |
| 137 | + * @wakeup: Returns information that the sleep state should not be re-entered. | |
| 137 | 138 | * |
| 138 | 139 | * This function should be called after devices have been suspended. |
| 139 | 140 | */ |
| @@ -147,7 +148,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) · 7 unmodified lines | ||
| 147 | 148 | goto Platform_finish; |
| 148 | 149 | } |
| 149 | 150 | |
| 150 | − error = dpm_suspend_noirq(PMSG_SUSPEND); | |
| 151 | + error = dpm_suspend_end(PMSG_SUSPEND); | |
| 151 | 152 | if (error) { |
| 152 | 153 | printk(KERN_ERR "PM: Some devices failed to power down\n"); |
| 153 | 154 | goto Platform_finish; |
| @@ -189,7 +190,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) · 35 unmodified lines | ||
| 189 | 190 | if (suspend_ops->wake) |
| 190 | 191 | suspend_ops->wake(); |
| 191 | 192 | |
| 192 | − dpm_resume_noirq(PMSG_RESUME); | |
| 193 | + dpm_resume_start(PMSG_RESUME); | |
| 193 | 194 | |
| 194 | 195 | Platform_finish: |
| 195 | 196 | if (suspend_ops->finish) |
| @@ -199,9 +200,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) · 3 unmodified lines | ||
| 199 | 200 | } |
| 200 | 201 | |
| 201 | 202 | /** |
| 202 | − * suspend_devices_and_enter - suspend devices and enter the desired system | |
| 203 | − * sleep state. | |
| 204 | − * @state: state to enter | |
| 203 | + * suspend_devices_and_enter - Suspend devices and enter system sleep state. | |
| 204 | + * @state: System sleep state to enter. | |
| 205 | 205 | */ |
| 206 | 206 | int suspend_devices_and_enter(suspend_state_t state) |
| 207 | 207 | { |
| @@ -251,10 +251,10 @@ int suspend_devices_and_enter(suspend_state_t state) · 43 unmodified lines | ||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | − * suspend_finish - Do final work before exiting suspend sequence. | |
| 254 | + * suspend_finish - Clean up before finishing the suspend sequence. | |
| 255 | 255 | * |
| 256 | − * Call platform code to clean up, restart processes, and free the | |
| 257 | − * console that we've allocated. This is not called for suspend-to-disk. | |
| 256 | + * Call platform code to clean up, restart processes, and free the console that | |
| 257 | + * we've allocated. This routine is not called for hibernation. | |
| 258 | 258 | */ |
| 259 | 259 | static void suspend_finish(void) |
| 260 | 260 | { |
| @@ -265,16 +265,14 @@ static void suspend_finish(void) · 4 unmodified lines | ||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | − * enter_state - Do common work of entering low-power state. | |
| 269 | − * @state: pm_state structure for state we're entering. | |
| 268 | + * enter_state - Do common work needed to enter system sleep state. | |
| 269 | + * @state: System sleep state to enter. | |
| 270 | 270 | * |
| 271 | − * Make sure we're the only ones trying to enter a sleep state. Fail | |
| 272 | − * if someone has beat us to it, since we don't want anything weird to | |
| 273 | − * happen when we wake up. | |
| 274 | − * Then, do the setup for suspend, enter the state, and cleaup (after | |
| 275 | − * we've woken up). | |
| 271 | + * Make sure that no one else is trying to put the system into a sleep state. | |
| 272 | + * Fail if that's not the case. Otherwise, prepare for system suspend, make the | |
| 273 | + * system enter the given sleep state and clean up after wakeup. | |
| 276 | 274 | */ |
| 277 | −int enter_state(suspend_state_t state) | |
| 275 | +static int enter_state(suspend_state_t state) | |
| 278 | 276 | { |
| 279 | 277 | int error; |
| 280 | 278 | |
| @@ -310,24 +308,26 @@ int enter_state(suspend_state_t state) · 29 unmodified lines | ||
| 310 | 308 | } |
| 311 | 309 | |
| 312 | 310 | /** |
| 313 | − * pm_suspend - Externally visible function for suspending system. | |
| 314 | − * @state: Enumerated value of state to enter. | |
| 311 | + * pm_suspend - Externally visible function for suspending the system. | |
| 312 | + * @state: System sleep state to enter. | |
| 315 | 313 | * |
| 316 | − * Determine whether or not value is within range, get state | |
| 317 | − * structure, and enter (above). | |
| 314 | + * Check if the value of @state represents one of the supported states, | |
| 315 | + * execute enter_state() and update system suspend statistics. | |
| 318 | 316 | */ |
| 319 | 317 | int pm_suspend(suspend_state_t state) |
| 320 | 318 | { |
| 321 | − int ret; | |
| 322 | − if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) { | |
| 323 | − ret = enter_state(state); | |
| 324 | − if (ret) { | |
| 325 | − suspend_stats.fail++; | |
| 326 | − dpm_save_failed_errno(ret); | |
| 327 | − } else | |
| 328 | − suspend_stats.success++; | |
| 329 | − return ret; | |
| 319 | + int error; | |
| 320 | + | |
| 321 | + if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) | |
| 322 | + return -EINVAL; | |
| 323 | + | |
| 324 | + error = enter_state(state); | |
| 325 | + if (error) { | |
| 326 | + suspend_stats.fail++; | |
| 327 | + dpm_save_failed_errno(error); | |
| 328 | + } else { | |
| 329 | + suspend_stats.success++; | |
| 330 | 330 | } |
| 331 | − return -EINVAL; | |
| 331 | + return error; | |
| 332 | 332 | } |
| 333 | 333 | EXPORT_SYMBOL(pm_suspend); |
| @@ -249,16 +249,10 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, · 248 unmodified lines | ||
| 249 | 249 | } |
| 250 | 250 | pm_restore_gfp_mask(); |
| 251 | 251 | error = hibernation_snapshot(data->platform_support); |
| 252 | − if (error) { | |
| 253 | − thaw_kernel_threads(); | |
| 254 | − } else { | |
| 252 | + if (!error) { | |
| 255 | 253 | error = put_user(in_suspend, (int __user *)arg); |
| 256 | − if (!error && !freezer_test_done) | |
| 257 | − data->ready = 1; | |
| 258 | − if (freezer_test_done) { | |
| 259 | − freezer_test_done = false; | |
| 260 | − thaw_kernel_threads(); | |
| 261 | − } | |
| 254 | + data->ready = !freezer_test_done && !error; | |
| 255 | + freezer_test_done = false; | |
| 262 | 256 | } |
| 263 | 257 | break; |
| 264 | 258 | |