diff mbox series

[RFT,v2,13/14] clk: qcom: smd-rpm: Mark clock enabled in clk_smd_rpm_handoff()

Message ID 20230303-topic-rpmcc_sleep-v2-13-ae80a325fe94@linaro.org (mailing list archive)
State Changes Requested
Headers show
Series SMD RPMCC sleep preparations | expand

Commit Message

Konrad Dybcio March 8, 2023, 9:35 p.m. UTC
From: Shawn Guo <shawn.guo@linaro.org>

The result of clock handoff is that the clock is voted by APSS and
enabled by RPM.  So it should be marked as enabled.

This, combined with .is_enabled/prepared will ultimately cause RPM
clocks that were enabled by the bootloader to actually be shut down
if unused. We can only afford to do so if we have a functioning ICC
driver. An immediate thought to test for that can be to provide an
ICC path to the RPMCC node, however that would create a couple of
circular dependencies between GCC/DISPCC/.../RPMCC and ICC.

The next best thing to do without breaking older device trees is to
add an opt-in DTS property. Do just that.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
[Konrad: make conditional, explain the consequences]
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/clk/qcom/clk-smd-rpm.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
index ef3157fd29d5..6736e53e607a 100644
--- a/drivers/clk/qcom/clk-smd-rpm.c
+++ b/drivers/clk/qcom/clk-smd-rpm.c
@@ -197,7 +197,7 @@  struct rpm_smd_clk_desc {
 
 static DEFINE_MUTEX(rpm_smd_clk_lock);
 
-static int clk_smd_rpm_handoff(struct clk_smd_rpm *r)
+static int clk_smd_rpm_handoff(struct clk_smd_rpm *r, bool disable_unused_clks)
 {
 	int ret;
 	struct clk_smd_rpm_req req = {
@@ -222,6 +222,10 @@  static int clk_smd_rpm_handoff(struct clk_smd_rpm *r)
 	if (ret)
 		return ret;
 
+	/* Marking clocks enabled here will trigger unused cleanup */
+	if (disable_unused_clks)
+		r->enabled = true;
+
 	return 0;
 }
 
@@ -1319,6 +1323,7 @@  static int rpm_smd_clk_probe(struct platform_device *pdev)
 	struct qcom_smd_rpm *rpm;
 	struct clk_smd_rpm **rpm_smd_clks;
 	const struct rpm_smd_clk_desc *desc;
+	bool disable_unused_clks;
 
 	rpm = dev_get_drvdata(pdev->dev.parent);
 	if (!rpm) {
@@ -1326,6 +1331,14 @@  static int rpm_smd_clk_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	/*
+	 * We can only really park unused clocks if we have a sane interconnect
+	 * driver. Otherwise, the platform may (and probably will) try accessing
+	 * IPs that are hosted on unclocked buses. In an effort not to break
+	 * older DTs, make this an opt-in through a DT property.
+	 */
+	disable_unused_clks = of_property_read_bool(pdev->dev.of_node, "qcom,clk-disable-unused");
+
 	desc = of_device_get_match_data(&pdev->dev);
 	if (!desc)
 		return -EINVAL;
@@ -1339,7 +1352,7 @@  static int rpm_smd_clk_probe(struct platform_device *pdev)
 
 		rpm_smd_clks[i]->rpm = rpm;
 
-		ret = clk_smd_rpm_handoff(rpm_smd_clks[i]);
+		ret = clk_smd_rpm_handoff(rpm_smd_clks[i], disable_unused_clks);
 		if (ret)
 			goto err;
 	}