public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] PM: domains: Reverse the order of performance and enabling ops
@ 2022-07-20 11:02 Abel Vesa
  2022-07-21 16:48 ` Ulf Hansson
  0 siblings, 1 reply; 12+ messages in thread
From: Abel Vesa @ 2022-07-20 11:02 UTC (permalink / raw)
  To: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, Len Brown,
	Pavel Machek
  Cc: Bjorn Andersson, Greg Kroah-Hartman, linux-pm,
	Linux Kernel Mailing List, Abel Vesa

Rather than enabling and then setting the performance state, which usually
translates into two different levels (voltages) in order to get to the
one required by the consumer, we could give a chance to the providers to
cache the performance state needed by the consumer and then, when powering
on the power domain, the provider could use the cached level instead.
Also the drop_performance and power_off have to be reversed so that
when the last active consumer suspends, the level doesn't actually drop
until the pd is disabled.

For the power domains that do not provide the set_performance, things
remain unchanged, as does for the power domains that only provide the
set_performance but do not provide the power_on/off.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
 drivers/base/power/domain.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5a2e0232862e..38647c304b73 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -939,8 +939,8 @@ static int genpd_runtime_suspend(struct device *dev)
 		return 0;

 	genpd_lock(genpd);
-	gpd_data->rpm_pstate = genpd_drop_performance_state(dev);
 	genpd_power_off(genpd, true, 0);
+	gpd_data->rpm_pstate = genpd_drop_performance_state(dev);
 	genpd_unlock(genpd);

 	return 0;
@@ -978,9 +978,8 @@ static int genpd_runtime_resume(struct device *dev)
 		goto out;

 	genpd_lock(genpd);
+	genpd_restore_performance_state(dev, gpd_data->rpm_pstate);
 	ret = genpd_power_on(genpd, 0);
-	if (!ret)
-		genpd_restore_performance_state(dev, gpd_data->rpm_pstate);
 	genpd_unlock(genpd);

 	if (ret)
@@ -1018,8 +1017,8 @@ static int genpd_runtime_resume(struct device *dev)
 err_poweroff:
 	if (!pm_runtime_is_irq_safe(dev) || genpd_is_irq_safe(genpd)) {
 		genpd_lock(genpd);
-		gpd_data->rpm_pstate = genpd_drop_performance_state(dev);
 		genpd_power_off(genpd, true, 0);
+		gpd_data->rpm_pstate = genpd_drop_performance_state(dev);
 		genpd_unlock(genpd);
 	}

@@ -2747,17 +2746,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 	dev->pm_domain->detach = genpd_dev_pm_detach;
 	dev->pm_domain->sync = genpd_dev_pm_sync;

-	if (power_on) {
-		genpd_lock(pd);
-		ret = genpd_power_on(pd, 0);
-		genpd_unlock(pd);
-	}
-
-	if (ret) {
-		genpd_remove_device(pd, dev);
-		return -EPROBE_DEFER;
-	}
-
 	/* Set the default performance state */
 	pstate = of_get_required_opp_performance_state(dev->of_node, index);
 	if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) {
@@ -2769,6 +2757,18 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 			goto err;
 		dev_gpd_data(dev)->default_pstate = pstate;
 	}
+
+	if (power_on) {
+		genpd_lock(pd);
+		ret = genpd_power_on(pd, 0);
+		genpd_unlock(pd);
+	}
+
+	if (ret) {
+		genpd_remove_device(pd, dev);
+		return -EPROBE_DEFER;
+	}
+
 	return 1;

 err:
--
2.34.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-08-17 11:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-20 11:02 [RFC] PM: domains: Reverse the order of performance and enabling ops Abel Vesa
2022-07-21 16:48 ` Ulf Hansson
2022-07-26 18:38   ` Abel Vesa
2022-07-28 11:37     ` Ulf Hansson
2022-07-29  9:46       ` Abel Vesa
2022-08-04 20:58         ` Dmitry Osipenko
2022-08-12 15:47           ` Abel Vesa
2022-08-12 13:14         ` Ulf Hansson
2022-08-12 15:46           ` Abel Vesa
2022-08-16 10:48             ` Ulf Hansson
2022-08-16 12:23               ` Abel Vesa
2022-08-17 11:04                 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox