MLK-9768: dma: imx-sdma: fix UART loopback random failed
authorRobin Gong <b38343@freescale.com>
Mon, 8 Dec 2014 09:30:40 +0000 (17:30 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:24 +0000 (14:47 -0500)
For UART, we need use old chn_real_count to know the real rx count even in
cylic dma mode, because UART driver use cyclic mode to increase performance
without any data loss.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 398cee2ad110c4f183e553af0564fbdcbe8548cb)

drivers/dma/imx-sdma.c

index 09eba80..810ea3a 100644 (file)
@@ -1398,7 +1398,12 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan,
        struct sdma_channel *sdmac = to_sdma_chan(chan);
        u32 residue;
 
-       if (sdmac->flags & IMX_DMA_SG_LOOP)
+       /*
+        * For uart rx data may not receive fully, use old chn_real_count to
+        * know the real rx count.
+        */
+       if ((sdmac->flags & IMX_DMA_SG_LOOP) &&
+           sdmac->peripheral_type != IMX_DMATYPE_UART)
                residue = (sdmac->num_bd - sdmac->buf_ptail) *
                           sdmac->period_len - sdmac->chn_real_count;
        else