All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: arina.kharlamova@mbzuai.ac.ae
Cc: Sean Wang <sean.wang@mediatek.com>, Vinod Koul <vkoul@kernel.org>,
	Frank Li <Frank.Li@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	zhangqilong <zhangqilong3@huawei.com>,
	dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: mediatek: mtk-uart-apdma: Fix runtime PM usage count
Date: Tue, 1 Dec 2026 14:10:16 -0600	[thread overview]
Message-ID: <aw8pqBmUlc2nFeDV@SMW015318> (raw)
In-Reply-To: <20261201-s2p-c03-v1-1-1db0d74a538c@mbzuai.ac.ae>

On Tue, Dec 01, 2026 at 02:55:28AM +0400, Arina Kharlamova via B4 Relay wrote:
> [You don't often get email from devnull+arina.kharlamova.mbzuai.ac.ae@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
>
> Commit 545b2baac89b ("dmaengine: mediatek:Fix PM usage reference leak
> of mtk_uart_apdma_alloc_chan_resources") switched
> mtk_uart_apdma_alloc_chan_resources() to pm_runtime_resume_and_get()
> and added an err_pm label. It left two problems behind.
>
> The pm_runtime_put_noidle() on the resume error path was kept, but
> pm_runtime_resume_and_get() already drops the usage count when it
> fails, so the count is dropped twice.
>
> The success path falls through into err_pm, so the function drops the
> reference it has just taken. mtk_uart_apdma_free_chan_resources() then
> calls pm_runtime_put_sync() on a count that is already zero.
>
> Return the error directly when the resume fails, and return 0 before
> err_pm on success.
>
> Fixes: 545b2baac89b ("dmaengine: mediatek:Fix PM usage reference leak of mtk_uart_apdma_alloc_chan_resources")
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
> ---

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

> Found by checks derived from the spec2patch kernel API specifications,
> with the help of an AI coding assistant (Claude); I reviewed the
> analysis and the fix.
> ---
>  drivers/dma/mediatek/mtk-uart-apdma.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
> index bf242c4c262f..d59a07ab1aae 100644
> --- a/drivers/dma/mediatek/mtk-uart-apdma.c
> +++ b/drivers/dma/mediatek/mtk-uart-apdma.c
> @@ -274,10 +274,8 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan)
>         int ret;
>
>         ret = pm_runtime_resume_and_get(mtkd->ddev.dev);
> -       if (ret < 0) {
> -               pm_runtime_put_noidle(chan->device->dev);
> +       if (ret < 0)
>                 return ret;
> -       }
>
>         mtk_uart_apdma_write(c, VFF_ADDR, 0);
>         mtk_uart_apdma_write(c, VFF_THRE, 0);
> @@ -300,6 +298,8 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan)
>         if (mtkd->support_ext_addr)
>                 mtk_uart_apdma_write(c, VFF_ADDR2, VFF_ADDR2_CLR_B);
>
> +       return 0;
> +
>  err_pm:
>         pm_runtime_put_noidle(mtkd->ddev.dev);
>         return ret;
>
> ---
> base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
> change-id: 20261129-s2p-c03-aa7e4bb16aa9
>
> Best regards,
> --
> Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
>
>

      reply	other threads:[~2026-12-01 20:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 22:55 [PATCH] dmaengine: mediatek: mtk-uart-apdma: Fix runtime PM usage count Arina Kharlamova
2026-11-30 22:55 ` Arina Kharlamova via B4 Relay
2026-12-01 20:10 ` 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=aw8pqBmUlc2nFeDV@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=arina.kharlamova@mbzuai.ac.ae \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=sean.wang@mediatek.com \
    --cc=vkoul@kernel.org \
    --cc=zhangqilong3@huawei.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.