serial: imx: start rx_dma once RXFIFO is not empty
authorRobin Gong <b38343@freescale.com>
Tue, 9 Dec 2014 09:11:33 +0000 (18:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jan 2015 22:23:59 +0000 (14:23 -0800)
Start rx_dma once RXFIFO is not empty that can avoid dma request lost
and causes data delay issue.

Signed-off-by: Robin Gong <b38343@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index ab958a59cae99f73a2d7b282650a38522403f896..d61b89e4a96ec465200c8a07b12b0c3914233adf 100644 (file)
@@ -946,8 +946,21 @@ static void dma_rx_callback(void *data)
                tty_flip_buffer_push(port);
 
                start_rx_dma(sport);
-       } else
+       } else if (readl(sport->port.membase + USR2) & USR2_RDR) {
+               /*
+                * start rx_dma directly once data in RXFIFO, more efficient
+                * than before:
+                *      1. call imx_rx_dma_done to stop dma if no data received
+                *      2. wait next  RDR interrupt to start dma transfer.
+                */
+               start_rx_dma(sport);
+       } else {
+               /*
+                * stop dma to prevent too many IDLE event trigged if no data
+                * in RXFIFO
+                */
                imx_rx_dma_done(sport);
+       }
 }
 
 static int start_rx_dma(struct imx_port *sport)