All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Breathitt Gray <wbg@kernel.org>
To: Jiawen Liu <liu1298662399@gmail.com>
Cc: William Breathitt Gray <wbg@kernel.org>,
	Biju Das <biju.das.jz@bp.renesas.com>,
	linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] counter: rz-mtu3-cnt: Abort probe if clock enable fails
Date: Fri,  4 Dec 2026 17:08:01 -0500	[thread overview]
Message-ID: <20261204220803.691569-1-wbg@kernel.org> (raw)
In-Reply-To: <179598033975.2.6271980880185966626.pattern-ext-107.15@gmail.com>

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/

      reply	other threads:[~2026-12-04 22:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204220803.691569-1-wbg@kernel.org \
    --to=wbg@kernel.org \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=liu1298662399@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.