serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
Subsystems (4)
v2 cover serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
Add uart_xmit_advance() helper to handle circular xmit buffer advancement + accounting of Tx'ed bytes. Use it to fix a few drivers that previously lacked to accounting for DMA Tx.
v2:
- Correct tags
Ilpo Järvinen (3):
serial: Create uart_xmit_advance()
serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting
serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
drivers/tty/serial/serial-tegra.c | 5 ++--- drivers/tty/serial/tegra-tcu.c | 2 +- include/linux/serial_core.h | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-)
Signature · 1 line
2.30.2
PATCH RESEND v2 1/3 serial: Create uart_xmit_advance()
A very common pattern in the drivers is to advance xmit tail index and do bookkeeping of Tx'ed characters. Create uart_xmit_advance() to handle it.
--- include/linux/serial_core.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/linux/serial_core.h +17 -0
@@ -616,6 +616,23 @@ struct uart_state {/* number of characters left in xmit buffer before we ask for more */ #define WAKEUP_CHARS 256 +/** +* uart_xmit_advance - Advance xmit buffer and account Tx'ed chars +* @up: uart_port structure describing the port +* @chars: number of characters sent +* +* This function advances the tail of circular xmit buffer by the number of +* @chars transmitted and handles accounting of transmitted bytes (into +* @up's icount.tx). +*/ +static inline void uart_xmit_advance (struct uart_port *up,unsigned int chars) +{ +struct circ_buf *xmit = &up->state->xmit; + + xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE -1 ); + up->icount.tx += chars; +} +struct module ;struct tty_driver ;
Signature · 1 line
2.30.2
PATCH RESEND v2 2/3 serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting
In reply to Ilpo JärvinenDMA complete & stop paths did not correctly account Tx'ed characters into icount.tx. Using uart_xmit_advance() fixes the problem.
--- drivers/tty/serial/serial-tegra.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/serial-tegra.c +2 -3
@@ -525,7 +525,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);
@@ -613,7 +613,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;
@@ -624,7 +623,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 ; }
Signature · 1 line
2.30.2
PATCH RESEND v2 3/3 serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
In reply to Ilpo JärvinenTx'ing does not correctly account Tx'ed characters into icount.tx. Using uart_xmit_advance() fixes the problem.
--- drivers/tty/serial/tegra-tcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/tegra-tcu.c +1 -1
@@ -101,7 +101,7 @@ static void tegra_tcu_uart_start_tx(struct uart_port *port)break ;tegra_tcu_write (tcu, &xmit->buf[xmit->tail], count); - xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE -1 ); +uart_xmit_advance (port, count); }uart_write_wakeup (port);
Signature · 1 line
2.30.2
Re: [PATCH v2 RESEND 3/3] serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
Quoted 10 lines · Ilpo Järvinen
Tx'ing does not correctly account Tx'ed characters into icount.tx. Using
uart_xmit_advance()fixes the problem.Cc <[email protected]> # serial: Create uart_xmit_advance()Fixes 2d908b38d409 ("serial: Add Tegra Combined UART driver")Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Ilpo Järvinen <[email protected]>--- drivers/tty/serial/tegra-tcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Difficult to review without a copy of the first patch in my inbox. I was able to find it on lore, though and this does seem to do the right thing, so: