[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230913-multiple-state-scu-v1-1-9d91c6904ffa@nxp.com>
Date: Wed, 13 Sep 2023 10:05:36 +0800
From: "Peng Fan (OSS)" <peng.fan@....nxp.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>,
Kevin Hilman <khilman@...nel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
Len Brown <len.brown@...el.com>, Pavel Machek <pavel@....cz>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Dong Aisheng <aisheng.dong@....com>,
Peng Fan <peng.fan@....com>
Subject: [PATCH 1/3] PM / Domains: Support enter deepest state for multiple
states domains
From: Dong Aisheng <aisheng.dong@....com>
Currently the generic power domain will power off the domain if all
devices in it have been stopped during system suspend.
It is done by checking if the domain is active in genpd_sync_power_off,
then disable it. However, for power domains supporting multiple low power
states, it may have already entered an intermediate low power state by
runtime PM before system suspend and the status is already
GPD_STATE_POWER_OFF which results in then the power domain stay at an
intermediate low power state during system suspend.
Then genpd_sync_power_off will keep it at the low power state instead
of completely gate off it.
Let's give the power domain a chance to switch to the deepest state in
case it's already off but in an intermediate low power state.
Signed-off-by: Dong Aisheng <aisheng.dong@....com>
Signed-off-by: Peng Fan <peng.fan@....com>
---
drivers/base/power/domain.c | 18 +++++++++++++++++-
include/linux/pm_domain.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5cb2023581d4..22cfa3020b18 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1124,7 +1124,17 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
{
struct gpd_link *link;
- if (!genpd_status_on(genpd) || genpd_is_always_on(genpd))
+ /*
+ * Give the power domain a chance to switch to the deepest state in
+ * case it's already off but in an intermediate low power state.
+ */
+ genpd->state_idx_saved = genpd->state_idx;
+
+ if (genpd_is_always_on(genpd))
+ return;
+
+ if (!genpd_status_on(genpd) &&
+ genpd->state_idx == (genpd->state_count - 1))
return;
if (genpd->suspended_count != genpd->device_count
@@ -1143,6 +1153,9 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
if (_genpd_power_off(genpd, false))
return;
+ if (genpd->status == GENPD_STATE_OFF)
+ return;
+
genpd->status = GENPD_STATE_OFF;
list_for_each_entry(link, &genpd->child_links, child_node) {
@@ -1189,6 +1202,9 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
}
_genpd_power_on(genpd, false);
+ /* restore save power domain state after resume */
+ genpd->state_idx = genpd->state_idx_saved;
+
genpd->status = GENPD_STATE_ON;
}
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index f776fb93eaa0..bbd08115a1fc 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -167,6 +167,7 @@ struct generic_pm_domain {
};
};
+ unsigned int state_idx_saved; /* saved power state for recovery after system suspend/resume */
};
static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
--
2.37.1
Powered by blists - more mailing lists