Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH] clk: imx: composite-93: return timeout from gate enable
@ 2026-08-21  8:56 Linkai Gong
  2026-08-21 11:49 ` Abel Vesa
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Linkai Gong @ 2026-08-21  8:56 UTC (permalink / raw)
  To: Abel Vesa, Michael Turquette, Stephen Boyd, Frank Li,
	Sascha Hauer
  Cc: Peng Fan, Brian Masney, Pengutronix Kernel Team, Fabio Estevam,
	Ye Li, Jacky Bai, linux-clk, imx, linux-arm-kernel, linux-kernel,
	gonglinkai

imx93_clk_composite_gate_enable() always returns 0, even when
imx93_clk_composite_wait_ready() times out.

Fixes: 4a3de5aa7743 ("clk: imx: clk-composite-93: check slice busy")
Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
---
 drivers/clk/imx/clk-composite-93.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/imx/clk-composite-93.c b/drivers/clk/imx/clk-composite-93.c
index ef20ceb2d255..953f67d13978 100644
--- a/drivers/clk/imx/clk-composite-93.c
+++ b/drivers/clk/imx/clk-composite-93.c
@@ -43,11 +43,12 @@ static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)
 	return ret;
 }
 
-static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
+static int imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
 {
 	struct clk_gate *gate = to_clk_gate(hw);
 	unsigned long flags;
 	u32 reg;
+	int ret;
 
 	if (gate->lock)
 		spin_lock_irqsave(gate->lock, flags);
@@ -61,17 +62,17 @@ static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
 
 	writel(reg, gate->reg);
 
-	imx93_clk_composite_wait_ready(hw, gate->reg);
+	ret = imx93_clk_composite_wait_ready(hw, gate->reg);
 
 	if (gate->lock)
 		spin_unlock_irqrestore(gate->lock, flags);
+
+	return ret;
 }
 
 static int imx93_clk_composite_gate_enable(struct clk_hw *hw)
 {
-	imx93_clk_composite_gate_endisable(hw, 1);
-
-	return 0;
+	return imx93_clk_composite_gate_endisable(hw, 1);
 }
 
 static void imx93_clk_composite_gate_disable(struct clk_hw *hw)
-- 
2.25.1


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

* Re: [PATCH] clk: imx: composite-93: return timeout from gate enable
  2026-08-21  8:56 [PATCH] clk: imx: composite-93: return timeout from gate enable Linkai Gong
@ 2026-08-21 11:49 ` Abel Vesa
  2026-09-07  2:19   ` Linkai Gong
  2026-09-02  8:19 ` Peng Fan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Abel Vesa @ 2026-08-21 11:49 UTC (permalink / raw)
  To: Linkai Gong
  Cc: Abel Vesa, Michael Turquette, Stephen Boyd, Frank Li,
	Sascha Hauer, Peng Fan, Brian Masney, Pengutronix Kernel Team,
	Fabio Estevam, Ye Li, Jacky Bai, linux-clk, imx, linux-arm-kernel,
	linux-kernel

On 26-08-21 16:56:16, Linkai Gong wrote:
> imx93_clk_composite_gate_enable() always returns 0, even when
> imx93_clk_composite_wait_ready() times out.
> 

Ok, so you are describing what it does, not why you are doing it.

Please make the commit message a bit more clear about why this change is
needed.

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

* Re: [PATCH] clk: imx: composite-93: return timeout from gate enable
  2026-08-21  8:56 [PATCH] clk: imx: composite-93: return timeout from gate enable Linkai Gong
  2026-08-21 11:49 ` Abel Vesa
@ 2026-09-02  8:19 ` Peng Fan
  2026-09-07  2:20   ` Linkai Gong
  2026-09-07  2:22 ` [PATCH v2] " Linkai Gong
  2026-09-10 15:45 ` [PATCH] " Frank Li
  3 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2026-09-02  8:19 UTC (permalink / raw)
  To: Linkai Gong
  Cc: Abel Vesa, Michael Turquette, Stephen Boyd, Frank Li,
	Sascha Hauer, Peng Fan, Brian Masney, Pengutronix Kernel Team,
	Fabio Estevam, Ye Li, Jacky Bai, linux-clk, imx, linux-arm-kernel,
	linux-kernel

On Fri, Aug 21, 2026 at 04:56:16PM +0800, Linkai Gong wrote:
>imx93_clk_composite_gate_enable() always returns 0, even when
>imx93_clk_composite_wait_ready() times out.

Do you meet any issues or just code inspection?

Thanks,
Peng

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

* Re: [PATCH] clk: imx: composite-93: return timeout from gate enable
  2026-08-21 11:49 ` Abel Vesa
@ 2026-09-07  2:19   ` Linkai Gong
  0 siblings, 0 replies; 9+ messages in thread
From: Linkai Gong @ 2026-09-07  2:19 UTC (permalink / raw)
  To: Abel Vesa; +Cc: Peng Fan, Stephen Boyd, linux-clk, imx

On Fri, Aug 21, 2026 at 02:49:58PM +0300, Abel Vesa wrote:
> Ok, so you are describing what it does, not why you are doing it.
>
> Please make the commit message a bit more clear about why this change is
> needed.

You are right. I will send a v2 that explains why: enable() currently
hides the timeout from the clk core, so consumers keep going while the
slice is still busy.

Thanks,
Linkai

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

* Re: [PATCH] clk: imx: composite-93: return timeout from gate enable
  2026-09-02  8:19 ` Peng Fan
@ 2026-09-07  2:20   ` Linkai Gong
  0 siblings, 0 replies; 9+ messages in thread
From: Linkai Gong @ 2026-09-07  2:20 UTC (permalink / raw)
  To: Peng Fan; +Cc: Abel Vesa, Stephen Boyd, linux-clk, imx

On Wed, Sep 02, 2026 at 04:17:54PM +0800, Peng Fan wrote:
> Do you meet any issues or just code inspection?

Just code inspection. Compile tested only, I do not have i.MX93
hardware.

wait_ready() already returns the timeout, but enable() drops it and
always returns 0. The clk core then treats the clock as enabled while
the slice is still busy. That is why the error should be propagated
even without a field report.

I will send a v2 with a clearer commit message, as Abel asked.

Thanks,
Linkai

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

* [PATCH v2] clk: imx: composite-93: return timeout from gate enable
  2026-08-21  8:56 [PATCH] clk: imx: composite-93: return timeout from gate enable Linkai Gong
  2026-08-21 11:49 ` Abel Vesa
  2026-09-02  8:19 ` Peng Fan
@ 2026-09-07  2:22 ` Linkai Gong
  2026-09-10 10:49   ` Peng Fan (OSS)
  2026-09-10 15:47   ` Frank Li
  2026-09-10 15:45 ` [PATCH] " Frank Li
  3 siblings, 2 replies; 9+ messages in thread
From: Linkai Gong @ 2026-09-07  2:22 UTC (permalink / raw)
  To: Abel Vesa, Peng Fan, Stephen Boyd; +Cc: linux-clk, imx

imx93_clk_composite_wait_ready() already reports a busy timeout, but
imx93_clk_composite_gate_enable() ignores that and always returns 0.
The clk framework then marks the clock enabled and lets consumers run
while the CCM slice is still busy.

Propagate the timeout so enable fails instead of looking successful.

Fixes: 4a3de5aa7743 ("clk: imx: clk-composite-93: check slice busy")
Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
---
v2:
- Rewrite the commit message to explain why (Abel Vesa)

 drivers/clk/imx/clk-composite-93.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/imx/clk-composite-93.c b/drivers/clk/imx/clk-composite-93.c
index ef20ceb2d255..953f67d13978 100644
--- a/drivers/clk/imx/clk-composite-93.c
+++ b/drivers/clk/imx/clk-composite-93.c
@@ -43,11 +43,12 @@ static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)
 	return ret;
 }
 
-static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
+static int imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
 {
 	struct clk_gate *gate = to_clk_gate(hw);
 	unsigned long flags;
 	u32 reg;
+	int ret;
 
 	if (gate->lock)
 		spin_lock_irqsave(gate->lock, flags);
@@ -61,17 +62,17 @@ static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
 
 	writel(reg, gate->reg);
 
-	imx93_clk_composite_wait_ready(hw, gate->reg);
+	ret = imx93_clk_composite_wait_ready(hw, gate->reg);
 
 	if (gate->lock)
 		spin_unlock_irqrestore(gate->lock, flags);
+
+	return ret;
 }
 
 static int imx93_clk_composite_gate_enable(struct clk_hw *hw)
 {
-	imx93_clk_composite_gate_endisable(hw, 1);
-
-	return 0;
+	return imx93_clk_composite_gate_endisable(hw, 1);
 }
 
 static void imx93_clk_composite_gate_disable(struct clk_hw *hw)
-- 
2.25.1

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

* RE: [PATCH v2] clk: imx: composite-93: return timeout from gate enable
  2026-09-07  2:22 ` [PATCH v2] " Linkai Gong
@ 2026-09-10 10:49   ` Peng Fan (OSS)
  2026-09-10 15:47   ` Frank Li
  1 sibling, 0 replies; 9+ messages in thread
From: Peng Fan (OSS) @ 2026-09-10 10:49 UTC (permalink / raw)
  To: Linkai Gong, Abel Vesa, Stephen Boyd
  Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev

> Subject: [PATCH v2] clk: imx: composite-93: return timeout from gate
> enable
>
> imx93_clk_composite_wait_ready() already reports a busy timeout, but
> imx93_clk_composite_gate_enable() ignores that and always returns 0.
> The clk framework then marks the clock enabled and lets consumers
> run while the CCM slice is still busy.
>
> Propagate the timeout so enable fails instead of looking successful.
>
> Fixes: 4a3de5aa7743 ("clk: imx: clk-composite-93: check slice busy")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

NXP Confidential

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

* Re: [PATCH] clk: imx: composite-93: return timeout from gate enable
  2026-08-21  8:56 [PATCH] clk: imx: composite-93: return timeout from gate enable Linkai Gong
                   ` (2 preceding siblings ...)
  2026-09-07  2:22 ` [PATCH v2] " Linkai Gong
@ 2026-09-10 15:45 ` Frank Li
  3 siblings, 0 replies; 9+ messages in thread
From: Frank Li @ 2026-09-10 15:45 UTC (permalink / raw)
  To: Linkai Gong
  Cc: Abel Vesa, Michael Turquette, Stephen Boyd, Frank Li,
	Sascha Hauer, Peng Fan, Brian Masney, Pengutronix Kernel Team,
	Fabio Estevam, Ye Li, Jacky Bai, linux-clk, imx, linux-arm-kernel,
	linux-kernel

On Fri, Aug 21, 2026 at 04:56:16PM +0800, Linkai Gong wrote:
> [You don't often get email from gonglinkai@kylinos.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> imx93_clk_composite_gate_enable() always returns 0, even when
> imx93_clk_composite_wait_ready() times out.
>
> Fixes: 4a3de5aa7743 ("clk: imx: clk-composite-93: check slice busy")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/clk/imx/clk-composite-93.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-composite-93.c b/drivers/clk/imx/clk-composite-93.c
> index ef20ceb2d255..953f67d13978 100644
> --- a/drivers/clk/imx/clk-composite-93.c
> +++ b/drivers/clk/imx/clk-composite-93.c
> @@ -43,11 +43,12 @@ static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)
>         return ret;
>  }
>
> -static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
> +static int imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
>  {
>         struct clk_gate *gate = to_clk_gate(hw);
>         unsigned long flags;
>         u32 reg;
> +       int ret;
>
>         if (gate->lock)
>                 spin_lock_irqsave(gate->lock, flags);
> @@ -61,17 +62,17 @@ static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
>
>         writel(reg, gate->reg);
>
> -       imx93_clk_composite_wait_ready(hw, gate->reg);
> +       ret = imx93_clk_composite_wait_ready(hw, gate->reg);
>
>         if (gate->lock)
>                 spin_unlock_irqrestore(gate->lock, flags);
> +
> +       return ret;
>  }
>
>  static int imx93_clk_composite_gate_enable(struct clk_hw *hw)
>  {
> -       imx93_clk_composite_gate_endisable(hw, 1);
> -
> -       return 0;
> +       return imx93_clk_composite_gate_endisable(hw, 1);
>  }
>
>  static void imx93_clk_composite_gate_disable(struct clk_hw *hw)
> --
> 2.25.1
>
>

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

* Re: [PATCH v2] clk: imx: composite-93: return timeout from gate enable
  2026-09-07  2:22 ` [PATCH v2] " Linkai Gong
  2026-09-10 10:49   ` Peng Fan (OSS)
@ 2026-09-10 15:47   ` Frank Li
  1 sibling, 0 replies; 9+ messages in thread
From: Frank Li @ 2026-09-10 15:47 UTC (permalink / raw)
  To: Linkai Gong; +Cc: Abel Vesa, Peng Fan, Stephen Boyd, linux-clk, imx

On Mon, Sep 07, 2026 at 10:22:14AM +0800, Linkai Gong wrote:
> [You don't often get email from gonglinkai@kylinos.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> imx93_clk_composite_wait_ready() already reports a busy timeout, but
> imx93_clk_composite_gate_enable() ignores that and always returns 0.
> The clk framework then marks the clock enabled and lets consumers run
> while the CCM slice is still busy.
>
> Propagate the timeout so enable fails instead of looking successful.
>
> Fixes: 4a3de5aa7743 ("clk: imx: clk-composite-93: check slice busy")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
> ---
> v2:
> - Rewrite the commit message to explain why (Abel Vesa)

Don't post to v1's thread.

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
>  drivers/clk/imx/clk-composite-93.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-composite-93.c b/drivers/clk/imx/clk-composite-93.c
> index ef20ceb2d255..953f67d13978 100644
> --- a/drivers/clk/imx/clk-composite-93.c
> +++ b/drivers/clk/imx/clk-composite-93.c
> @@ -43,11 +43,12 @@ static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)
>         return ret;
>  }
>
> -static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
> +static int imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
>  {
>         struct clk_gate *gate = to_clk_gate(hw);
>         unsigned long flags;
>         u32 reg;
> +       int ret;
>
>         if (gate->lock)
>                 spin_lock_irqsave(gate->lock, flags);
> @@ -61,17 +62,17 @@ static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)
>
>         writel(reg, gate->reg);
>
> -       imx93_clk_composite_wait_ready(hw, gate->reg);
> +       ret = imx93_clk_composite_wait_ready(hw, gate->reg);
>
>         if (gate->lock)
>                 spin_unlock_irqrestore(gate->lock, flags);
> +
> +       return ret;
>  }
>
>  static int imx93_clk_composite_gate_enable(struct clk_hw *hw)
>  {
> -       imx93_clk_composite_gate_endisable(hw, 1);
> -
> -       return 0;
> +       return imx93_clk_composite_gate_endisable(hw, 1);
>  }
>
>  static void imx93_clk_composite_gate_disable(struct clk_hw *hw)
> --
> 2.25.1
>

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

end of thread, other threads:[~2026-09-10 15:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21  8:56 [PATCH] clk: imx: composite-93: return timeout from gate enable Linkai Gong
2026-08-21 11:49 ` Abel Vesa
2026-09-07  2:19   ` Linkai Gong
2026-09-02  8:19 ` Peng Fan
2026-09-07  2:20   ` Linkai Gong
2026-09-07  2:22 ` [PATCH v2] " Linkai Gong
2026-09-10 10:49   ` Peng Fan (OSS)
2026-09-10 15:47   ` Frank Li
2026-09-10 15:45 ` [PATCH] " Frank Li

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