serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 1 Sep 2022 14:39:33 +0000 (17:39 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 08:55:46 +0000 (10:55 +0200)
commit 754f68044c7dd6c52534ba3e0f664830285c4b15 upstream.

DMA complete & stop paths did not correctly account Tx'ed characters
into icount.tx. Using uart_xmit_advance() fixes the problem.

Fixes: e9ea096dd225 ("serial: tegra: add serial driver")
Cc: <stable@vger.kernel.org> # serial: Create uart_xmit_advance()
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220901143934.8850-3-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial-tegra.c

index 731ac35acb3125a2dcee3a6dbeaee93fb2963de2..1896e0d9a64b484abac4d1dbbe253a4d92b1be71 100644 (file)
@@ -409,7 +409,7 @@ static void tegra_uart_tx_dma_complete(void *args)
        count = tup->tx_bytes_requested - state.residue;
        async_tx_ack(tup->tx_dma_desc);
        spin_lock_irqsave(&tup->uport.lock, flags);
-       xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1);
+       uart_xmit_advance(&tup->uport, count);
        tup->tx_in_progress = 0;
        if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
                uart_write_wakeup(&tup->uport);
@@ -493,7 +493,6 @@ static unsigned int tegra_uart_tx_empty(struct uart_port *u)
 static void tegra_uart_stop_tx(struct uart_port *u)
 {
        struct tegra_uart_port *tup = to_tegra_uport(u);
-       struct circ_buf *xmit = &tup->uport.state->xmit;
        struct dma_tx_state state;
        unsigned int count;
 
@@ -504,7 +503,7 @@ static void tegra_uart_stop_tx(struct uart_port *u)
        dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state);
        count = tup->tx_bytes_requested - state.residue;
        async_tx_ack(tup->tx_dma_desc);
-       xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1);
+       uart_xmit_advance(&tup->uport, count);
        tup->tx_in_progress = 0;
 }