From: Fugang Duan Date: Tue, 17 Aug 2021 10:02:03 +0000 (+0800) Subject: tty: serial: fsl_lpuart: check dma_tx_in_progress in tx dma callback X-Git-Tag: v5.15-rc1~153^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88c1d2478ec8a420cf60a3c25503e37b34fea5aa;p=thirdparty%2Flinux.git tty: serial: fsl_lpuart: check dma_tx_in_progress in tx dma callback There have a corner case that tx DMA .callback() is coming after .flush_buffer(), then .callback() should check dma_tx_in_progress flag and return in directly. Signed-off-by: Fugang Duan Signed-off-by: Vipul Kumar Signed-off-by: Sherry Sun Link: https://lore.kernel.org/r/20210817100203.21300-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index f0e5da77ed6d4..31d715c4787a3 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -479,6 +479,10 @@ static void lpuart_dma_tx_complete(void *arg) unsigned long flags; spin_lock_irqsave(&sport->port.lock, flags); + if (!sport->dma_tx_in_progress) { + spin_unlock_irqrestore(&sport->port.lock, flags); + return; + } dma_unmap_sg(chan->device->dev, sgl, sport->dma_tx_nents, DMA_TO_DEVICE);