aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-07-11 18:39:57 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-07-11 18:39:57 -0400
commit4ecd6e651dd25ebbf0cc53c68162c0ab08641725 (patch)
tree6a9a77fde53b096432f28a691889d9f79112eec3 /drivers
parent697a7f3727b53c7d4c927948bbe1f6afc4fabfde (diff)
PM / Domains: Improve handling of wakeup devices during system suspend
Kevin points out that if there's a device that can wake up the system from sleep states, but it doesn't generate wakeup signals by itself (they are generated on its behalf by other parts of the system) and it currently is not enabled to wake up the system (that is, device_may_wakeup() returns "false" for it), we may need to change its wakeup settings during system suspend (for example, the device might have been configured to signal remote wakeup from the system's working state, as needed by runtime PM). Therefore the generic PM domains code should invoke the system suspend callbacks provided by the device's driver, which it doesn't do if the PM domain is powered off during the system suspend's "prepare" stage. This is a valid point. Moreover, this code also should make sure that system wakeup devices that are enabled to wake up the system from sleep states and have to remain active for this purpose are not suspended while the system is in a sleep state. To avoid the above issues, make the generic PM domains' .prepare() routine, pm_genpd_prepare(), force runtime resume of devices whose system wakeup settings may need to be changed during system suspend or that should remain active while the system is in a sleep state to be able to wake it up from that state. Reported-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/domain.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 7b20801d19da..b6e29ffbb70d 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -482,6 +482,33 @@ static void pm_genpd_sync_poweroff(struct generic_pm_domain *genpd)
482} 482}
483 483
484/** 484/**
485 * resume_needed - Check whether to resume a device before system suspend.
486 * @dev: Device to check.
487 * @genpd: PM domain the device belongs to.
488 *
489 * There are two cases in which a device that can wake up the system from sleep
490 * states should be resumed by pm_genpd_prepare(): (1) if the device is enabled
491 * to wake up the system and it has to remain active for this purpose while the
492 * system is in the sleep state and (2) if the device is not enabled to wake up
493 * the system from sleep states and it generally doesn't generate wakeup signals
494 * by itself (those signals are generated on its behalf by other parts of the
495 * system). In the latter case it may be necessary to reconfigure the device's
496 * wakeup settings during system suspend, because it may have been set up to
497 * signal remote wakeup from the system's working state as needed by runtime PM.
498 * Return 'true' in either of the above cases.
499 */
500static bool resume_needed(struct device *dev, struct generic_pm_domain *genpd)
501{
502 bool active_wakeup;
503
504 if (!device_can_wakeup(dev))
505 return false;
506
507 active_wakeup = genpd->active_wakeup && genpd->active_wakeup(dev);
508 return device_may_wakeup(dev) ? active_wakeup : !active_wakeup;
509}
510
511/**
485 * pm_genpd_prepare - Start power transition of a device in a PM domain. 512 * pm_genpd_prepare - Start power transition of a device in a PM domain.
486 * @dev: Device to start the transition of. 513 * @dev: Device to start the transition of.
487 * 514 *
@@ -515,6 +542,9 @@ static int pm_genpd_prepare(struct device *dev)
515 return -EBUSY; 542 return -EBUSY;
516 } 543 }
517 544
545 if (resume_needed(dev, genpd))
546 pm_runtime_resume(dev);
547
518 genpd_acquire_lock(genpd); 548 genpd_acquire_lock(genpd);
519 549
520 if (genpd->prepared_count++ == 0) 550 if (genpd->prepared_count++ == 0)