Skip to content

Commit e98ab45

Browse files
SherrySun5gregkh
authored andcommitted
tty: serial: lpuart: only disable CTS instead of overwriting the whole UARTMODIR register
No need to overwrite the whole UARTMODIR register before waiting the transmit engine complete, actually our target here is only to disable CTS flow control to avoid the dirty data in TX FIFO may block the transmit engine complete. Also delete the following duplicate CTS disable configuration. Fixes: d5a2e08 ("tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete") Cc: stable <stable@kernel.org> Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Link: https://lore.kernel.org/r/20250307065446.1122482-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3c3cede commit e98ab45

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,24 +2349,26 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
23492349
/* update the per-port timeout */
23502350
uart_update_timeout(port, termios->c_cflag, baud);
23512351

2352+
/*
2353+
* disable CTS to ensure the transmit engine is not blocked by the flow
2354+
* control when there is dirty data in TX FIFO
2355+
*/
2356+
lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
2357+
23522358
/*
23532359
* LPUART Transmission Complete Flag may never be set while queuing a break
23542360
* character, so skip waiting for transmission complete when UARTCTRL_SBK is
23552361
* asserted.
23562362
*/
2357-
if (!(old_ctrl & UARTCTRL_SBK)) {
2358-
lpuart32_write(port, 0, UARTMODIR);
2363+
if (!(old_ctrl & UARTCTRL_SBK))
23592364
lpuart32_wait_bit_set(port, UARTSTAT, UARTSTAT_TC);
2360-
}
23612365

23622366
/* disable transmit and receive */
23632367
lpuart32_write(port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE),
23642368
UARTCTRL);
23652369

23662370
lpuart32_write(port, bd, UARTBAUD);
23672371
lpuart32_serial_setbrg(sport, baud);
2368-
/* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */
2369-
lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
23702372
/* restore control register */
23712373
lpuart32_write(port, ctrl, UARTCTRL);
23722374
/* re-enable the CTS if needed */

0 commit comments

Comments
 (0)