Skip to contentSkip to conversation

clk: qcom: gcc-sm8550: Fix shared clk parking breakage

PATCH Applied Stephen Boyd 5 participants 13 messages Aug 19, 2024 – Jan 3, 2025

Subsystems (3)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover clk: qcom: gcc-sm8550: Fix shared clk parking breakage

Amit Pundir reported[1] that a recent commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration") broke USB and audio on sm8550-hdk. These two patches fix the issue by skipping the parking bit of the shared RCGs for devices that can't run so slow.

[1] https://lore.kernel.org/CAMi1Hd1KQBE4kKUdAn8E5FV+BiKzuv+8FoyWQrrTHPDoYTuhgA@mail.gmail.com/

Stephen Boyd (2):
clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs
clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 +++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c | 54 +++++++++++++++++------------------
 3 files changed, 58 insertions(+), 27 deletions(-)

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

Signature · 1 line
https://chromeos.dev
#1 lore raw

PATCH 1/2 clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs

The QUPs aren't shared in a way that requires parking the RCG at an always on parent in case some other entity turns on the clk. The hardware is capable of setting a new frequency itself with the DFS mode, so parking is unnecessary. Furthermore, there aren't any GDSCs for these devices, so there isn't a possibility of the GDSC turning on the clks for housekeeping purposes.

This wasn't a problem to mark these clks shared until we started parking shared RCGs at clk registration time in commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration"). Parking at init is actually harmful to the UART when earlycon is used. If the device is pumping out data while the frequency changes you'll see garbage on the serial console until the driver can probe and actually set a proper frequency.

Revert the QUP part of commit 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable") so that the QUPs don't get parked during clk registration and break UART operations.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
---
 drivers/clk/qcom/gcc-sm8550.c | 52 +++++++++++++++++------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/clk/qcom/gcc-sm8550.c +26 -26
index 7944ddb4b47d..0244a05866b8 100644
@@ -536,7 +536,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s0_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -551,7 +551,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s1_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -566,7 +566,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s2_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -581,7 +581,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s3_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -596,7 +596,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s4_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -611,7 +611,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s5_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -626,7 +626,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s6_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -641,7 +641,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s7_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -656,7 +656,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s8_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -671,7 +671,7 @@ static struct clk_rcg2 gcc_qupv3_i2c_s9_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_ops,
 	},
 };
 
@@ -700,7 +700,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s0_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s0_clk_src = {
@@ -717,7 +717,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s1_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s1_clk_src = {
@@ -750,7 +750,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s2_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s2_clk_src = {
@@ -767,7 +767,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s3_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s3_clk_src = {
@@ -784,7 +784,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s4_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s4_clk_src = {
@@ -801,7 +801,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s5_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s5_clk_src = {
@@ -818,7 +818,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s6_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s6_clk_src = {
@@ -835,7 +835,7 @@ static struct clk_init_data gcc_qupv3_wrap1_s7_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap1_s7_clk_src = {
@@ -852,7 +852,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s0_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s0_clk_src = {
@@ -869,7 +869,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s1_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s1_clk_src = {
@@ -886,7 +886,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s2_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s2_clk_src = {
@@ -903,7 +903,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s3_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s3_clk_src = {
@@ -920,7 +920,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s4_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s4_clk_src = {
@@ -937,7 +937,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s5_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s5_clk_src = {
@@ -975,7 +975,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s6_clk_src_init = {
 	.parent_data = gcc_parent_data_8,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_8),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s6_clk_src = {
@@ -992,7 +992,7 @@ static struct clk_init_data gcc_qupv3_wrap2_s7_clk_src_init = {
 	.parent_data = gcc_parent_data_0,
 	.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 	.flags = CLK_SET_RATE_PARENT,
-	.ops = &clk_rcg2_shared_ops,
+	.ops = &clk_rcg2_ops,
 };
 
 static struct clk_rcg2 gcc_qupv3_wrap2_s7_clk_src = {
Signature · 1 line
https://chromeos.dev
author Applied
#2 lore raw

Re: [PATCH 1/2] clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs

Quoting Stephen Boyd (2024-08-19 16:36:26)

Quoted 26 lines

The QUPs aren't shared in a way that requires parking the RCG at an always on parent in case some other entity turns on the clk. The hardware is capable of setting a new frequency itself with the DFS mode, so parking is unnecessary. Furthermore, there aren't any GDSCs for these devices, so there isn't a possibility of the GDSC turning on the clks for housekeeping purposes.

This wasn't a problem to mark these clks shared until we started parking shared RCGs at clk registration time in commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration"). Parking at init is actually harmful to the UART when earlycon is used. If the device is pumping out data while the frequency changes you'll see garbage on the serial console until the driver can probe and actually set a proper frequency.

Revert the QUP part of commit 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable") so that the QUPs don't get parked during clk registration and break UART operations.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
Quoted 1 line

---

Applied to clk-fixes

#3 lore raw

PATCH 2/2 clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

In reply to Stephen Boyd

Amit Pundir reports that audio and USB-C host mode stops working if the gcc_usb30_prim_master_clk_src clk is registered and clk_rcg2_shared_init() parks it on XO. Skip parking this clk at registration time to fix those issues.

Partially revert commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") by skipping the parking bit for this clk, but keep the part where we cache the config register. That's still necessary to figure out the true parent of the clk at registration time.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
---
 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 ++++++++++++++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg.h +1 -0
index d7414361e432..8e0f3372dc7a 100644
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
 extern const struct clk_ops clk_rcg2_shared_ops;
+extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;
 extern const struct clk_ops clk_dp_ops;
 
 struct clk_rcg_dfs_data {
drivers/clk/qcom/clk-rcg2.c +30 -0
index 30b19bd39d08..bf26c5448f00 100644
@@ -1348,6 +1348,36 @@ const struct clk_ops clk_rcg2_shared_ops = {
 };
 EXPORT_SYMBOL_GPL(clk_rcg2_shared_ops);
 
+static int clk_rcg2_shared_no_init_park(struct clk_hw *hw)
+{
+	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
+
+	/*
+	 * Read the config register so that the parent is properly mapped at
+	 * registration time.
+	 */
+	regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG, &rcg->parked_cfg);
+
+	return 0;
+}
+
+/*
+ * Like clk_rcg2_shared_ops but skip the init so that the clk frequency is left
+ * unchanged at registration time.
+ */
+const struct clk_ops clk_rcg2_shared_no_init_park_ops = {
+	.init = clk_rcg2_shared_no_init_park,
+	.enable = clk_rcg2_shared_enable,
+	.disable = clk_rcg2_shared_disable,
+	.get_parent = clk_rcg2_shared_get_parent,
+	.set_parent = clk_rcg2_shared_set_parent,
+	.recalc_rate = clk_rcg2_shared_recalc_rate,
+	.determine_rate = clk_rcg2_determine_rate,
+	.set_rate = clk_rcg2_shared_set_rate,
+	.set_rate_and_parent = clk_rcg2_shared_set_rate_and_parent,
+};
+EXPORT_SYMBOL_GPL(clk_rcg2_shared_no_init_park_ops);
+
 /* Common APIs to be used for DFS based RCGR */
 static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
 				       struct freq_tbl *f)
drivers/clk/qcom/gcc-sm8550.c +1 -1
index 0244a05866b8..5abaeddd6afc 100644
@@ -1159,7 +1159,7 @@ static struct clk_rcg2 gcc_usb30_prim_master_clk_src = {
 		.parent_data = gcc_parent_data_0,
 		.num_parents = ARRAY_SIZE(gcc_parent_data_0),
 		.flags = CLK_SET_RATE_PARENT,
-		.ops = &clk_rcg2_shared_ops,
+		.ops = &clk_rcg2_shared_no_init_park_ops,
 	},
 };
 
Signature · 1 line
https://chromeos.dev
author Applied
#4 lore raw

Re: [PATCH 2/2] clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

Quoting Stephen Boyd (2024-08-19 16:36:27)

Quoted 18 lines

Amit Pundir reports that audio and USB-C host mode stops working if the gcc_usb30_prim_master_clk_src clk is registered and clk_rcg2_shared_init() parks it on XO. Skip parking this clk at registration time to fix those issues.

Partially revert commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") by skipping the parking bit for this clk, but keep the part where we cache the config register. That's still necessary to figure out the true parent of the clk at registration time.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
Quoted 1 line

---

Applied to clk-fixes

#5 lore raw

Re: [PATCH 2/2] clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

In reply to Stephen Boyd

Quoting Stephen Boyd (2024-08-19 16:36:27)

Quoted 29 lines

Amit Pundir reports that audio and USB-C host mode stops working if the gcc_usb30_prim_master_clk_src clk is registered and clk_rcg2_shared_init() parks it on XO. Skip parking this clk at registration time to fix those issues.

Partially revert commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") by skipping the parking bit for this clk, but keep the part where we cache the config register. That's still necessary to figure out the true parent of the clk at registration time.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
---
 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 ++++++++++++++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg.h +0 -0
index d7414361e432..8e0f3372dc7a 100644

drivers/clk/qcom/clk-rcg.h extern const struct clk_ops clk_byte2_ops; · line 201

Quoted 4 lines
drivers/clk/qcom/clk-rcg.h +1 -0
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
 extern const struct clk_ops clk_rcg2_shared_ops;
+extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;

I'm considering inverting these two rcg2_shared clk_ops so that only a few clks are parked at clk registration time, to minimize the impact of commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration"). We're up to three or four band-aids, that we can probably wait on applying if we make all the shared RCGs determine the correct parent at registration time but skip the parking, except for the display clks on sc7180 where that exposes another problem with shared parents getting turned off during probe. It's possible that other SoCs will want to park their display clks as well to avoid that secondary problem, but it can be an opt-in case instead of a change to all shared RCGs.

#6 lore raw

Re: [PATCH 2/2] clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

Quoted 37 lines · Stephen Boyd

Quoting Stephen Boyd (2024-08-19 16:36:27)

Quoted 29 lines

Amit Pundir reports that audio and USB-C host mode stops working if the gcc_usb30_prim_master_clk_src clk is registered and clk_rcg2_shared_init() parks it on XO. Skip parking this clk at registration time to fix those issues.

Partially revert commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") by skipping the parking bit for this clk, but keep the part where we cache the config register. That's still necessary to figure out the true parent of the clk at registration time.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
---
 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 ++++++++++++++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg.h +0 -0
index d7414361e432..8e0f3372dc7a 100644

drivers/clk/qcom/clk-rcg.h extern const struct clk_ops clk_byte2_ops; · line 201

Quoted 4 lines
drivers/clk/qcom/clk-rcg.h +1 -0
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
 extern const struct clk_ops clk_rcg2_shared_ops;
+extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;

I'm considering inverting these two rcg2_shared clk_ops so that only a few clks are parked at clk registration time, to minimize the impact of

Quoted 8 lines

commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration"). We're up to three or four band-aids, that we can probably wait on applying if we make all the shared RCGs determine the correct parent at registration time but skip the parking, except for the display clks on sc7180 where that exposes another problem with shared parents getting turned off during probe. It's possible that other SoCs will want to park their display clks as well to avoid that secondary problem, but it can be an opt-in case instead of a change to all shared RCGs.

Are all cases that need the parking obvious like it was the case on 7180, i.e. some downstream branch is stuck and there's complaining in dmesg?

Konrad

#7 lore raw

Re: [PATCH 2/2] clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

Quoting Konrad Dybcio (2024-08-30 05:24:20)

Quoted 47 lines · Stephen Boyd
Quoted 37 lines

Quoting Stephen Boyd (2024-08-19 16:36:27)

Quoted 29 lines

Amit Pundir reports that audio and USB-C host mode stops working if the gcc_usb30_prim_master_clk_src clk is registered and clk_rcg2_shared_init() parks it on XO. Skip parking this clk at registration time to fix those issues.

Partially revert commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") by skipping the parking bit for this clk, but keep the part where we cache the config register. That's still necessary to figure out the true parent of the clk at registration time.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
---
 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 ++++++++++++++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg.h +0 -0
index d7414361e432..8e0f3372dc7a 100644

drivers/clk/qcom/clk-rcg.h extern const struct clk_ops clk_byte2_ops; · line 201

Quoted 4 lines
drivers/clk/qcom/clk-rcg.h +1 -0
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
 extern const struct clk_ops clk_rcg2_shared_ops;
+extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;

I'm considering inverting these two rcg2_shared clk_ops so that only a few clks are parked at clk registration time, to minimize the impact of

Quoted 8 lines

commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration"). We're up to three or four band-aids, that we can probably wait on applying if we make all the shared RCGs determine the correct parent at registration time but skip the parking, except for the display clks on sc7180 where that exposes another problem with shared parents getting turned off during probe. It's possible that other SoCs will want to park their display clks as well to avoid that secondary problem, but it can be an opt-in case instead of a change to all shared RCGs.

Quoted 3 lines

Are all cases that need the parking obvious like it was the case on 7180, i.e. some downstream branch is stuck and there's complaining in dmesg?

I'm under the impression that we need to park the clk when it is shared by a remoteproc/firmware or is associated with a GDSC. It seems that on older generations of hardware the GDSC would get unstuck eventually, but newer generations stay broken and cause all sorts of havoc.

Note that in my statement earlier in this thread I'm talking about parking the clk at registration time. That's done to avoid a problem where a shared RCG turns off their parent PLL and another shared RCG is also using that PLL but hasn't parked yet. The solution was to park at registration time to fix that. It's mostly a workaround for the fact that the clk framework doesn't have a good way to track dependencies for all the child clks that are enable at registration time which want to keep the parent PLL enabled. The problem is that it breaks things like USB that has strict frequency requirements for the link.

#8 lore raw

Re: [PATCH 2/2] clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

Quoted 48 lines · Stephen Boyd

Quoting Konrad Dybcio (2024-08-30 05:24:20)

Quoted 47 lines · Stephen Boyd
Quoted 45 lines

Quoting Stephen Boyd (2024-08-19 16:36:27)

Quoted 29 lines

Amit Pundir reports that audio and USB-C host mode stops working if the gcc_usb30_prim_master_clk_src clk is registered and clk_rcg2_shared_init() parks it on XO. Skip parking this clk at registration time to fix those issues.

Partially revert commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") by skipping the parking bit for this clk, but keep the part where we cache the config register. That's still necessary to figure out the true parent of the clk at registration time.

Fixes 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration")
Fixes 929c75d57566 ("clk: qcom: gcc-sm8550: Mark RCGs shared where applicable")
Cc Konrad Dybcio <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Taniya Das <[email protected]>
---
 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 ++++++++++++++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg.h +0 -0
index d7414361e432..8e0f3372dc7a 100644

drivers/clk/qcom/clk-rcg.h extern const struct clk_ops clk_byte2_ops; · line 201

Quoted 4 lines
drivers/clk/qcom/clk-rcg.h +1 -0
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
 extern const struct clk_ops clk_rcg2_shared_ops;
+extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;

I'm considering inverting these two rcg2_shared clk_ops so that only a few clks are parked at clk registration time, to minimize the impact of commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration"). We're up to three or four band-aids, that we can probably wait on applying if we make all the shared RCGs determine the correct parent at registration time but skip the parking, except for the display clks on sc7180 where that exposes another problem with shared parents getting turned off during probe. It's possible that other SoCs will want to park their display clks as well to avoid that secondary problem, but it can be an opt-in case instead of a change to all shared RCGs.

Quoted 8 lines
Quoted 3 lines

Are all cases that need the parking obvious like it was the case on 7180, i.e. some downstream branch is stuck and there's complaining in dmesg?

I'm under the impression that we need to park the clk when it is shared by a remoteproc/firmware or is associated with a GDSC. It seems that on older generations of hardware the GDSC would get unstuck eventually, but newer generations stay broken and cause all sorts of havoc.

I heard newer GDSCs are funky..

Quoted 9 lines

Note that in my statement earlier in this thread I'm talking about parking the clk at registration time. That's done to avoid a problem where a shared RCG turns off their parent PLL and another shared RCG is also using that PLL but hasn't parked yet. The solution was to park at registration time to fix that. It's mostly a workaround for the fact that the clk framework doesn't have a good way to track dependencies for all the child clks that are enable at registration time which want to keep the parent PLL enabled. The problem is that it breaks things like USB that has strict frequency requirements for the link.

Should we just do something like .sync_state, where top-level parents aren't turned off until all clocks have been registered?

Konrad

Tested-by on the v1 series
#9 lore raw
In reply to Stephen Boyd
Quoted 8 lines · Stephen Boyd

Amit Pundir reported[1] that a recent commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration") broke USB and audio on sm8550-hdk. These two patches fix the issue by skipping the parking bit of the shared RCGs for devices that can't run so slow.

[1] https://lore.kernel.org/CAMi1Hd1KQBE4kKUdAn8E5FV+BiKzuv+8FoyWQrrTHPDoYTuhgA@mail.gmail.com/

Thank you for the patches Stephen. This series fixes the serial console garbage, audio, and USB-C host mode regression I see on SM8550-HDK running AOSP.

Quoted 14 lines

Stephen Boyd (2):
clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs
clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

 drivers/clk/qcom/clk-rcg.h    |  1 +
 drivers/clk/qcom/clk-rcg2.c   | 30 +++++++++++++++++++
 drivers/clk/qcom/gcc-sm8550.c | 54 +++++++++++++++++------------------
 3 files changed, 58 insertions(+), 27 deletions(-)

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b --
https://chromeos.dev

#10 lore raw
In reply to Stephen Boyd

Hi,

Quoted 11 lines · Stephen Boyd

Amit Pundir reported[1] that a recent commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration") broke USB and audio on sm8550-hdk. These two patches fix the issue by skipping the parking bit of the shared RCGs for devices that can't run so slow.

[1] https://lore.kernel.org/CAMi1Hd1KQBE4kKUdAn8E5FV+BiKzuv+8FoyWQrrTHPDoYTuhgA@mail.gmail.com/

Stephen Boyd (2):
clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs
clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

Quoted 7 lines
  drivers/clk/qcom/clk-rcg.h    |  1 +
  drivers/clk/qcom/clk-rcg2.c   | 30 +++++++++++++++++++
  drivers/clk/qcom/gcc-sm8550.c | 54 +++++++++++++++++------------------
  3 files changed, 58 insertions(+), 27 deletions(-)

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

I'm pretty sure sm8450 & sm8650 (and probably other SoCs) could be also affected, could you check ?

Neil

#11 lore raw

Quoting [email protected] (2024-08-21 08:44:00)

Quoted 20 lines

Hi,

Quoted 17 lines · Stephen Boyd

Amit Pundir reported[1] that a recent commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration") broke USB and audio on sm8550-hdk. These two patches fix the issue by skipping the parking bit of the shared RCGs for devices that can't run so slow.

[1] https://lore.kernel.org/CAMi1Hd1KQBE4kKUdAn8E5FV+BiKzuv+8FoyWQrrTHPDoYTuhgA@mail.gmail.com/

Stephen Boyd (2):
clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs
clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

  drivers/clk/qcom/clk-rcg.h    |  1 +
  drivers/clk/qcom/clk-rcg2.c   | 30 +++++++++++++++++++
  drivers/clk/qcom/gcc-sm8550.c | 54 +++++++++++++++++------------------
  3 files changed, 58 insertions(+), 27 deletions(-)
Quoted 3 lines
Quoted 1 line

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

I'm pretty sure sm8450 & sm8650 (and probably other SoCs) could be also affected, could you check ?

Does someone have the hardware to test? It looks like sm8450 isn't using the shared ops, but sm8650 is, likely incorrectly.

#12 lore raw
Quoted 21 lines · Stephen Boyd

Quoting [email protected] (2024-08-21 08:44:00)

Quoted 20 lines

Hi,

Quoted 17 lines · Stephen Boyd

Amit Pundir reported[1] that a recent commit 01a0a6cc8cfd ("clk: qcom:
Park shared RCGs upon registration") broke USB and audio on sm8550-hdk. These two patches fix the issue by skipping the parking bit of the shared RCGs for devices that can't run so slow.

[1] https://lore.kernel.org/CAMi1Hd1KQBE4kKUdAn8E5FV+BiKzuv+8FoyWQrrTHPDoYTuhgA@mail.gmail.com/

Stephen Boyd (2):
clk: qcom: gcc-sm8550: Don't use parking clk_ops for QUPs
clk: qcom: gcc-sm8550: Don't park the USB RCG at registration time

   drivers/clk/qcom/clk-rcg.h    |  1 +
   drivers/clk/qcom/clk-rcg2.c   | 30 +++++++++++++++++++
   drivers/clk/qcom/gcc-sm8550.c | 54 +++++++++++++++++------------------
   3 files changed, 58 insertions(+), 27 deletions(-)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

I'm pretty sure sm8450 & sm8650 (and probably other SoCs) could be also affected, could you check ?

Does someone have the hardware to test? It looks like sm8450 isn't using the shared ops, but sm8650 is, likely incorrectly.

I can't reproduce the uart issue on 8650, I'll try moving some dependencies (CLK, ICC, ..) as modules.

Bryan reproduced it on X1, and he posted a patch.

Neil