[PATCH] clk: qcom: rpmh: make clkaN optional

Pengyu Luo posted 1 patch 10 months, 1 week ago
There is a newer version of this series
drivers/clk/qcom/clk-rpmh.c | 10 ++++++++++
1 file changed, 10 insertions(+)
[PATCH] clk: qcom: rpmh: make clkaN optional
Posted by Pengyu Luo 10 months, 1 week ago
On sm8650, clkaN are missing in cmd-db for some specific devices. This
caused a boot failure. Printing log during initramfs phase, I found

[    0.053281] clk-rpmh 17a00000.rsc:clock-controller: missing RPMh resource address for clka1

Adding the optional property to avoid probing failure which causes
countless deferred probe. In the downstream tree,similar workarounds
are introduced for sm7635, sm8550, sm8635, sm8650, sm8750.

Tested-by: Pengyu Luo <mitltlatltl@gmail.com> # Oneplus Pad Pro / Oneplus Pad 2
Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
---
 drivers/clk/qcom/clk-rpmh.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index c7675930f..68704c4f0 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -66,6 +66,8 @@ struct clk_rpmh {
 struct clk_rpmh_desc {
 	struct clk_hw **clks;
 	size_t num_clks;
+	/* rpmh clock clkaN are optional for this latform */
+	bool clka_optional;
 };
 
 static DEFINE_MUTEX(rpmh_clk_lock);
@@ -648,6 +650,7 @@ static struct clk_hw *sm8550_rpmh_clocks[] = {
 static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
 	.clks = sm8550_rpmh_clocks,
 	.num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
+	.clka_optional = true,
 };
 
 static struct clk_hw *sm8650_rpmh_clocks[] = {
@@ -679,6 +682,7 @@ static struct clk_hw *sm8650_rpmh_clocks[] = {
 static const struct clk_rpmh_desc clk_rpmh_sm8650 = {
 	.clks = sm8650_rpmh_clocks,
 	.num_clks = ARRAY_SIZE(sm8650_rpmh_clocks),
+	.clka_optional = true,
 };
 
 static struct clk_hw *sc7280_rpmh_clocks[] = {
@@ -847,6 +851,7 @@ static struct clk_hw *sm8750_rpmh_clocks[] = {
 static const struct clk_rpmh_desc clk_rpmh_sm8750 = {
 	.clks = sm8750_rpmh_clocks,
 	.num_clks = ARRAY_SIZE(sm8750_rpmh_clocks),
+	.clka_optional = true,
 };
 
 static struct clk_hw *of_clk_rpmh_hw_get(struct of_phandle_args *clkspec,
@@ -890,6 +895,11 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 		rpmh_clk = to_clk_rpmh(hw_clks[i]);
 		res_addr = cmd_db_read_addr(rpmh_clk->res_name);
 		if (!res_addr) {
+			hw_clks[i] = NULL;
+
+			if (desc->clka_optional && !strncmp(rpmh_clk->res_name, "clka", sizeof("clka") - 1))
+				continue;
+
 			dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
 				rpmh_clk->res_name);
 			return -ENODEV;
-- 
2.48.1
Re: [PATCH] clk: qcom: rpmh: make clkaN optional
Posted by Dmitry Baryshkov 10 months ago
On Fri, Apr 04, 2025 at 03:20:02PM +0800, Pengyu Luo wrote:
> On sm8650, clkaN are missing in cmd-db for some specific devices. This
> caused a boot failure. Printing log during initramfs phase, I found
> 
> [    0.053281] clk-rpmh 17a00000.rsc:clock-controller: missing RPMh resource address for clka1
> 
> Adding the optional property to avoid probing failure which causes
> countless deferred probe. In the downstream tree,similar workarounds
> are introduced for sm7635, sm8550, sm8635, sm8650, sm8750.

Nit: SM7635, SM8550, etc.

> 
> Tested-by: Pengyu Luo <mitltlatltl@gmail.com> # Oneplus Pad Pro / Oneplus Pad 2

I'm not so sure about this tag. You are expected to test the patch that
you are submitting.

> Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
> ---
>  drivers/clk/qcom/clk-rpmh.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
> index c7675930f..68704c4f0 100644
> --- a/drivers/clk/qcom/clk-rpmh.c
> +++ b/drivers/clk/qcom/clk-rpmh.c
> @@ -66,6 +66,8 @@ struct clk_rpmh {
>  struct clk_rpmh_desc {
>  	struct clk_hw **clks;
>  	size_t num_clks;
> +	/* rpmh clock clkaN are optional for this latform */

RPMh, platform

> +	bool clka_optional;
>  };
>  
>  static DEFINE_MUTEX(rpmh_clk_lock);
> @@ -648,6 +650,7 @@ static struct clk_hw *sm8550_rpmh_clocks[] = {
>  static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
>  	.clks = sm8550_rpmh_clocks,
>  	.num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
> +	.clka_optional = true,
>  };
>  
>  static struct clk_hw *sm8650_rpmh_clocks[] = {
> @@ -679,6 +682,7 @@ static struct clk_hw *sm8650_rpmh_clocks[] = {
>  static const struct clk_rpmh_desc clk_rpmh_sm8650 = {
>  	.clks = sm8650_rpmh_clocks,
>  	.num_clks = ARRAY_SIZE(sm8650_rpmh_clocks),
> +	.clka_optional = true,
>  };
>  
>  static struct clk_hw *sc7280_rpmh_clocks[] = {
> @@ -847,6 +851,7 @@ static struct clk_hw *sm8750_rpmh_clocks[] = {
>  static const struct clk_rpmh_desc clk_rpmh_sm8750 = {
>  	.clks = sm8750_rpmh_clocks,
>  	.num_clks = ARRAY_SIZE(sm8750_rpmh_clocks),
> +	.clka_optional = true,
>  };
>  
>  static struct clk_hw *of_clk_rpmh_hw_get(struct of_phandle_args *clkspec,
> @@ -890,6 +895,11 @@ static int clk_rpmh_probe(struct platform_device *pdev)
>  		rpmh_clk = to_clk_rpmh(hw_clks[i]);
>  		res_addr = cmd_db_read_addr(rpmh_clk->res_name);
>  		if (!res_addr) {
> +			hw_clks[i] = NULL;
> +
> +			if (desc->clka_optional && !strncmp(rpmh_clk->res_name, "clka", sizeof("clka") - 1))

Carriage return after &&

> +				continue;
> +
>  			dev_err(&pdev->dev, "missing RPMh resource address for %s\n",
>  				rpmh_clk->res_name);
>  			return -ENODEV;
> -- 
> 2.48.1
> 

-- 
With best wishes
Dmitry