* [PATCH v2 0/2] clk: renesas: rzg2l-cpg: MSTOP adjustments
@ 2026-12-04 9:45 Claudiu Beznea
2026-12-04 9:45 ` [PATCH v2 1/2] clk: renesas: rzg2l-cpg: Do not set MSTOP to standby on resume if in use Claudiu Beznea
2026-12-04 9:45 ` [PATCH v2 2/2] clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume Claudiu Beznea
0 siblings, 2 replies; 4+ messages in thread
From: Claudiu Beznea @ 2026-12-04 9:45 UTC (permalink / raw)
To: geert+renesas, sboyd, bmasney+clk, jbrunet+clk
Cc: claudiu.beznea, linux-renesas-soc, linux-clk, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Hi,
This series adds two patches for the RZ/G2L CPG driver:
- patch 1/2 fixes the MSTOP state restore when resuming
- patch 2/2 skips restoring the MSTOP and reset settings when resuming
from a suspend that did not go through the firmware (e.g. s2idle),
as the CPG state is preserved in that case
Please let me know your feedback.
Thank you,
Claudiu
Changes in v2:
- added patch "clk: renesas: rzg2l-cpg: Do not set MSTOP to standby on
resume if in use"
- adjusted the description for patch 2/2
Claudiu Beznea (2):
clk: renesas: rzg2l-cpg: Do not set MSTOP to standby on resume if in
use
clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle
resume
drivers/clk/renesas/rzg2l-cpg.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 1/2] clk: renesas: rzg2l-cpg: Do not set MSTOP to standby on resume if in use
2026-12-04 9:45 [PATCH v2 0/2] clk: renesas: rzg2l-cpg: MSTOP adjustments Claudiu Beznea
@ 2026-12-04 9:45 ` Claudiu Beznea
2026-12-04 9:45 ` [PATCH v2 2/2] clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume Claudiu Beznea
1 sibling, 0 replies; 4+ messages in thread
From: Claudiu Beznea @ 2026-12-04 9:45 UTC (permalink / raw)
To: geert+renesas, sboyd, bmasney+clk, jbrunet+clk
Cc: claudiu.beznea, linux-renesas-soc, linux-clk, Claudiu Beznea,
stable
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
When a device is part of the wakeup path, only some of its clocks may be
left enabled during suspend. If those clocks share the same MSTOP with
clocks that were disabled, rzg2l_cpg_resume() calls
rzg2l_mod_clock_module_set_state() for the disabled clocks. This decrements
the MSTOP usage counter, which these clocks never incremented, and may put
the module in standby while it is still in use. Accessing the module
afterwards leads to synchronous aborts.
Set the module MSTOP to standby on init/resume only if its usage counter
is zero.
Fixes: 5cd33db56956 ("clk: renesas: rzg2l: Add support for MSTOP in clock enable/disable API")
Cc: stable@vger.kernel.org
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v2:
- none, this patch is new
drivers/clk/renesas/rzg2l-cpg.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index 06ae7228a954..49cdb205fcc0 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -2182,11 +2182,13 @@ static void rzg2l_mod_clock_init_mstop_helper(struct rzg2l_cpg_priv *priv,
{
/*
* Out of reset all modules are enabled. Set module state in case
- * associated clocks are disabled at probe/resume. Otherwise module
- * is in invalid HW state.
+ * associated clocks are disabled at probe/resume and the shared
+ * MSTOP usage counter is zero. Otherwise module is in invalid HW
+ * state.
*/
scoped_guard(spinlock_irqsave, &priv->rmw_lock) {
- if (!rzg2l_mod_clock_is_enabled(&clk->hw))
+ if (!rzg2l_mod_clock_is_enabled(&clk->hw) &&
+ !atomic_read(&clk->mstop->usecnt))
rzg2l_mod_clock_module_set_state(clk, true);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume
2026-12-04 9:45 [PATCH v2 0/2] clk: renesas: rzg2l-cpg: MSTOP adjustments Claudiu Beznea
2026-12-04 9:45 ` [PATCH v2 1/2] clk: renesas: rzg2l-cpg: Do not set MSTOP to standby on resume if in use Claudiu Beznea
@ 2026-12-04 9:45 ` Claudiu Beznea
2026-12-04 9:59 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Claudiu Beznea @ 2026-12-04 9:45 UTC (permalink / raw)
To: geert+renesas, sboyd, bmasney+clk, jbrunet+clk
Cc: claudiu.beznea, linux-renesas-soc, linux-clk, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
When the system is not suspended via firmware (e.g. s2idle), the CPG is
not powered off and its registers, including the reset and MSTOP
settings, are preserved. There is no need to de-assert the critical
resets and re-initialize the MSTOP settings on resume in that case.
Skip these steps when resuming from a suspend that did not go through
the firmware.
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v2:
- updated the patch description
drivers/clk/renesas/rzg2l-cpg.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index 49cdb205fcc0..66398e9a38f3 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -31,6 +31,7 @@
#include <linux/reset-controller.h>
#include <linux/slab.h>
#include <linux/string_choices.h>
+#include <linux/suspend.h>
#include <linux/units.h>
#include <dt-bindings/clock/renesas-cpg-mssr.h>
@@ -2699,6 +2700,9 @@ static int rzg2l_cpg_resume(struct device *dev)
struct rzg2l_cpg_priv *priv = dev_get_drvdata(dev);
int ret;
+ if (!pm_suspend_via_firmware())
+ return 0;
+
ret = rzg2l_cpg_deassert_crit_resets(&priv->rcdev, priv->info);
if (ret)
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume
2026-12-04 9:45 ` [PATCH v2 2/2] clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume Claudiu Beznea
@ 2026-12-04 9:59 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-04 9:59 UTC (permalink / raw)
To: Claudiu Beznea; +Cc: linux-clk, wsa+renesas
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] clk: renesas: rzg2l_cpg_resume() skips restore on RISC-V SBI
suspend-to-RAM
- [Medium] clk: renesas: rzg2l_cpg_resume() disables hibernation
restore_noirq
--
commit 125f430fe29577ed1821b9bcbe0dc9f5cab8e351
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume
This commit returns early from rzg2l_cpg_resume() when
pm_suspend_via_firmware() is false, skipping reset de-assertion and
MSTOP re-initialization.
> diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
> index 5b255d8a7a6f3..07ff6282622b5 100644
> --- a/drivers/clk/renesas/rzg2l-cpg.c
> +++ b/drivers/clk/renesas/rzg2l-cpg.c
[ ... ]
> @@ -2699,6 +2700,9 @@ static int rzg2l_cpg_resume(struct device *dev)
> struct rzg2l_cpg_priv *priv = dev_get_drvdata(dev);
> int ret;
>
> + if (!pm_suspend_via_firmware())
> + return 0;
> +
> ret = rzg2l_cpg_deassert_crit_resets(&priv->rcdev, priv->info);
> if (ret)
> return ret;
[Severity: High]
Does this skip CPG restore on RISC-V SBI suspend-to-RAM?
In arch/riscv/kernel/suspend.c, sbi_system_suspend_ops has no .begin
callback and never calls pm_set_suspend_via_firmware(), so
pm_suspend_via_firmware() always returns false on RISC-V.
On RZ/Five (r9a07g043), resuming from SBI suspend-to-RAM skips
rzg2l_cpg_deassert_crit_resets() and
rzg2l_mod_enable_crit_clock_init_mstop(), leaving the DMAC resets
asserted, module clocks disabled, and MSTOP state out of sync.
Checking pm_suspend_no_platform(), which suspend_devices_and_enter()
sets specifically for PM_SUSPEND_TO_IDLE, would target s2idle without
breaking RISC-V suspend-to-RAM.
[Severity: Medium]
Will this also disable hibernation restore?
NOIRQ_SYSTEM_SLEEP_PM_OPS() wires rzg2l_cpg_resume() to .restore_noirq
as well. During hibernation, hibernation_snapshot() clears the suspend
flags and DT platforms register no platform_hibernation_ops, so
pm_suspend_via_firmware() is false during dpm_resume_start(PMSG_RESTORE).
With CONFIG_HIBERNATION=y and CONFIG_SUSPEND=n, pm_suspend_via_firmware()
is also stubbed to return false, making .restore_noirq a permanent no-op
and leaving boot-kernel reset, clock, and MSTOP states unreconciled with
the restored image.
Using pm_suspend_no_platform(), or separating .resume_noirq and
.restore_noirq in rzg2l_cpg_pm_ops, would preserve hibernation restore.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204094532.1052522-1-claudiu.beznea@kernel.org?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 9:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 9:45 [PATCH v2 0/2] clk: renesas: rzg2l-cpg: MSTOP adjustments Claudiu Beznea
2026-12-04 9:45 ` [PATCH v2 1/2] clk: renesas: rzg2l-cpg: Do not set MSTOP to standby on resume if in use Claudiu Beznea
2026-12-04 9:45 ` [PATCH v2 2/2] clk: renesas: rzg2l-cpg: Skip resets and MSTOP restore on s2idle resume Claudiu Beznea
2026-12-04 9:59 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox