]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
serial: imx: implement the flush_buffer hook
authorHuang Shijie <b32955@freescale.com>
Wed, 9 Oct 2013 07:13:23 +0000 (15:13 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 20 Aug 2014 08:06:34 +0000 (10:06 +0200)
The current driver does not implement the flush_buffer hook for
uart_ops. When we enable the DMA for the driver, and test it with Bluetooth,
we may meet the following bug for TX:

    [1] User application may call the flush operation at any time.
        The uart_flush_buffer() calls the uart_circ_clear() to set
        the xmit->head and xmit->tail with 0.

    [2] The TX DMA callback can be called at any time too.
        The dma_tx_call() will update the xmit->tail.

    If [2] occurs just after the [1], we will get the wrong xmit->tail.

This patch implements the flush_buffer hook to fix this issue.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index d9527a2326d7a784d68010bb261fa35158569293..83fc81af214f2a40ea69a8133d5f62938c99a1b9 100644 (file)
@@ -1291,6 +1291,16 @@ static void imx_flush_buffer(struct uart_port *port)
        }
 }
 
+static void imx_flush_buffer(struct uart_port *port)
+{
+       struct imx_port *sport = (struct imx_port *)port;
+
+       if (sport->dma_is_enabled) {
+               sport->tx_bytes = 0;
+               dmaengine_terminate_all(sport->dma_chan_tx);
+       }
+}
+
 static void
 imx_set_termios(struct uart_port *port, struct ktermios *termios,
                   struct ktermios *old)