Commit eb56b7ed authored by Huang Shijie's avatar Huang Shijie Committed by Greg Kroah-Hartman

serial: imx: implement the flush_buffer hook

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: default avatarHuang Shijie <b32955@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fa2b5ea0
...@@ -1303,6 +1303,16 @@ static void imx_shutdown(struct uart_port *port) ...@@ -1303,6 +1303,16 @@ static void imx_shutdown(struct uart_port *port)
clk_disable_unprepare(sport->clk_ipg); clk_disable_unprepare(sport->clk_ipg);
} }
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 static void
imx_set_termios(struct uart_port *port, struct ktermios *termios, imx_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old) struct ktermios *old)
...@@ -1623,6 +1633,7 @@ static struct uart_ops imx_pops = { ...@@ -1623,6 +1633,7 @@ static struct uart_ops imx_pops = {
.break_ctl = imx_break_ctl, .break_ctl = imx_break_ctl,
.startup = imx_startup, .startup = imx_startup,
.shutdown = imx_shutdown, .shutdown = imx_shutdown,
.flush_buffer = imx_flush_buffer,
.set_termios = imx_set_termios, .set_termios = imx_set_termios,
.type = imx_type, .type = imx_type,
.release_port = imx_release_port, .release_port = imx_release_port,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment