All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Ginger Li <ginger.jzllee@gmail.com>
Cc: sean.wang@mediatek.com, vkoul@kernel.org, Frank.Li@kernel.org,
	matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.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: milbeaut-hdmac: Fix deadlock with the channel IRQ handler
Date: Wed, 23 Sep 2026 10:23:33 -0500	[thread overview]
Message-ID: <arPu9TwyACiAlw94@SMW015318> (raw)
In-Reply-To: <20260923094426.67872-1-ginger.jzllee@gmail.com>

On Wed, Sep 23, 2026 at 05:44:26PM +0800, Ginger Li wrote:
> [You don't often get email from ginger.jzllee@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> milbeaut_hdmac_interrupt() is a hardirq handler and takes mc->vc.lock with a
> plain spin_lock() for the whole time it runs.  interrupts are disabled locally
> in that context, so the handler itself is fine.
>
> milbeaut_hdmac_chan_config(), milbeaut_hdmac_chan_pause() and
> milbeaut_hdmac_chan_resume() are called from process context and take the same
> lock with a plain spin_lock() as well, so interrupts stay enabled while the
> lock is held.
>
> If a channel interrupt is delivered on the CPU that is inside one of those
> critical sections, milbeaut_hdmac_interrupt() spins on a lock that the
> interrupted code is holding and can never release, and the CPU hangs.
>
> Take mc->vc.lock with spin_lock_irqsave() in those three functions, as
> milbeaut_hdmac_issue_pending() and the other process context users of this
> lock already do.
>
> Fixes: 6c3214e698e4 ("dmaengine: milbeaut-hdmac: Add HDMAC driver for Milbeaut platforms")
> Signed-off-by: Ginger Li <ginger.jzllee@gmail.com>
> ---

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

>  drivers/dma/milbeaut-hdmac.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/milbeaut-hdmac.c b/drivers/dma/milbeaut-hdmac.c
> --- a/drivers/dma/milbeaut-hdmac.c
> +++ b/drivers/dma/milbeaut-hdmac.c
> @@ -214,10 +214,11 @@ milbeaut_hdmac_chan_config(struct dma_chan *chan, stru
>  {
>         struct virt_dma_chan *vc = to_virt_chan(chan);
>         struct milbeaut_hdmac_chan *mc = to_milbeaut_hdmac_chan(vc);
> +       unsigned long flags;
>
> -       spin_lock(&mc->vc.lock);
> +       spin_lock_irqsave(&mc->vc.lock, flags);
>         mc->cfg = *cfg;
> -       spin_unlock(&mc->vc.lock);
> +       spin_unlock_irqrestore(&mc->vc.lock, flags);
>
>         return 0;
>  }
> @@ -226,13 +227,14 @@ static int milbeaut_hdmac_chan_pause(struct dma_chan *
>  {
>         struct virt_dma_chan *vc = to_virt_chan(chan);
>         struct milbeaut_hdmac_chan *mc = to_milbeaut_hdmac_chan(vc);
> +       unsigned long flags;
>         u32 val;
>
> -       spin_lock(&mc->vc.lock);
> +       spin_lock_irqsave(&mc->vc.lock, flags);
>         val = readl_relaxed(mc->reg_ch_base + MLB_HDMAC_DMACA);
>         val |= MLB_HDMAC_PB;
>         writel_relaxed(val, mc->reg_ch_base + MLB_HDMAC_DMACA);
> -       spin_unlock(&mc->vc.lock);
> +       spin_unlock_irqrestore(&mc->vc.lock, flags);
>
>         return 0;
>  }
> @@ -241,13 +243,14 @@ static int milbeaut_hdmac_chan_resume(struct dma_chan
>  {
>         struct virt_dma_chan *vc = to_virt_chan(chan);
>         struct milbeaut_hdmac_chan *mc = to_milbeaut_hdmac_chan(vc);
> +       unsigned long flags;
>         u32 val;
>
> -       spin_lock(&mc->vc.lock);
> +       spin_lock_irqsave(&mc->vc.lock, flags);
>         val = readl_relaxed(mc->reg_ch_base + MLB_HDMAC_DMACA);
>         val &= ~MLB_HDMAC_PB;
>         writel_relaxed(val, mc->reg_ch_base + MLB_HDMAC_DMACA);
> -       spin_unlock(&mc->vc.lock);
> +       spin_unlock_irqrestore(&mc->vc.lock, flags);
>
>         return 0;
>  }
> --
> 2.43.0
>


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  9:44 [PATCH] dmaengine: milbeaut-hdmac: Fix deadlock with the channel IRQ handler Ginger Li
2026-09-23 15:23 ` 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=arPu9TwyACiAlw94@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=ginger.jzllee@gmail.com \
    --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 \
    /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.