[PATCH v6 05/10] clk: renesas: rzg2l-cpg: Re-enable critical module clocks during resume

Biju posted 10 patches 2 weeks, 3 days ago
There is a newer version of this series
[PATCH v6 05/10] clk: renesas: rzg2l-cpg: Re-enable critical module clocks during resume
Posted by Biju 2 weeks, 3 days ago
From: Biju Das <biju.das.jz@bp.renesas.com>

After a suspend/resume cycle, critical module clocks (CLK_IS_CRITICAL) may
be left disabled as there is no owning driver to restore them, unlike
regular clocks. Add rzg2l_mod_enable_crit_clock_init_mstop() which walks
all module clocks on resume, re-enables any critical clock found disabled,
and then restores its MSTOP state via the existing helper. This replaces
the direct call to rzg2l_mod_clock_init_mstop() in rzg2l_cpg_resume(),
preserving the correct clock-before-MSTOP restore ordering.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v5->v6:
 * Updated commit description
 * Dropped the list implementation.
 * Replaced  rzg2l_mod_clock_init_mstop->rzg2l_mod_enable_crit_clock_init_mstop() 
   for enabling critical clks and restoring mstop state during resume.
v4->v5:
 * No change
v4:
 * Moved this patch from [1] as it is boot-dependent
 [1] https://lore.kernel.org/all/20260306134228.871815-1-biju.das.jz@bp.renesas.com/
---
 drivers/clk/renesas/rzg2l-cpg.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index b68b0312f0e3..7899c79734e1 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -1600,6 +1600,23 @@ static void rzg2l_mod_clock_init_mstop_helper(struct rzg2l_cpg_priv *priv,
 	}
 }
 
+static void rzg2l_mod_enable_crit_clock_init_mstop(struct rzg2l_cpg_priv *priv)
+{
+	struct mod_clock *clk;
+	struct clk_hw *hw;
+
+	for_each_mod_clock(clk, hw, priv) {
+		if (!clk->mstop)
+			continue;
+
+		if ((clk_hw_get_flags(&clk->hw) & CLK_IS_CRITICAL) &&
+		    (!rzg2l_mod_clock_is_enabled(&clk->hw)))
+			rzg2l_mod_clock_endisable(&clk->hw, true);
+
+		rzg2l_mod_clock_init_mstop_helper(priv, clk);
+	}
+}
+
 static void rzg2l_mod_clock_init_mstop(struct rzg2l_cpg_priv *priv)
 {
 	struct mod_clock *clk;
@@ -2095,7 +2112,7 @@ static int rzg2l_cpg_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	rzg2l_mod_clock_init_mstop(priv);
+	rzg2l_mod_enable_crit_clock_init_mstop(priv);
 
 	return 0;
 }
-- 
2.43.0
Re: [PATCH v6 05/10] clk: renesas: rzg2l-cpg: Re-enable critical module clocks during resume
Posted by Geert Uytterhoeven 2 weeks, 3 days ago
Hi Biju,

On Thu, 19 Mar 2026 at 13:51, Biju <biju.das.au@gmail.com> wrote:
> From: Biju Das <biju.das.jz@bp.renesas.com>
>
> After a suspend/resume cycle, critical module clocks (CLK_IS_CRITICAL) may
> be left disabled as there is no owning driver to restore them, unlike
> regular clocks. Add rzg2l_mod_enable_crit_clock_init_mstop() which walks
> all module clocks on resume, re-enables any critical clock found disabled,
> and then restores its MSTOP state via the existing helper. This replaces
> the direct call to rzg2l_mod_clock_init_mstop() in rzg2l_cpg_resume(),
> preserving the correct clock-before-MSTOP restore ordering.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v5->v6:
>  * Updated commit description
>  * Dropped the list implementation.
>  * Replaced  rzg2l_mod_clock_init_mstop->rzg2l_mod_enable_crit_clock_init_mstop()
>    for enabling critical clks and restoring mstop state during resume.

Thanks for the update!

> --- a/drivers/clk/renesas/rzg2l-cpg.c
> +++ b/drivers/clk/renesas/rzg2l-cpg.c
> @@ -1600,6 +1600,23 @@ static void rzg2l_mod_clock_init_mstop_helper(struct rzg2l_cpg_priv *priv,
>         }
>  }
>
> +static void rzg2l_mod_enable_crit_clock_init_mstop(struct rzg2l_cpg_priv *priv)
> +{
> +       struct mod_clock *clk;
> +       struct clk_hw *hw;
> +
> +       for_each_mod_clock(clk, hw, priv) {
> +               if (!clk->mstop)
> +                       continue;

RZ/V2M has critical clocks, but no mstop, so I think this check should
be moved below the call to rzg2l_mod_clock_endisable()...

> +
> +               if ((clk_hw_get_flags(&clk->hw) & CLK_IS_CRITICAL) &&
> +                   (!rzg2l_mod_clock_is_enabled(&clk->hw)))
> +                       rzg2l_mod_clock_endisable(&clk->hw, true);
> +

... i.e.

    if (clk->mstop)

> +               rzg2l_mod_clock_init_mstop_helper(priv, clk);
> +       }
> +}
> +
>  static void rzg2l_mod_clock_init_mstop(struct rzg2l_cpg_priv *priv)
>  {
>         struct mod_clock *clk;

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds