diff options
| -rw-r--r-- | Documentation/power/devices.txt | 34 | ||||
| -rw-r--r-- | Documentation/power/runtime_pm.txt | 17 | ||||
| -rw-r--r-- | Documentation/power/swsusp.txt | 5 | ||||
| -rw-r--r-- | drivers/base/power/main.c | 66 | ||||
| -rw-r--r-- | drivers/cpuidle/cpuidle.c | 55 | ||||
| -rw-r--r-- | drivers/cpuidle/governors/menu.c | 17 | ||||
| -rw-r--r-- | include/linux/cpuidle.h | 7 | ||||
| -rw-r--r-- | include/linux/pm.h | 36 | ||||
| -rw-r--r-- | include/linux/pm_runtime.h | 6 | ||||
| -rw-r--r-- | kernel/power/hibernate.c | 27 | ||||
| -rw-r--r-- | kernel/power/suspend.c | 2 | ||||
| -rw-r--r-- | kernel/sched/idle.c | 20 |
12 files changed, 216 insertions, 76 deletions
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt index 47d46dff70f7..d172bce0fd49 100644 --- a/Documentation/power/devices.txt +++ b/Documentation/power/devices.txt | |||
| @@ -2,6 +2,7 @@ Device Power Management | |||
| 2 | 2 | ||
| 3 | Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. | 3 | Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. |
| 4 | Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu> | 4 | Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu> |
| 5 | Copyright (c) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 5 | 6 | ||
| 6 | 7 | ||
| 7 | Most of the code in Linux is device drivers, so most of the Linux power | 8 | Most of the code in Linux is device drivers, so most of the Linux power |
| @@ -326,6 +327,20 @@ the phases are: | |||
| 326 | driver in some way for the upcoming system power transition, but it | 327 | driver in some way for the upcoming system power transition, but it |
| 327 | should not put the device into a low-power state. | 328 | should not put the device into a low-power state. |
| 328 | 329 | ||
| 330 | For devices supporting runtime power management, the return value of the | ||
| 331 | prepare callback can be used to indicate to the PM core that it may | ||
| 332 | safely leave the device in runtime suspend (if runtime-suspended | ||
| 333 | already), provided that all of the device's descendants are also left in | ||
| 334 | runtime suspend. Namely, if the prepare callback returns a positive | ||
| 335 | number and that happens for all of the descendants of the device too, | ||
| 336 | and all of them (including the device itself) are runtime-suspended, the | ||
| 337 | PM core will skip the suspend, suspend_late and suspend_noirq suspend | ||
| 338 | phases as well as the resume_noirq, resume_early and resume phases of | ||
| 339 | the following system resume for all of these devices. In that case, | ||
| 340 | the complete callback will be called directly after the prepare callback | ||
| 341 | and is entirely responsible for bringing the device back to the | ||
| 342 | functional state as appropriate. | ||
| 343 | |||
| 329 | 2. The suspend methods should quiesce the device to stop it from performing | 344 | 2. The suspend methods should quiesce the device to stop it from performing |
| 330 | I/O. They also may save the device registers and put it into the | 345 | I/O. They also may save the device registers and put it into the |
| 331 | appropriate low-power state, depending on the bus type the device is on, | 346 | appropriate low-power state, depending on the bus type the device is on, |
| @@ -400,12 +415,23 @@ When resuming from freeze, standby or memory sleep, the phases are: | |||
| 400 | the resume callbacks occur; it's not necessary to wait until the | 415 | the resume callbacks occur; it's not necessary to wait until the |
| 401 | complete phase. | 416 | complete phase. |
| 402 | 417 | ||
| 418 | Moreover, if the preceding prepare callback returned a positive number, | ||
| 419 | the device may have been left in runtime suspend throughout the whole | ||
| 420 | system suspend and resume (the suspend, suspend_late, suspend_noirq | ||
| 421 | phases of system suspend and the resume_noirq, resume_early, resume | ||
| 422 | phases of system resume may have been skipped for it). In that case, | ||
| 423 | the complete callback is entirely responsible for bringing the device | ||
| 424 | back to the functional state after system suspend if necessary. [For | ||
| 425 | example, it may need to queue up a runtime resume request for the device | ||
| 426 | for this purpose.] To check if that is the case, the complete callback | ||
| 427 | can consult the device's power.direct_complete flag. Namely, if that | ||
| 428 | flag is set when the complete callback is being run, it has been called | ||
| 429 | directly after the preceding prepare and special action may be required | ||
| 430 | to make the device work correctly afterward. | ||
| 431 | |||
| 403 | At the end of these phases, drivers should be as functional as they were before | 432 | At the end of these phases, drivers should be as functional as they were before |
| 404 | suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are | 433 | suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are |
| 405 | gated on. Even if the device was in a low-power state before the system sleep | 434 | gated on. |
| 406 | because of runtime power management, afterwards it should be back in its | ||
| 407 | full-power state. There are multiple reasons why it's best to do this; they are | ||
| 408 | discussed in more detail in Documentation/power/runtime_pm.txt. | ||
| 409 | 435 | ||
| 410 | However, the details here may again be platform-specific. For example, | 436 | However, the details here may again be platform-specific. For example, |
| 411 | some systems support multiple "run" states, and the mode in effect at | 437 | some systems support multiple "run" states, and the mode in effect at |
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt index 5f96daf8566a..e1bee8a4aaac 100644 --- a/Documentation/power/runtime_pm.txt +++ b/Documentation/power/runtime_pm.txt | |||
| @@ -2,6 +2,7 @@ Runtime Power Management Framework for I/O Devices | |||
| 2 | 2 | ||
| 3 | (C) 2009-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. | 3 | (C) 2009-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. |
| 4 | (C) 2010 Alan Stern <stern@rowland.harvard.edu> | 4 | (C) 2010 Alan Stern <stern@rowland.harvard.edu> |
| 5 | (C) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 5 | 6 | ||
| 6 | 1. Introduction | 7 | 1. Introduction |
| 7 | 8 | ||
| @@ -444,6 +445,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h: | |||
| 444 | bool pm_runtime_status_suspended(struct device *dev); | 445 | bool pm_runtime_status_suspended(struct device *dev); |
| 445 | - return true if the device's runtime PM status is 'suspended' | 446 | - return true if the device's runtime PM status is 'suspended' |
| 446 | 447 | ||
| 448 | bool pm_runtime_suspended_if_enabled(struct device *dev); | ||
| 449 | - return true if the device's runtime PM status is 'suspended' and its | ||
| 450 | 'power.disable_depth' field is equal to 1 | ||
| 451 | |||
| 447 | void pm_runtime_allow(struct device *dev); | 452 | void pm_runtime_allow(struct device *dev); |
| 448 | - set the power.runtime_auto flag for the device and decrease its usage | 453 | - set the power.runtime_auto flag for the device and decrease its usage |
| 449 | counter (used by the /sys/devices/.../power/control interface to | 454 | counter (used by the /sys/devices/.../power/control interface to |
| @@ -644,6 +649,18 @@ place (in particular, if the system is not waking up from hibernation), it may | |||
| 644 | be more efficient to leave the devices that had been suspended before the system | 649 | be more efficient to leave the devices that had been suspended before the system |
| 645 | suspend began in the suspended state. | 650 | suspend began in the suspended state. |
| 646 | 651 | ||
| 652 | To this end, the PM core provides a mechanism allowing some coordination between | ||
| 653 | different levels of device hierarchy. Namely, if a system suspend .prepare() | ||
| 654 | callback returns a positive number for a device, that indicates to the PM core | ||
| 655 | that the device appears to be runtime-suspended and its state is fine, so it | ||
| 656 | may be left in runtime suspend provided that all of its descendants are also | ||
| 657 | left in runtime suspend. If that happens, the PM core will not execute any | ||
| 658 | system suspend and resume callbacks for all of those devices, except for the | ||
| 659 | complete callback, which is then entirely responsible for handling the device | ||
| 660 | as appropriate. This only applies to system suspend transitions that are not | ||
| 661 | related to hibernation (see Documentation/power/devices.txt for more | ||
| 662 | information). | ||
| 663 | |||
| 647 | The PM core does its best to reduce the probability of race conditions between | 664 | The PM core does its best to reduce the probability of race conditions between |
| 648 | the runtime PM and system suspend/resume (and hibernation) callbacks by carrying | 665 | the runtime PM and system suspend/resume (and hibernation) callbacks by carrying |
| 649 | out the following operations: | 666 | out the following operations: |
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt index 079160e22bcc..f732a8321e8a 100644 --- a/Documentation/power/swsusp.txt +++ b/Documentation/power/swsusp.txt | |||
| @@ -220,7 +220,10 @@ Q: After resuming, system is paging heavily, leading to very bad interactivity. | |||
| 220 | 220 | ||
| 221 | A: Try running | 221 | A: Try running |
| 222 | 222 | ||
| 223 | cat `cat /proc/[0-9]*/maps | grep / | sed 's:.* /:/:' | sort -u` > /dev/null | 223 | cat /proc/[0-9]*/maps | grep / | sed 's:.* /:/:' | sort -u | while read file |
| 224 | do | ||
| 225 | test -f "$file" && cat "$file" > /dev/null | ||
| 226 | done | ||
| 224 | 227 | ||
| 225 | after resume. swapoff -a; swapon -a may also be useful. | 228 | after resume. swapoff -a; swapon -a may also be useful. |
| 226 | 229 | ||
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 86d5e4fb5b98..343ffad59377 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
| @@ -479,7 +479,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state, bool asyn | |||
| 479 | TRACE_DEVICE(dev); | 479 | TRACE_DEVICE(dev); |
| 480 | TRACE_RESUME(0); | 480 | TRACE_RESUME(0); |
| 481 | 481 | ||
| 482 | if (dev->power.syscore) | 482 | if (dev->power.syscore || dev->power.direct_complete) |
| 483 | goto Out; | 483 | goto Out; |
| 484 | 484 | ||
| 485 | if (!dev->power.is_noirq_suspended) | 485 | if (!dev->power.is_noirq_suspended) |
| @@ -605,7 +605,7 @@ static int device_resume_early(struct device *dev, pm_message_t state, bool asyn | |||
| 605 | TRACE_DEVICE(dev); | 605 | TRACE_DEVICE(dev); |
| 606 | TRACE_RESUME(0); | 606 | TRACE_RESUME(0); |
| 607 | 607 | ||
| 608 | if (dev->power.syscore) | 608 | if (dev->power.syscore || dev->power.direct_complete) |
| 609 | goto Out; | 609 | goto Out; |
| 610 | 610 | ||
| 611 | if (!dev->power.is_late_suspended) | 611 | if (!dev->power.is_late_suspended) |
| @@ -735,6 +735,12 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) | |||
| 735 | if (dev->power.syscore) | 735 | if (dev->power.syscore) |
| 736 | goto Complete; | 736 | goto Complete; |
| 737 | 737 | ||
| 738 | if (dev->power.direct_complete) { | ||
| 739 | /* Match the pm_runtime_disable() in __device_suspend(). */ | ||
| 740 | pm_runtime_enable(dev); | ||
| 741 | goto Complete; | ||
| 742 | } | ||
| 743 | |||
| 738 | dpm_wait(dev->parent, async); | 744 | dpm_wait(dev->parent, async); |
| 739 | dpm_watchdog_set(&wd, dev); | 745 | dpm_watchdog_set(&wd, dev); |
| 740 | device_lock(dev); | 746 | device_lock(dev); |
| @@ -1007,7 +1013,7 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a | |||
| 1007 | goto Complete; | 1013 | goto Complete; |
| 1008 | } | 1014 | } |
| 1009 | 1015 | ||
| 1010 | if (dev->power.syscore) | 1016 | if (dev->power.syscore || dev->power.direct_complete) |
| 1011 | goto Complete; | 1017 | goto Complete; |
| 1012 | 1018 | ||
| 1013 | dpm_wait_for_children(dev, async); | 1019 | dpm_wait_for_children(dev, async); |
| @@ -1146,7 +1152,7 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as | |||
| 1146 | goto Complete; | 1152 | goto Complete; |
| 1147 | } | <||
