From d657e72adc37792f4c1b8b050c6b6ca572aa311c Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Mon, 8 Dec 2014 17:30:40 +0800 Subject: [PATCH] MLK-9768: dma: imx-sdma: fix UART loopback random failed 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 --- drivers/dma/imx-sdma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 5f97c964efa9..36c0b9294a60 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1358,7 +1358,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_tail) * sdmac->period_len; else residue = sdmac->chn_count - sdmac->chn_real_count; -- 2.39.2