mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1
@ 2022-03-07 17:02 Ahmad Fatoum
  2022-03-07 17:02 ` [PATCH next 2/2] fixup! clk: implement clk_hw_reparent Ahmad Fatoum
  2022-03-08  8:20 ` [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1 Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-03-07 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

clk: stm32mp1: fix infinite recursion with composite clock

Linux clk_hw_reparent does some accounting, which seems to be not necessary
for barebox. It does not do any hardware access and is distinct from
clk_hw_set_parent. The faulty barebox implementation, however,
configures a new parent leading to:

  &rcc {
    assigned-clocks = <&rcc ETHCK_K>;
     assigned-clock-parents = <&rcc PLL4_P>;
  };

to trigger an infinite recursion: ETHCK will have its parent set, then
set the parent of its mux sibling, which in turn sets ETHCK and so on.

Restore old working behavior.

Fixes: 3045cc773a94 ("clk: stm32mp1: sync with Linux v5.17-rc1")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Please fixup
---
 drivers/clk/clk-stm32mp1.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c
index 3e0c15ee32b9..c4b03e9f6d74 100644
--- a/drivers/clk/clk-stm32mp1.c
+++ b/drivers/clk/clk-stm32mp1.c
@@ -704,22 +704,7 @@ static int clk_mmux_get_parent(struct clk_hw *hw)
 
 static int clk_mmux_set_parent(struct clk_hw *hw, u8 index)
 {
-	struct clk_mux *mux = to_clk_mux(hw);
-	struct stm32_clk_mmux *clk_mmux = to_clk_mmux(mux);
-	struct clk_hw *hwp;
-	int ret, n;
-
-	ret = clk_mux_ops.set_parent(hw, index);
-	if (ret)
-		return ret;
-
-	hwp = clk_hw_get_parent(hw);
-
-	for (n = 0; n < clk_mmux->mmux->nbr_clk; n++)
-		if (clk_mmux->mmux->hws[n] != hw)
-			clk_hw_reparent(clk_mmux->mmux->hws[n], hwp);
-
-	return 0;
+	return clk_mux_ops.set_parent(hw, index);
 }
 
 static const struct clk_ops clk_mmux_ops = {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH next 2/2] fixup! clk: implement clk_hw_reparent
  2022-03-07 17:02 [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1 Ahmad Fatoum
@ 2022-03-07 17:02 ` Ahmad Fatoum
  2022-03-08  8:20 ` [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1 Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-03-07 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Revert "clk: implement clk_hw_reparent"

The implementation is faulty. In Linux, the function does accounting,
which seems not applicable to barebox and it does not do any hardware
access or set parentage, unlike the barebox port. As a previous commit
removed the sole use site of the helper to fix a bug, drop the helper
altogether.

This reverts commit 55a41677e2be90bbcaaa93cc541ead71a1e632d6.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Should result in an empty patch that can be skipped.
---
 include/linux/clk.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index ab96e36010c3..7fd835c35e51 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -241,14 +241,6 @@ int clk_hw_set_rate(struct clk_hw *hw, unsigned long rate);
 int clk_set_parent(struct clk *clk, struct clk *parent);
 int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *hwp);
 
-static inline void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent)
-{
-	if (!hw)
-		return;
-
-	clk_hw_set_parent(hw, new_parent);
-}
-
 /**
  * clk_get_parent - get the parent clock source for this clock
  * @clk: clock source
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1
  2022-03-07 17:02 [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1 Ahmad Fatoum
  2022-03-07 17:02 ` [PATCH next 2/2] fixup! clk: implement clk_hw_reparent Ahmad Fatoum
@ 2022-03-08  8:20 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-03-08  8:20 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Mar 07, 2022 at 06:02:09PM +0100, Ahmad Fatoum wrote:
> clk: stm32mp1: fix infinite recursion with composite clock
> 
> Linux clk_hw_reparent does some accounting, which seems to be not necessary
> for barebox. It does not do any hardware access and is distinct from
> clk_hw_set_parent. The faulty barebox implementation, however,
> configures a new parent leading to:
> 
>   &rcc {
>     assigned-clocks = <&rcc ETHCK_K>;
>      assigned-clock-parents = <&rcc PLL4_P>;
>   };
> 
> to trigger an infinite recursion: ETHCK will have its parent set, then
> set the parent of its mux sibling, which in turn sets ETHCK and so on.
> 
> Restore old working behavior.
> 
> Fixes: 3045cc773a94 ("clk: stm32mp1: sync with Linux v5.17-rc1")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Please fixup
> ---
>  drivers/clk/clk-stm32mp1.c | 17 +----------------
>  1 file changed, 1 insertion(+), 16 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c
> index 3e0c15ee32b9..c4b03e9f6d74 100644
> --- a/drivers/clk/clk-stm32mp1.c
> +++ b/drivers/clk/clk-stm32mp1.c
> @@ -704,22 +704,7 @@ static int clk_mmux_get_parent(struct clk_hw *hw)
>  
>  static int clk_mmux_set_parent(struct clk_hw *hw, u8 index)
>  {
> -	struct clk_mux *mux = to_clk_mux(hw);
> -	struct stm32_clk_mmux *clk_mmux = to_clk_mmux(mux);
> -	struct clk_hw *hwp;
> -	int ret, n;
> -
> -	ret = clk_mux_ops.set_parent(hw, index);
> -	if (ret)
> -		return ret;
> -
> -	hwp = clk_hw_get_parent(hw);
> -
> -	for (n = 0; n < clk_mmux->mmux->nbr_clk; n++)
> -		if (clk_mmux->mmux->hws[n] != hw)
> -			clk_hw_reparent(clk_mmux->mmux->hws[n], hwp);
> -
> -	return 0;
> +	return clk_mux_ops.set_parent(hw, index);
>  }
>  
>  static const struct clk_ops clk_mmux_ops = {
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-08  8:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 17:02 [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1 Ahmad Fatoum
2022-03-07 17:02 ` [PATCH next 2/2] fixup! clk: implement clk_hw_reparent Ahmad Fatoum
2022-03-08  8:20 ` [PATCH next 1/2] fixup! clk: stm32mp1: sync with Linux v5.17-rc1 Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox