From: Frank Li <Frank.li@oss.nxp.com>
To: Hongling Zeng <zenghongling@kylinos.cn>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, wens@kernel.org,
jernej.skrabec@gmail.com, samuel@sholland.org,
mripard@kernel.org, arnd@arndb.de, dmaengine@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
zhongling0719@126.com, stable@vger.kernel.org
Subject: Re: [PATCH v2] dmaengine: sun6i: Fix potential deadlock on sdev->lock
Date: Fri, 16 Oct 2026 11:39:22 -0400 [thread overview]
Message-ID: <atJFKnNXdtFjTsQ9@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260706031721.24415-1-zenghongling@kylinos.cn>
On Mon, Jul 06, 2026 at 11:17:21AM +0800, Hongling Zeng wrote:
> sun6i_dma_terminate_all() and sun6i_dma_pause() acquire sdev->lock
> with plain spin_lock() from process context. If a DMA interrupt fires
> on the same CPU while the lock is held, the interrupt handler schedules
> sun6i_dma_tasklet(), which runs in softirq context and attempts to
> acquire the same lock with spin_lock_irq(), causing a deadlock.
>
> Fix by using spin_lock_irq() to disable interrupts while holding
> sdev->lock, consistent with other call sites.
>
> Fixes: ba489fd46ab6 ("dmaengine: sun6i: Add support for Allwinner A31 DMA controller")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> Change in v2:
> -Fix by using spin_lock_irqsave() and spin_unlock_irqrestore() to
> disable interrupts while holding sdev->lock and properly save/restore
> interrupt state.
> ---
> drivers/dma/sun6i-dma.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index a9a254dbf8cb..a6487971ad09 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -891,6 +891,7 @@ static int sun6i_dma_pause(struct dma_chan *chan)
> struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device);
> struct sun6i_vchan *vchan = to_sun6i_vchan(chan);
> struct sun6i_pchan *pchan = vchan->phy;
> + unsigned long flags;
>
> dev_dbg(chan2dev(chan), "vchan %p: pause\n", &vchan->vc);
>
> @@ -898,9 +899,9 @@ static int sun6i_dma_pause(struct dma_chan *chan)
> writel(DMA_CHAN_PAUSE_PAUSE,
> pchan->base + DMA_CHAN_PAUSE);
> } else {
> - spin_lock(&sdev->lock);
> + spin_lock_irqsave(&sdev->lock, flags);
> list_del_init(&vchan->node);
> - spin_unlock(&sdev->lock);
> + spin_unlock_irqrestore(&sdev->lock, flags);
> }
>
> return 0;
> @@ -939,9 +940,9 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan)
> unsigned long flags;
> LIST_HEAD(head);
>
> - spin_lock(&sdev->lock);
> + spin_lock_irqsave(&sdev->lock, flags);
> list_del_init(&vchan->node);
> - spin_unlock(&sdev->lock);
> + spin_unlock_irqrestore(&sdev->lock, flags);
>
> spin_lock_irqsave(&vchan->vc.lock, flags);
>
> --
> 2.25.1
>
next prev parent reply other threads:[~2026-10-16 15:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 3:17 Hongling Zeng
2026-10-16 15:39 ` Frank Li [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-07-06 3:03 Hongling Zeng
2023-07-26 5:17 [PATCH v2] dmaengine: sun6i: Fix potential deadlock on &sdev->lock Chengfeng Ye
2023-08-16 17:13 ` Chengfeng Ye
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=atJFKnNXdtFjTsQ9@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=arnd@arndb.de \
--cc=dmaengine@vger.kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mripard@kernel.org \
--cc=samuel@sholland.org \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=wens@kernel.org \
--cc=zenghongling@kylinos.cn \
--cc=zhongling0719@126.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®