diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-07-12 02:40:03 +0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-07-12 02:40:03 +0400 |
commit | 56375fd420f851944960bd53dbb08d674f4d9406 (patch) | |
tree | 634fc52ba88aad057cbd2175d9a2b91d5dee4f01 /drivers | |
parent | 4ecd6e651dd25ebbf0cc53c68162c0ab08641725 (diff) | |
download | linux-56375fd420f851944960bd53dbb08d674f4d9406.tar.xz |
PM / Domains: Queue up power off work only if it is not pending
In theory it is possible that pm_genpd_poweroff() for two different
subdomains of the same parent domain will attempt to queue up the
execution of pm_genpd_poweroff() for the parent twice in a row. This
would lead to unpleasant consequences, so prevent it from happening
by checking if genpd->power_off_work is pending before attempting to
queue it up.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/power/domain.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b6e29ffbb70d..c3e4e2934e16 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -213,6 +213,19 @@ static bool genpd_abort_poweroff(struct generic_pm_domain *genpd) } /** + * genpd_queue_power_off_work - Queue up the execution of pm_genpd_poweroff(). + * @genpd: PM domait to power off. + * + * Queue up the execution of pm_genpd_poweroff() unless it's already been done + * before. + */ +static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) +{ + if (!work_pending(&genpd->power_off_work)) + queue_work(pm_wq, &genpd->power_off_work); +} + +/** * pm_genpd_poweroff - Remove power from a given PM domain. * @genpd: PM domain to power down. * @@ -304,7 +317,7 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd) if (parent) { genpd_sd_counter_dec(parent); if (parent->sd_count == 0) - queue_work(pm_wq, &parent->power_off_work); + genpd_queue_power_off_work(parent); genpd_release_lock(parent); } |