MLK-11344-5: dmaengine: imx: fix loop mode issue
authorFugang Duan <b38611@freescale.com>
Fri, 10 Oct 2014 07:31:11 +0000 (15:31 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:24 +0000 (14:47 -0500)
cherry-pick below patch from v3.14.y:

ENGR00329822-01 dmaengine: imx: fix loop mode issue

Fix loop mode issue that calling dmaengine_tx_status() can get
right state.residue value.

Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 37e17f10b35c34317def08704e4b4edf5aa23894)
(cherry picked from commit 00cc7021317ac6efb460eb1b9bc3bd8aa6ad73c2)

drivers/dma/imx-sdma.c

index d1651a5..09eba80 100644 (file)
@@ -714,6 +714,12 @@ static void sdma_update_channel_loop(struct sdma_channel *sdmac)
 
                dmaengine_desc_get_callback_invoke(&sdmac->desc, NULL);
 
+               if (sdmac->peripheral_type == IMX_DMATYPE_UART) {
+                       /* restore mode.count after counter readed */
+                       sdmac->chn_real_count = bd->mode.count;
+                       bd->mode.count = sdmac->chn_count;
+               }
+
                if (error)
                        sdmac->status = old_status;
        }
@@ -1313,6 +1319,9 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic(
                goto err_out;
        }
 
+       if (sdmac->peripheral_type == IMX_DMATYPE_UART)
+               sdmac->chn_count = period_len;
+
        while (buf < buf_len) {
                struct sdma_buffer_descriptor *bd = &sdmac->bd[i];
                int param;