Skip to content

Commit 895b661

Browse files
storulfrafaeljw
authored andcommitted
PM / Domains: Don't power on at attach for the multi PM domain case
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 <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 021c917 commit 895b661

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/base/power/domain.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ static void genpd_dev_pm_sync(struct device *dev)
22352235
}
22362236

22372237
static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
2238-
unsigned int index)
2238+
unsigned int index, bool power_on)
22392239
{
22402240
struct of_phandle_args pd_args;
22412241
struct generic_pm_domain *pd;
@@ -2271,9 +2271,11 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
22712271
dev->pm_domain->detach = genpd_dev_pm_detach;
22722272
dev->pm_domain->sync = genpd_dev_pm_sync;
22732273

2274-
genpd_lock(pd);
2275-
ret = genpd_power_on(pd, 0);
2276-
genpd_unlock(pd);
2274+
if (power_on) {
2275+
genpd_lock(pd);
2276+
ret = genpd_power_on(pd, 0);
2277+
genpd_unlock(pd);
2278+
}
22772279

22782280
if (ret)
22792281
genpd_remove_device(pd, dev);
@@ -2307,7 +2309,7 @@ int genpd_dev_pm_attach(struct device *dev)
23072309
"#power-domain-cells") != 1)
23082310
return 0;
23092311

2310-
return __genpd_dev_pm_attach(dev, dev->of_node, 0);
2312+
return __genpd_dev_pm_attach(dev, dev->of_node, 0, true);
23112313
}
23122314
EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
23132315

@@ -2359,14 +2361,14 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
23592361
}
23602362

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

2368-
pm_runtime_set_active(genpd_dev);
23692370
pm_runtime_enable(genpd_dev);
2371+
genpd_queue_power_off_work(dev_to_genpd(genpd_dev));
23702372

23712373
return genpd_dev;
23722374
}

0 commit comments

Comments
 (0)