From: Ulf Hansson <ulf.hansson@linaro.org>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Sudeep Holla <sudeep.holla@arm.com>,
Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
linux-pm@vger.kernel.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Lina Iyer <ilina@codeaurora.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Stephen Boyd <sboyd@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Alexandre Torgue <alexandre.torgue@st.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] PM: domains: Enable dev_pm_genpd_suspend|resume() for suspend-to-idle
Date: Tue, 3 Nov 2020 16:06:26 +0100 [thread overview]
Message-ID: <20201103150627.233438-3-ulf.hansson@linaro.org> (raw)
In-Reply-To: <20201103150627.233438-1-ulf.hansson@linaro.org>
The dev_pm_genpd_suspend|resume() have so far only been used during the
syscore suspend/resume phases. However, during suspend-to-idle, where the
syscore phases doesn't exist, similar operations are sometimes needed.
An existing example are the timekeeping_suspend|resume() functions, which
are being called both through a registered syscore ops during the syscore
phases, but also as regular functions calls from cpuidle (via
tick_freeze()) during suspend-to-idle.
For similar reasons, let's enable the dev_pm_genpd_suspend|resume() APIs to
be re-used for corresponding CPU devices that are attached to a genpd,
during suspend-to-idle.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Changes in v2:
- Renamed and add documentation of the APIs.
- Updated the commit message and its header.
---
drivers/base/power/domain.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 9b4881b67683..4a55f3c949ae 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1366,18 +1366,27 @@ static void genpd_complete(struct device *dev)
static void genpd_switch_state(struct device *dev, bool suspend)
{
struct generic_pm_domain *genpd;
+ bool use_lock;
genpd = dev_to_genpd_safe(dev);
if (!genpd)
return;
+ use_lock = genpd_is_irq_safe(genpd);
+
+ if (use_lock)
+ genpd_lock(genpd);
+
if (suspend) {
genpd->suspended_count++;
- genpd_sync_power_off(genpd, false, 0);
+ genpd_sync_power_off(genpd, use_lock, 0);
} else {
- genpd_sync_power_on(genpd, false, 0);
+ genpd_sync_power_on(genpd, use_lock, 0);
genpd->suspended_count--;
}
+
+ if (use_lock)
+ genpd_unlock(genpd);
}
/**
@@ -1385,7 +1394,9 @@ static void genpd_switch_state(struct device *dev, bool suspend)
* @dev: The device that is attached to the genpd, that can be suspended.
*
* This routine should typically be called for a device that needs to be
- * suspended during the syscore suspend phase.
+ * suspended during the syscore suspend phase. It may also be called during
+ * suspend-to-idle to suspend a corresponding CPU device that is attached to a
+ * genpd.
*/
void dev_pm_genpd_suspend(struct device *dev)
{
@@ -1398,7 +1409,8 @@ EXPORT_SYMBOL_GPL(dev_pm_genpd_suspend);
* @dev: The device that is attached to the genpd, which needs to be resumed.
*
* This routine should typically be called for a device that needs to be resumed
- * during the syscore resume phase.
+ * during the syscore resume phase. It may also be called during suspend-to-idle
+ * to resume a corresponding CPU device that is attached to a genpd.
*/
void dev_pm_genpd_resume(struct device *dev)
{
--
2.25.1
next prev parent reply other threads:[~2020-11-03 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 15:06 [PATCH v2 0/3] cpuidle: psci: Enable s2idle when using PSCI OSI Ulf Hansson
2020-11-03 15:06 ` [PATCH v2 1/3] PM: domains: Rename pm_genpd_syscore_poweroff|poweron() Ulf Hansson
2020-11-03 15:06 ` Ulf Hansson [this message]
2020-11-03 15:06 ` [PATCH v2 3/3] cpuidle: psci: Enable suspend-to-idle for PSCI OSI mode Ulf Hansson
2020-11-10 19:44 ` [PATCH v2 0/3] cpuidle: psci: Enable s2idle when using PSCI OSI Rafael J. Wysocki
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=20201103150627.233438-3-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=alexandre.torgue@st.com \
--cc=bjorn.andersson@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=ilina@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rjw@rjwysocki.net \
--cc=sboyd@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=vincent.guittot@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;
as well as URLs for NNTP newsgroup(s).