DMA Engine development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Ruoyu Wang <ruoyuw560@gmail.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org,
	ed.blake@sondrel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: img-mdc: Fix runtime PM usage counter leak
Date: Thu, 13 Aug 2026 11:16:56 -0500	[thread overview]
Message-ID: <an3t-OJN4TdsS7fJ@SMW015318> (raw)
In-Reply-To: <20260813153143.3953303-1-ruoyuw560@gmail.com>

On Thu, Aug 13, 2026 at 11:31:43PM +0800, Ruoyu Wang wrote:
> [You don't often get email from ruoyuw560@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> pm_runtime_get_sync() leaves the IMG MDC device's usage counter
> incremented when runtime resume fails. mdc_alloc_chan_resources() returns
> that error to the DMA core, so the channel's client count is not
> incremented and mdc_free_chan_resources() is not called to drop the
> reference. Repeated allocation attempts can therefore accumulate usage
> references and prevent runtime suspend.
>
> Use pm_runtime_resume_and_get() so a failed resume does not retain a
> usage reference while successful allocations remain paired with
> mdc_free_chan_resources(). DMA core only treats negative return values as
> allocation failures, so the helper's zero success return preserves
> behavior.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: 56d355e6f586 ("dmaengine: img-mdc: Add runtime PM")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/img-mdc-dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c
> index b3765ba1580308..a3192d49b6c860 100644
> --- a/drivers/dma/img-mdc-dma.c
> +++ b/drivers/dma/img-mdc-dma.c
> @@ -738,7 +738,7 @@ static int mdc_alloc_chan_resources(struct dma_chan *chan)
>         struct mdc_chan *mchan = to_mdc_chan(chan);
>         struct device *dev = mdma2dev(mchan->mdma);
>
> -       return pm_runtime_get_sync(dev);
> +       return pm_runtime_resume_and_get(dev);
>  }
>
>  static void mdc_free_chan_resources(struct dma_chan *chan)
> --
> 2.51.0
>

      parent reply	other threads:[~2026-08-13 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:31 [PATCH] dmaengine: img-mdc: Fix runtime PM usage counter leak Ruoyu Wang
2026-08-13 15:45 ` sashiko-bot
2026-08-13 16:16 ` Frank Li [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=an3t-OJN4TdsS7fJ@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=ed.blake@sondrel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ruoyuw560@gmail.com \
    --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