[PATCH v2 2/4] PM: domains: Return early if perf state is already set for the device

From: Ulf Hansson
Date: Thu Jun 03 2021 - 05:35:51 EST


When dev_pm_genpd_set_performance_state() gets called to set a new
performance state for the device, let's take a quicker path by doing an
early return, if it turns out that the new state is already set for the
device.

Suggested-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
---

Changes in v2:
- New patch.

---
drivers/base/power/domain.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5c476ed1c6c9..ef25a5b18587 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -387,6 +387,9 @@ static int genpd_set_performance_state(struct device *dev, unsigned int state)
int ret;

prev_state = gpd_data->performance_state;
+ if (prev_state == state)
+ return 0;
+
gpd_data->performance_state = state;
state = _genpd_reeval_performance_state(genpd, state);

--
2.25.1