[PATCH 2/3] PM / Domains: Choose the deepest state to enter if no devices using it

Peng Fan (OSS) peng.fan at oss.nxp.com
Tue Sep 12 19:05:37 PDT 2023


From: Dong Aisheng <aisheng.dong at nxp.com>

For a domain has no working devices anymore, let's choose the deepest state
to enter to save power. e.g. driver probe failure.

Signed-off-by: Dong Aisheng <aisheng.dong at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/base/power/domain.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 22cfa3020b18..1887eb1b3130 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -730,6 +730,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
 	if (atomic_read(&genpd->sd_count) > 0)
 		return -EBUSY;
 
+	/* Choose the deepest state if no devices using this domain */
+	if (!genpd->device_count)
+		genpd->state_idx = genpd->state_count - 1;
+
 	ret = _genpd_power_off(genpd, true);
 	if (ret) {
 		genpd->states[genpd->state_idx].rejected++;

-- 
2.37.1




More information about the linux-arm-kernel mailing list