Skip to content

Commit

Permalink
PM / Domains: Don't power on at attach for the multi PM domain case
Browse files Browse the repository at this point in the history
There are no legacy behavior in drivers to consider while attaching a
device to genpd - for the multiple PM domain case.

For that reason, let's instead require the driver to runtime resume the
device, via calling pm_runtime_get_sync() for example, when it needs to
power on the corresponding PM domain.

This allows us to improve the situation during attach. Instead of always
power on the PM domain, which may be unnecessary, let's leave it in its
current state. Additionally, to avoid the PM domain to stay powered on,
let's schedule a power off work.

Fixes: 3c095f3 (PM / Domains: Add support for multi PM domains ...)
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
storulf authored and rafaeljw committed Jul 3, 2018
1 parent 021c917 commit 895b661
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -2235,7 +2235,7 @@ static void genpd_dev_pm_sync(struct device *dev)
}

static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
unsigned int index)
unsigned int index, bool power_on)
{
struct of_phandle_args pd_args;
struct generic_pm_domain *pd;
Expand Down Expand Up @@ -2271,9 +2271,11 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
dev->pm_domain->detach = genpd_dev_pm_detach;
dev->pm_domain->sync = genpd_dev_pm_sync;

genpd_lock(pd);
ret = genpd_power_on(pd, 0);
genpd_unlock(pd);
if (power_on) {
genpd_lock(pd);
ret = genpd_power_on(pd, 0);
genpd_unlock(pd);
}

if (ret)
genpd_remove_device(pd, dev);
Expand Down Expand Up @@ -2307,7 +2309,7 @@ int genpd_dev_pm_attach(struct device *dev)
"#power-domain-cells") != 1)
return 0;

return __genpd_dev_pm_attach(dev, dev->of_node, 0);
return __genpd_dev_pm_attach(dev, dev->of_node, 0, true);
}
EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);

Expand Down Expand Up @@ -2359,14 +2361,14 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
}

/* Try to attach the device to the PM domain at the specified index. */
ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index);
ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index, false);
if (ret < 1) {
device_unregister(genpd_dev);
return ret ? ERR_PTR(ret) : NULL;
}

pm_runtime_set_active(genpd_dev);
pm_runtime_enable(genpd_dev);
genpd_queue_power_off_work(dev_to_genpd(genpd_dev));

return genpd_dev;
}
Expand Down

0 comments on commit 895b661

Please sign in to comment.