DMA Engine development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: "Golla, Nagendra" <Nagendra.Golla@amd.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, michal.simek@amd.com,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	rafael@kernel.org, git@amd.com, dmaengine@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH V3 1/6] dmaengine: zynqmp_dma: Fix PM usage count handling in probe error path
Date: Fri, 21 Aug 2026 10:09:22 -0500	[thread overview]
Message-ID: <aohqItUOivG0UXhC@SMW015318> (raw)
In-Reply-To: <25b9e249-053f-4560-ab3c-eaa30bf0b240@amd.com>

On Fri, Aug 21, 2026 at 09:57:49AM +0530, Golla, Nagendra wrote:
> Hi Frank
>
> On 8/11/2026 9:43 PM, Frank Li wrote:
> > On Mon, Aug 10, 2026 at 03:34:47PM +0530, Golla Nagendra wrote:
> > > When pm_runtime_resume_and_get() succeeds during probe, it increments
> > > the usage count and enables clocks. If a later step (e.g., channel
> > > probe) fails, the error path only called pm_runtime_disable() without
> > > a matching pm_runtime_put_sync(), leaking the reference and the clock
> > > enable.
> > >
> > > Add an else branch to drop the usage count acquired by
> > > pm_runtime_resume_and_get() when runtime PM is still enabled, letting
> > > the PM core suspend/disable clocks on the success-then-later-failure
> > > path.
> > >
> > > Fixes: 64c6f7da8c2c ("dmaengine: zynqmp_dma: Add runtime pm support")
> > > Signed-off-by: Golla Nagendra <nagendra.golla@amd.com>
> > > ---
> > > Changes in V3:
> > > - New patch: split from V2 2/3 per Frank Li's review to keep the PM usage
> > >    count fix separate from the per-channel reset changes
> > > ---
> > >   drivers/dma/xilinx/zynqmp_dma.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
> > > index f6a812e49ddc..87986f65d24c 100644
> > > --- a/drivers/dma/xilinx/zynqmp_dma.c
> > > +++ b/drivers/dma/xilinx/zynqmp_dma.c
> > > @@ -1152,6 +1152,8 @@ static int zynqmp_dma_probe(struct platform_device *pdev)
> > >   err_disable_pm:
> > >   	if (!pm_runtime_enabled(zdev->dev))
> >
> > You just enable runtime pm above few lines.  Is it for CONFIG_PM?
> >
> > You should check return value of pm_runtime_enable(), or change to use
> >
> > devm_pm_runtime_enable().
> >
> > if devm_runtime_enable() failure, you can direct return. Need check
> > pm_runtime_enabled() here again.
> >
> > >   		zynqmp_dma_runtime_suspend(zdev->dev);
> > > +	else
> > > +		pm_runtime_put_sync(zdev->dev);
> >
> > This one suggest use PM acquire to fix this.
> Thanks for the review
>
> The probe error path already holds a reference from
> pm_runtime_resume_and_get().Using PM_RUNTIME_ACQUIRE_IF_ACTIVE() here would

My means replace pm_runtime_resume_and_get() with PM_RUNTIME_ACQUIRE_IF_ACTIVE()

> acquire a second reference on top of the existing one incrementing the usage
> count to 2, and the guard releasing one at scope exit would still leave one
> leaked reference. The guard is designed for cases where no reference is held
> yet (like the IRQ handler). Here we just need to release the one existing

call pm_runtime_put() before return 0 at probe, which have not hold
runtime pm count for IRQ.

Frank

> reference, so i am using the pm_runtime_put_sync_suspend().
>
> Thanks,
> Nagendra
> >
> > Frank
> >
> > >   	pm_runtime_disable(zdev->dev);
> > >   	return ret;
> > >   }
> > > --
> > > 2.43.7
> > >
>

  reply	other threads:[~2026-08-21 15:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 10:04 [PATCH V3 0/6] dmaengine: zynqmp_dma: Per-channel reset, IRQ guard improvements, and PM fixes Golla Nagendra
2026-08-10 10:04 ` [PATCH V3 1/6] dmaengine: zynqmp_dma: Fix PM usage count handling in probe error path Golla Nagendra
2026-08-10 10:28   ` sashiko-bot
2026-08-11 10:55     ` Golla, Nagendra
2026-08-11 16:13   ` Frank Li
2026-08-21  4:27     ` Golla, Nagendra
2026-08-21 15:09       ` Frank Li [this message]
2026-08-10 10:04 ` [PATCH V3 2/6] PM: runtime: Add pm_runtime_if_active guard and conditional variant Golla Nagendra
2026-08-10 10:25   ` sashiko-bot
2026-08-11 10:54     ` Golla, Nagendra
2026-08-10 10:04 ` [PATCH V3 3/6] dmaengine: zynqmp_dma: Guard IRQ handler against spurious interrupts Golla Nagendra
2026-08-10 10:04 ` [PATCH V3 4/6] dt-bindings: dma: xlnx,zynqmp-dma: Add Versal Net compatible support Golla Nagendra
2026-08-10 10:20   ` sashiko-bot
2026-08-11 10:50     ` Golla, Nagendra
2026-08-11 16:41   ` Frank Li
2026-08-21  4:30     ` Golla, Nagendra
2026-08-12 10:43   ` Krzysztof Kozlowski
2026-08-21  4:36     ` Golla, Nagendra
2026-08-10 10:04 ` [PATCH V3 5/6] dmaengine: zynqmp_dma: Add new compatible string for Versal Net Golla Nagendra
2026-08-10 10:20   ` sashiko-bot
2026-08-11 10:52     ` Golla, Nagendra
2026-08-10 10:04 ` [PATCH V3 6/6] dmaengine: zynqmp_dma: Add per-channel reset support Golla Nagendra

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=aohqItUOivG0UXhC@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=Nagendra.Golla@amd.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=git@amd.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --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