2024-04-12 10:42:35

by Ulf Hansson

[permalink] [raw]
Subject: [PATCH 1/2] pmdomain: core: Update the rejected/usage counters at system suspend too

During system suspend we may try to enter a low power-state for the genpd
in question. Let's take this into account for the statistics too, by
updating the rejected/usage counters for the corresponding state.

Signed-off-by: Ulf Hansson <[email protected]>
---
drivers/pmdomain/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 4215ffd9b11c..903ea0c193e1 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1178,8 +1178,12 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,

/* Choose the deepest state when suspending */
genpd->state_idx = genpd->state_count - 1;
- if (_genpd_power_off(genpd, false))
+ if (_genpd_power_off(genpd, false)) {
+ genpd->states[genpd->state_idx].rejected++;
return;
+ } else {
+ genpd->states[genpd->state_idx].usage++;
+ }

genpd->status = GENPD_STATE_OFF;

--
2.34.1



2024-04-12 10:51:53

by Ulf Hansson

[permalink] [raw]
Subject: [PATCH 2/2] pmdomain: core: Don't clear suspended_count at genpd_prepare()

There is no longer any need to clear genpd->suspended_count in
genpd_prepare(), as it should be correctly incremented and decremented for
all cases. In fact, if the counter isn't correctly managed we would be
hiding a problem that we shouldn't. Therefore, let's not clear it.

Signed-off-by: Ulf Hansson <[email protected]>
---
drivers/pmdomain/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 903ea0c193e1..342779464c0d 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1255,10 +1255,7 @@ static int genpd_prepare(struct device *dev)
return -EINVAL;

genpd_lock(genpd);
-
- if (genpd->prepared_count++ == 0)
- genpd->suspended_count = 0;
-
+ genpd->prepared_count++;
genpd_unlock(genpd);

ret = pm_generic_prepare(dev);
--
2.34.1