Skip to content

Commit f63816e

Browse files
Ulf Hanssonrafaeljw
authored andcommitted
PM: domains: Allow to abort power off when no ->power_off() callback
In genpd_power_off() we may decide to abort the power off of the PM domain, even beyond the point when the governor would accept it. The abort is done if it turns out that a child domain has been requested to be powered on, which means it's waiting for the lock of the parent to be released. However, the abort is currently only considered if the genpd in question has a ->power_off() callback assigned. This is unnecessary limiting, especially if the genpd would have a parent of its own. Let's remove the limitation and make the behaviour consistent. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> [ rjw: Subject edit ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 49f618e commit f63816e

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

drivers/base/power/domain.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
497497
struct pm_domain_data *pdd;
498498
struct gpd_link *link;
499499
unsigned int not_suspended = 0;
500+
int ret;
500501

501502
/*
502503
* Do not try to power off the domain in the following situations:
@@ -544,24 +545,13 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
544545
if (!genpd->gov)
545546
genpd->state_idx = 0;
546547

547-
if (genpd->power_off) {
548-
int ret;
549-
550-
if (atomic_read(&genpd->sd_count) > 0)
551-
return -EBUSY;
548+
/* Don't power off, if a child domain is waiting to power on. */
549+
if (atomic_read(&genpd->sd_count) > 0)
550+
return -EBUSY;
552551

553-
/*
554-
* If sd_count > 0 at this point, one of the subdomains hasn't
555-
* managed to call genpd_power_on() for the parent yet after
556-
* incrementing it. In that case genpd_power_on() will wait
557-
* for us to drop the lock, so we can call .power_off() and let
558-
* the genpd_power_on() restore power for us (this shouldn't
559-
* happen very often).
560-
*/
561-
ret = _genpd_power_off(genpd, true);
562-
if (ret)
563-
return ret;
564-
}
552+
ret = _genpd_power_off(genpd, true);
553+
if (ret)
554+
return ret;
565555

566556
genpd->status = GENPD_STATE_OFF;
567557
genpd_update_accounting(genpd);

0 commit comments

Comments
 (0)