[PATCH] clk: rockchip: fix finding of maximum clock ID

Yao Zi posted 1 patch 2 months, 2 weeks ago
drivers/clk/rockchip/clk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] clk: rockchip: fix finding of maximum clock ID
Posted by Yao Zi 2 months, 2 weeks ago
If an ID of a branch's child is greater than current maximum, we should
set new maximum to the child's ID, instead of its parent's.

Fixes: 2dc66a5ab2c6 ("clk: rockchip: rk3588: fix CLK_NR_CLKS usage")
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
 drivers/clk/rockchip/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 73d2cbdc716b..0972e9f87470 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -439,7 +439,7 @@ unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
 		if (list->id > max)
 			max = list->id;
 		if (list->child && list->child->id > max)
-			max = list->id;
+			max = list->child->id;
 	}
 
 	return max;
-- 
2.46.0
Re: [PATCH] clk: rockchip: fix finding of maximum clock ID
Posted by Stephen Boyd 1 month, 3 weeks ago
Quoting Yao Zi (2024-09-12 06:32:05)
> If an ID of a branch's child is greater than current maximum, we should
> set new maximum to the child's ID, instead of its parent's.
> 
> Fixes: 2dc66a5ab2c6 ("clk: rockchip: rk3588: fix CLK_NR_CLKS usage")
> Signed-off-by: Yao Zi <ziyao@disroot.org>
> ---

Applied to clk-fixes
Re: [PATCH] clk: rockchip: fix finding of maximum clock ID
Posted by Heiko Stübner 2 months, 2 weeks ago
Am Donnerstag, 12. September 2024, 15:32:05 CEST schrieb Yao Zi:
> If an ID of a branch's child is greater than current maximum, we should
> set new maximum to the child's ID, instead of its parent's.
> 
> Fixes: 2dc66a5ab2c6 ("clk: rockchip: rk3588: fix CLK_NR_CLKS usage")
> Signed-off-by: Yao Zi <ziyao@disroot.org>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

@Stephen: can you put that on top of the other Rockchip changes for 6.12
please?

Thanks a lot
Heiko

> ---
>  drivers/clk/rockchip/clk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
> index 73d2cbdc716b..0972e9f87470 100644
> --- a/drivers/clk/rockchip/clk.c
> +++ b/drivers/clk/rockchip/clk.c
> @@ -439,7 +439,7 @@ unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
>  		if (list->id > max)
>  			max = list->id;
>  		if (list->child && list->child->id > max)
> -			max = list->id;
> +			max = list->child->id;
>  	}
>  
>  	return max;
>
Re: [PATCH] clk: rockchip: fix finding of maximum clock ID
Posted by Stephen Boyd 1 month, 3 weeks ago
Quoting Heiko Stübner (2024-09-14 02:57:35)
> Am Donnerstag, 12. September 2024, 15:32:05 CEST schrieb Yao Zi:
> > If an ID of a branch's child is greater than current maximum, we should
> > set new maximum to the child's ID, instead of its parent's.
> > 
> > Fixes: 2dc66a5ab2c6 ("clk: rockchip: rk3588: fix CLK_NR_CLKS usage")
> > Signed-off-by: Yao Zi <ziyao@disroot.org>
> 
> Reviewed-by: Heiko Stuebner <heiko@sntech.de>
> 
> @Stephen: can you put that on top of the other Rockchip changes for 6.12
> please?
> 

Sorry I missed this one. I'll put it on clk-fixes.
Re: [PATCH] clk: rockchip: fix finding of maximum clock ID
Posted by Sebastian Reichel 2 months, 2 weeks ago
Hi,

On Thu, Sep 12, 2024 at 01:32:05PM GMT, Yao Zi wrote:
> If an ID of a branch's child is greater than current maximum, we should
> set new maximum to the child's ID, instead of its parent's.
> 
> Fixes: 2dc66a5ab2c6 ("clk: rockchip: rk3588: fix CLK_NR_CLKS usage")
> Signed-off-by: Yao Zi <ziyao@disroot.org>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

oops, good catch. Note, that the function returns the correct value
for RK3588, since the clocks with the highest IDs are of GATE_LINK
type and do not have their child field set. I have not checked all
the Rockchip SoCs converted for 6.12, so I suggest sending this as
fixes material for 6.12.

Greetings,

-- Sebastian

>  drivers/clk/rockchip/clk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
> index 73d2cbdc716b..0972e9f87470 100644
> --- a/drivers/clk/rockchip/clk.c
> +++ b/drivers/clk/rockchip/clk.c
> @@ -439,7 +439,7 @@ unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
>  		if (list->id > max)
>  			max = list->id;
>  		if (list->child && list->child->id > max)
> -			max = list->id;
> +			max = list->child->id;
>  	}
>  
>  	return max;
> -- 
> 2.46.0
> 
Re: [PATCH] clk: rockchip: fix finding of maximum clock ID
Posted by Yao Zi 2 months, 2 weeks ago
On Sat, Sep 14, 2024 at 08:48:53AM +0200, Sebastian Reichel wrote:
> Hi,
> 
> On Thu, Sep 12, 2024 at 01:32:05PM GMT, Yao Zi wrote:
> > If an ID of a branch's child is greater than current maximum, we should
> > set new maximum to the child's ID, instead of its parent's.
> > 
> > Fixes: 2dc66a5ab2c6 ("clk: rockchip: rk3588: fix CLK_NR_CLKS usage")
> > Signed-off-by: Yao Zi <ziyao@disroot.org>
> > ---
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> 
> oops, good catch. Note, that the function returns the correct value
> for RK3588, since the clocks with the highest IDs are of GATE_LINK
> type and do not have their child field set.

yes, but it does hit me when working for rk3528 clock controller unit.

> I have not checked all
> the Rockchip SoCs converted for 6.12, so I suggest sending this as
> fixes material for 6.12.

I have done a rough check and think no code in 6.11 release is affected.

> 
> Greetings,
> 
> -- Sebastian

Cheers,
Yao Zi