* [PATCH] counter: rz-mtu3-cnt: Abort probe if clock enable fails
@ 2026-11-29 19:25 Jiawen Liu
2026-12-04 22:08 ` William Breathitt Gray
0 siblings, 1 reply; 2+ messages in thread
From: Jiawen Liu @ 2026-11-29 19:25 UTC (permalink / raw)
To: Biju Das, William Breathitt Gray; +Cc: linux-iio, linux-renesas-soc
When the RZ/G2L MTU3 module clock has no active enable reference,
clk_prepare_enable() can reach the CPG gate callback and return
-ETIMEDOUT if the gate fails to report enabled.
rz_mtu3_cnt_probe() ignores the error, marks the device runtime-active,
and registers the Counter. Later Counter operations can access registers
while the clock may still be off. Probe error handling or runtime suspend
can also release a clock reference the probe never acquired.
Return the error through dev_err_probe() before setting up runtime PM or
registering the Counter. clk_prepare_enable() rolls back the prepare
reference on enable failure, so only errors after a successful enable
need the existing clock cleanup.
Verification included source review,
an arm64 RZ/G2L driver object build, git diff --check, and checkpatch.
Runtime and hardware reproduction were not performed.
Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
drivers/counter/rz-mtu3-cnt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index 7bfb6979193ce..c8050ccb7ae98 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -861,7 +861,10 @@ static int rz_mtu3_cnt_probe(struct platform_device *pdev)
mutex_init(&priv->lock);
platform_set_drvdata(pdev, priv->clk);
- clk_prepare_enable(priv->clk);
+ ret = clk_prepare_enable(priv->clk);
+ if (ret)
+ return dev_err_probe(dev, ret, "Clock enable failed\n");
+
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
ret = devm_add_action_or_reset(&pdev->dev, rz_mtu3_cnt_pm_disable, dev);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] counter: rz-mtu3-cnt: Abort probe if clock enable fails
2026-11-29 19:25 [PATCH] counter: rz-mtu3-cnt: Abort probe if clock enable fails Jiawen Liu
@ 2026-12-04 22:08 ` William Breathitt Gray
0 siblings, 0 replies; 2+ messages in thread
From: William Breathitt Gray @ 2026-12-04 22:08 UTC (permalink / raw)
To: Jiawen Liu; +Cc: William Breathitt Gray, Biju Das, linux-iio, linux-renesas-soc
On Sun, Nov 29, 2026 at 07:25:33PM +0000, Jiawen Liu wrote:
> When the RZ/G2L MTU3 module clock has no active enable reference,
> clk_prepare_enable() can reach the CPG gate callback and return
> -ETIMEDOUT if the gate fails to report enabled.
>
> rz_mtu3_cnt_probe() ignores the error, marks the device runtime-active,
> and registers the Counter. Later Counter operations can access registers
> while the clock may still be off. Probe error handling or runtime suspend
> can also release a clock reference the probe never acquired.
>
> Return the error through dev_err_probe() before setting up runtime PM or
> registering the Counter. clk_prepare_enable() rolls back the prepare
> reference on enable failure, so only errors after a successful enable
> need the existing clock cleanup.
>
> Verification included source review,
> an arm64 RZ/G2L driver object build, git diff --check, and checkpatch.
> Runtime and hardware reproduction were not performed.
>
> Fixes: 0be8907359df ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
> ---
> drivers/counter/rz-mtu3-cnt.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
> index 7bfb6979193ce..c8050ccb7ae98 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -861,7 +861,10 @@ static int rz_mtu3_cnt_probe(struct platform_device *pdev)
>
> mutex_init(&priv->lock);
> platform_set_drvdata(pdev, priv->clk);
> - clk_prepare_enable(priv->clk);
> + ret = clk_prepare_enable(priv->clk);
> + if (ret)
> + return dev_err_probe(dev, ret, "Clock enable failed\n");
> +
> pm_runtime_set_active(&pdev->dev);
> pm_runtime_enable(&pdev->dev);
> ret = devm_add_action_or_reset(&pdev->dev, rz_mtu3_cnt_pm_disable, dev);
> --
> 2.34.1
FYI, this section of code is being refactored in another patch. [^1]
William Breathitt Gray
[^1]: https://lore.kernel.org/all/20261201220257.647022-3-cosmin-gabriel.tanislav.xa@renesas.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 19:25 [PATCH] counter: rz-mtu3-cnt: Abort probe if clock enable fails Jiawen Liu
2026-12-04 22:08 ` William Breathitt Gray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox