[1/6] serial: 8250: 8250_omap: Terminate DMA before pushing data on RX timeout
diff mbox series

Message ID 20200319110344.21348-2-vigneshr@ti.com
State New
Headers show
  • 8250_omap: Add DMA for AM654/J721e type UARTs
Related show

Commit Message

Vignesh Raghavendra March 19, 2020, 11:03 a.m. UTC
Terminate and flush DMA internal buffers, before pushing RX data to
higher layer. Otherwise, this will lead to data corruption, as driver
would end up pushing stale buffer data to higher layer while actual data
is still stuck inside DMA hardware and has yet not arrived at the
While at that, replace deprecated dmaengine_terminate_all() with

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
 drivers/tty/serial/8250/8250_omap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff mbox series

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index f04139923da0..65b6d165df67 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -755,7 +755,10 @@  static void __dma_rx_do_complete(struct uart_8250_port *p)
 	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
 	count = dma->rx_size - state.residue;
+	if (count < dma->rx_size)
+		dmaengine_terminate_async(dma->rxchan);
+	if (!count)
+		goto unlock;
 	ret = tty_insert_flip_string(tty_port, dma->rx_buf, count);
 	p->port.icount.rx += ret;
@@ -817,7 +820,6 @@  static void omap_8250_rx_dma_flush(struct uart_8250_port *p)
 	spin_unlock_irqrestore(&priv->rx_dma_lock, flags);
-	dmaengine_terminate_all(dma->rxchan);
 static int omap_8250_rx_dma(struct uart_8250_port *p)