mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugen Hristev <eugen.hristev@collabora.com>
To: Duoming Zhou <duoming@zju.edu.cn>, sean.wang@mediatek.com
Cc: vkoul@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: mediatek: Fix deadlock caused by synchronize_irq()
Date: Tue, 8 Aug 2023 14:45:01 +0300	[thread overview]
Message-ID: <da5d1a11-93d4-3952-9a2b-8313b9206660@collabora.com> (raw)
In-Reply-To: <20230806032511.45263-1-duoming@zju.edu.cn>

On 8/6/23 06:25, Duoming Zhou wrote:
> The synchronize_irq(c->irq) will not return until the IRQ handler
> mtk_uart_apdma_irq_handler() is completed. If the synchronize_irq()
> holds a spin_lock and waits the IRQ handler to complete, but the
> IRQ handler also needs the same spin_lock. The deadlock will happen.
> The process is shown below:
> 
>            cpu0                        cpu1
> mtk_uart_apdma_device_pause() | mtk_uart_apdma_irq_handler()
>    spin_lock_irqsave()         |
>                                |   spin_lock_irqsave()
>    //hold the lock to wait     |
>    synchronize_irq()           |
> 
> This patch reorders the synchronize_irq(c->irq) outside the spin_lock
> in order to mitigate the bug.
> 
> Fixes: 9135408c3ace ("dmaengine: mediatek: Add MediaTek UART APDMA support")
> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
> ---
>   drivers/dma/mediatek/mtk-uart-apdma.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
> index a1517ef1f4a..0acf6a92a4a 100644
> --- a/drivers/dma/mediatek/mtk-uart-apdma.c
> +++ b/drivers/dma/mediatek/mtk-uart-apdma.c
> @@ -451,9 +451,8 @@ static int mtk_uart_apdma_device_pause(struct dma_chan *chan)
>   	mtk_uart_apdma_write(c, VFF_EN, VFF_EN_CLR_B);
>   	mtk_uart_apdma_write(c, VFF_INT_EN, VFF_INT_EN_CLR_B);
>   
> -	synchronize_irq(c->irq);
> -
>   	spin_unlock_irqrestore(&c->vc.lock, flags);
> +	synchronize_irq(c->irq);
>   
>   	return 0;
>   }


Reviewed-by: Eugen Hristev <eugen.hristev@collabora.com>

  reply	other threads:[~2023-08-08 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-06  3:25 Duoming Zhou
2023-08-08 11:45 ` Eugen Hristev [this message]
2023-10-04 14:18 ` Vinod Koul

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=da5d1a11-93d4-3952-9a2b-8313b9206660@collabora.com \
    --to=eugen.hristev@collabora.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=duoming@zju.edu.cn \
    --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 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®