Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: qcom-geni: fix false console tx restart

Commit 663abb1a7a7f ("tty: serial: qcom_geni_serial: Fix UART hang")
addressed an issue with stalled tx after the console code interrupted
the last bytes of a tx command by reenabling the watermark interrupt if
there is data in write buffer. This can however break software flow
control by re-enabling tx after the user has stopped it.

Address the original issue by not clearing the CMD_DONE flag after
polling for command completion. This allows the interrupt handler to
start another transfer when the CMD_DONE interrupt has not been disabled
due to flow control.

Fixes: c4f528795d1a ("tty: serial: msm_geni_serial: Add serial driver support for GENI based QUP")
Fixes: 663abb1a7a7f ("tty: serial: qcom_geni_serial: Fix UART hang")
Cc: stable@vger.kernel.org # 4.17
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20240906131336.23625-3-johan+linaro@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
f97cdbbf c80ee36a

+3 -10
+3 -10
drivers/tty/serial/qcom_geni_serial.c
··· 306 306 static void qcom_geni_serial_poll_tx_done(struct uart_port *uport) 307 307 { 308 308 int done; 309 - u32 irq_clear = M_CMD_DONE_EN; 310 309 311 310 done = qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, 312 311 M_CMD_DONE_EN, true); 313 312 if (!done) { 314 313 writel(M_GENI_CMD_ABORT, uport->membase + 315 314 SE_GENI_M_CMD_CTRL_REG); 316 - irq_clear |= M_CMD_ABORT_EN; 317 315 qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, 318 316 M_CMD_ABORT_EN, true); 317 + writel(M_CMD_ABORT_EN, uport->membase + SE_GENI_M_IRQ_CLEAR); 319 318 } 320 - writel(irq_clear, uport->membase + SE_GENI_M_IRQ_CLEAR); 321 319 } 322 320 323 321 static void qcom_geni_serial_abort_rx(struct uart_port *uport) ··· 376 378 unsigned char c) 377 379 { 378 380 writel(DEF_TX_WM, uport->membase + SE_GENI_TX_WATERMARK_REG); 381 + writel(M_CMD_DONE_EN, uport->membase + SE_GENI_M_IRQ_CLEAR); 379 382 qcom_geni_serial_setup_tx(uport, 1); 380 383 WARN_ON(!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, 381 384 M_TX_FIFO_WATERMARK_EN, true)); ··· 421 422 } 422 423 423 424 writel(DEF_TX_WM, uport->membase + SE_GENI_TX_WATERMARK_REG); 425 + writel(M_CMD_DONE_EN, uport->membase + SE_GENI_M_IRQ_CLEAR); 424 426 qcom_geni_serial_setup_tx(uport, bytes_to_send); 425 427 for (i = 0; i < count; ) { 426 428 size_t chars_to_write = 0; ··· 463 463 bool locked = true; 464 464 unsigned long flags; 465 465 u32 geni_status; 466 - u32 irq_en; 467 466 468 467 WARN_ON(co->index < 0 || co->index >= GENI_UART_CONS_PORTS); 469 468 ··· 494 495 * has been sent, in which case we need to look for done first. 495 496 */ 496 497 qcom_geni_serial_poll_tx_done(uport); 497 - 498 - if (!kfifo_is_empty(&uport->state->port.xmit_fifo)) { 499 - irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 500 - writel(irq_en | M_TX_FIFO_WATERMARK_EN, 501 - uport->membase + SE_GENI_M_IRQ_EN); 502 - } 503 498 } 504 499 505 500 __qcom_geni_serial_console_write(uport, s, count);