diff mbox series

[V2,5/6] PM / domain: Save/restore performance state at runtime suspend/resume

Message ID 21383233a44afe5e5144fadb82867a0a890db46f.1486611268.git.viresh.kumar@linaro.org
State New
Headers show
Series None | expand

Commit Message

Viresh Kumar Feb. 9, 2017, 3:41 a.m. UTC
With runtime PM, the devices get suspended while the system is up and
running in order to save power. At such times, it is important to
re-evaluate the required performance state of the domain, in order to
choose a lower state if possible.

This patch updates the genpd suspend/resume callbacks to do that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

---
 drivers/base/power/domain.c | 19 +++++++++++++++++--
 include/linux/pm_domain.h   |  1 +
 2 files changed, 18 insertions(+), 2 deletions(-)

-- 
2.7.1.410.g6faf27b

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Kevin Hilman Feb. 17, 2017, 11:58 p.m. UTC | #1
Viresh Kumar <viresh.kumar@linaro.org> writes:

> With runtime PM, the devices get suspended while the system is up and

> running in order to save power. At such times, it is important to

> re-evaluate the required performance state of the domain, in order to

> choose a lower state if possible.

>

> This patch updates the genpd suspend/resume callbacks to do that.

>

> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>


Doesn't this assume that a device in the domain would need to change
performance state while runtime suspended.  How would that happen?

Rather than adding this here, I would think that drivers would instead
remove any QoS requests before going into runtime suspend, which would
trigger an update before runtime suspending.

Kevin
diff mbox series

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 1158a07f92de..ce9ab18be243 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -603,7 +603,8 @@  static int genpd_runtime_suspend(struct device *dev)
 {
 	struct generic_pm_domain *genpd;
 	bool (*suspend_ok)(struct device *__dev);
-	struct gpd_timing_data *td = &dev_gpd_data(dev)->td;
+	struct generic_pm_domain_data *pd_data = dev_gpd_data(dev);
+	struct gpd_timing_data *td = &pd_data->td;
 	bool runtime_pm = pm_runtime_enabled(dev);
 	ktime_t time_start;
 	s64 elapsed_ns;
@@ -660,7 +661,14 @@  static int genpd_runtime_suspend(struct device *dev)
 		return 0;
 
 	genpd_lock(genpd);
+
+	/* Re-evaluate performance state of the domain */
+	pd_data->cached_performance_state = pd_data->performance_state;
+	pd_data->performance_state = 0;
+	update_domain_performance_state(genpd, 0);
+
 	genpd_power_off(genpd, false);
+
 	genpd_unlock(genpd);
 
 	return 0;
@@ -677,7 +685,8 @@  static int genpd_runtime_suspend(struct device *dev)
 static int genpd_runtime_resume(struct device *dev)
 {
 	struct generic_pm_domain *genpd;
-	struct gpd_timing_data *td = &dev_gpd_data(dev)->td;
+	struct generic_pm_domain_data *pd_data = dev_gpd_data(dev);
+	struct gpd_timing_data *td = &pd_data->td;
 	bool runtime_pm = pm_runtime_enabled(dev);
 	ktime_t time_start;
 	s64 elapsed_ns;
@@ -700,7 +709,13 @@  static int genpd_runtime_resume(struct device *dev)
 	}
 
 	genpd_lock(genpd);
+
 	ret = genpd_power_on(genpd, 0);
+
+	/* Re-evaluate performance state of the domain */
+	pd_data->performance_state = pd_data->cached_performance_state;
+	update_domain_performance_state(genpd, 0);
+
 	genpd_unlock(genpd);
 
 	if (ret)
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index d994ad5ba1c0..69b453d44adb 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -122,6 +122,7 @@  struct generic_pm_domain_data {
 	struct notifier_block nb;
 	struct notifier_block perf_nb;
 	unsigned int performance_state;
+	unsigned int cached_performance_state;
 };
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS