From: Stephen Boyd <swboyd@chromium.org>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
patches@lists.linux.dev, linux-arm-msm@vger.kernel.org,
Taniya Das <quic_tdas@quicinc.com>,
Mike Tipton <quic_mdtipton@quicinc.com>
Subject: [PATCH/RFC] clk: qcom: rpmh: Block system suspend if XO is enabled
Date: Tue, 28 Jun 2022 13:13:40 -0700 [thread overview]
Message-ID: <20220628201340.3981860-1-swboyd@chromium.org> (raw)
Tracking down what RPMh resource is blocking XO shutdown in suspend is
hard. Largely because we need external debug tools to dump the RPMh
internal state to figure out what resource is enabled. Instead of doing
that, let's just block system wide suspend in the kernel if the RPMh XO
resource is enabled by something in the kernel. This will help us narrow
down XO shutdown failures to the XO clk, and not something else like an
interconnect or regulator RPMh resource.
I'm sending this as an RFC because it breaks suspend for me on Trogdor
boards. I found out that the XO resource is always enabled on these
devices because the audio driver leaves an audio clk always on. This
means that the XO resource must not be used to determine if XO shutdown
is achievable, or we're leaving power savings on the table.
Cc: Taniya Das <quic_tdas@quicinc.com>
Cc: Mike Tipton <quic_mdtipton@quicinc.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
Please don't apply. It will break suspend on Trogdor boards.
drivers/clk/qcom/clk-rpmh.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index aed907982344..ba0e0e4b9cf2 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -70,6 +70,14 @@ struct clk_rpmh_desc {
static DEFINE_MUTEX(rpmh_clk_lock);
+/* XO shutdown will fail if XO is enabled across suspend */
+static int clk_rpmh_suspend(struct device *dev)
+{
+ struct clk_rpmh *xo = dev_get_drvdata(dev);
+
+ return xo && xo->state ? -EBUSY : 0;
+}
+
#define __DEFINE_CLK_RPMH(_platform, _name, _name_active, _res_name, \
_res_en_offset, _res_on, _div) \
static struct clk_rpmh _platform##_##_name_active; \
@@ -690,6 +698,10 @@ static int clk_rpmh_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to register %s\n", name);
return ret;
}
+
+ /* Stash CXO clk for XO shutdown tracking */
+ if (i == RPMH_CXO_CLK)
+ platform_set_drvdata(pdev, rpmh_clk);
}
/* typecast to silence compiler warning */
@@ -722,9 +734,12 @@ static const struct of_device_id clk_rpmh_match_table[] = {
};
MODULE_DEVICE_TABLE(of, clk_rpmh_match_table);
+static SIMPLE_DEV_PM_OPS(clk_rpmh_pm_ops, clk_rpmh_suspend, NULL);
+
static struct platform_driver clk_rpmh_driver = {
.probe = clk_rpmh_probe,
.driver = {
+ .pm = pm_ptr(&clk_rpmh_pm_ops),
.name = "clk-rpmh",
.of_match_table = clk_rpmh_match_table,
},
base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
--
https://chromeos.dev
next reply other threads:[~2022-06-28 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 20:13 Stephen Boyd [this message]
2022-07-01 4:00 ` [PATCH/RFC] clk: qcom: rpmh: Block system suspend if XO is enabled Bjorn Andersson
2022-07-07 0:02 ` Stephen Boyd
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=20220628201340.3981860-1-swboyd@chromium.org \
--to=swboyd@chromium.org \
--cc=bjorn.andersson@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=patches@lists.linux.dev \
--cc=quic_mdtipton@quicinc.com \
--cc=quic_tdas@quicinc.com \
--cc=sboyd@kernel.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