From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Kevin Hilman <khilman@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Dong Aisheng <aisheng.dong@nxp.com>, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 1/3] PM / Domains: Support enter deepest state for multiple states domains
Date: Wed, 13 Sep 2023 10:05:36 +0800 [thread overview]
Message-ID: <20230913-multiple-state-scu-v1-1-9d91c6904ffa@nxp.com> (raw)
In-Reply-To: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com>
From: Dong Aisheng <aisheng.dong@nxp.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@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.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
next prev parent reply other threads:[~2023-09-13 2:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 2:05 [PATCH 0/3] genpd: imx8: support multiple states Peng Fan (OSS)
2023-09-13 2:05 ` Peng Fan (OSS) [this message]
2023-09-13 2:05 ` [PATCH 2/3] PM / Domains: Choose the deepest state to enter if no devices using it Peng Fan (OSS)
2023-09-13 2:05 ` [PATCH 3/3] genpd: imx: scu-pd: add multi states support Peng Fan (OSS)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230913-multiple-state-scu-v1-1-9d91c6904ffa@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=khilman@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=peng.fan@nxp.com \
--cc=rafael@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®