Skip to content

Commit

Permalink
serial: meson+qcom: don't advance the kfifo twice
Browse files Browse the repository at this point in the history
Marek reports, that the -next commit 1788cf6 (tty: serial: switch
from circ_buf to kfifo) broke meson_uart and qcom_geni_serial. The
commit mistakenly advanced the kfifo twice: once by
uart_fifo_get()/kfifo_out() and second time by uart_xmit_advance().

To advance the fifo only once, drop the superfluous uart_xmit_advance()
from both.

To count the TX statistics properly, use uart_fifo_out() in
qcom_geni_serial (meson_uart_start_tx() already uses that).

I checked all other uses of uart_xmit_advance() and they appear correct:
either they are finishing DMA transfers or are after peek/linear_ptr
(i.e. they do not advance fifo).

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: 1788cf6 ("tty: serial: switch from circ_buf to kfifo")
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20240416054825.6211-1-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jiri Slaby (SUSE) authored and Greg Kroah-Hartman committed Apr 16, 2024
1 parent b20172c commit 35fad98
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion drivers/tty/serial/meson_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ static void meson_uart_start_tx(struct uart_port *port)
break;

writel(ch, port->membase + AML_UART_WFIFO);
uart_xmit_advance(port, 1);
}

if (!kfifo_is_empty(&tport->xmit_fifo)) {
Expand Down
4 changes: 1 addition & 3 deletions drivers/tty/serial/qcom_geni_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,16 +855,14 @@ static void qcom_geni_serial_send_chunk_fifo(struct uart_port *uport,
unsigned int chunk)
{
struct qcom_geni_serial_port *port = to_dev_port(uport);
struct tty_port *tport = &uport->state->port;
unsigned int tx_bytes, remaining = chunk;
u8 buf[BYTES_PER_FIFO_WORD];

while (remaining) {
memset(buf, 0, sizeof(buf));
tx_bytes = min(remaining, BYTES_PER_FIFO_WORD);

tx_bytes = kfifo_out(&tport->xmit_fifo, buf, tx_bytes);
uart_xmit_advance(uport, tx_bytes);
tx_bytes = uart_fifo_out(uport, buf, tx_bytes);

iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1);

Expand Down

0 comments on commit 35fad98

Please sign in to comment.