DMA Engine development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: sashiko-reviews@lists.linux.dev, dmaengine@vger.kernel.org,
	Frank Li <Frank.Li@kernel.org>, Vinod Koul <vkoul@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()
Date: Thu, 19 Nov 2026 11:41:54 -0600	[thread overview]
Message-ID: <av804gPG5A8_8UkG@SMW015318> (raw)
In-Reply-To: <216e7cd0-10b9-45a0-9eba-b53cbc6fda4f@web.de>

On Thu, Nov 19, 2026 at 06:22:41PM +0100, Markus Elfring wrote:
> >> Thank you for your contribution! Sashiko AI review found 1 potential
> >> issue to consider:
> >> - [High] dmaengine: dw: double clk_disable_unprepare() in dw_probe() and
> >>   dw_remove()
> >> --
> >>
> >> commit ff07f5838666895fdb235cca7d9f7155e7085b00
> >> Author: Markus Elfring <elfring@users.sourceforge.net>
> >>
> >> dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe()
> >>
> >> This commit replaces devm_clk_get_optional() and clk_prepare_enable() in
> >> dw_probe() with devm_clk_get_optional_enabled().
> >>
> >>> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> >>> index 7e76391475ac1..9bb3c2cd08570 100644
> >>> --- a/drivers/dma/dw/platform.c
> >>> +++ b/drivers/dma/dw/platform.c
> >>> @@ -64,12 +64,9 @@ static int dw_probe(struct platform_device *pdev)
> >>>
> >>>  	data->chip = chip;
> >>>
> >>> -	chip->clk = devm_clk_get_optional(chip->dev, "hclk");
> >>> +	chip->clk = devm_clk_get_optional_enabled(chip->dev, "hclk");
> >>>  	if (IS_ERR(chip->clk))
> >>>  		return PTR_ERR(chip->clk);
> >>> -	ret = clk_prepare_enable(chip->clk);
> >>> -	if (ret)
> >>> -		return ret;
> >>>
> >>>  	pm_runtime_enable(&pdev->dev);
> >>>
> >>
> >> [Severity: High]
> >> Does this cause a double clk_disable_unprepare() on chip->clk?
> >>
> >> devm_clk_get_optional_enabled() registers a devres cleanup that disables
> >> and unprepares chip->clk automatically, but both the err_dw_dma_probe
> >> error path in dw_probe() and dw_remove() still call
> >> clk_disable_unprepare(chip->clk) manually.  When data->probe() fails or
> >> the device is unbound, chip->clk is disabled and unprepared twice,
> >> underflowing the clock reference counts and triggering WARN() splats in
> >> the clock core.
> >
> > Please fix this problem
>
> Do you find these two function calls really not equivalent to another known function call?
> https://elixir.bootlin.com/linux/v7.4-rc1/source/include/linux/clk.h#L680-L699

What's your point? Sashiko just remind you need remove
clk unprepare at error path and remove() function

Frank
>
> Regards,
> Markus
>
>
> …
> >> --
> >> Sashiko AI review · https://sashiko.dev/#/patchset/8e3534b7-ae64-4c1f-819d-0ba390737b84@web.de?part=1
>

  reply	other threads:[~2026-11-19 17:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 16:06 [PATCH] dmaengine: dw: Use devm_clk_get_optional_enabled() in dw_probe() Markus Elfring
2026-11-19 16:12 ` sashiko-bot
2026-11-19 16:53   ` Frank Li
2026-11-19 17:22     ` Markus Elfring
2026-11-19 17:41       ` Frank Li [this message]
2026-11-19 17:16 ` Andy Shevchenko
2026-11-19 17:27   ` Markus Elfring
2026-11-19 17:36     ` Andy Shevchenko

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=av804gPG5A8_8UkG@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=Markus.Elfring@web.de \
    --cc=dmaengine@vger.kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox