Skip to content

Commit 74cb7e0

Browse files
SherrySun5gregkh
authored andcommitted
tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled
If the remote uart device is not connected or not enabled after booting up, the CTS line is high by default. At this time, if we enable the flow control when opening the device(for example, using “stty -F /dev/ttyLP4 crtscts” command), there will be a pending idle preamble(first writing 0 and then writing 1 to UARTCTRL_TE will queue an idle preamble) that cannot be sent out, resulting in the uart port fail to close(waiting for TX empty), so the user space stty will have to wait for a long time or forever. This is an LPUART IP bug(idle preamble has higher priority than CTS), here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE, so that the idle preamble does not get stuck due to CTS is deasserted. Fixes: 380c966 ("tty: serial: fsl_lpuart: add 32-bit register interface support") Cc: stable <stable@kernel.org> Signed-off-by: Sherry Sun <sherry.sun@nxp.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Link: https://lore.kernel.org/r/20240305015706.1050769-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1581daf commit 74cb7e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,9 +2345,12 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
23452345

23462346
lpuart32_write(&sport->port, bd, UARTBAUD);
23472347
lpuart32_serial_setbrg(sport, baud);
2348-
lpuart32_write(&sport->port, modem, UARTMODIR);
2349-
lpuart32_write(&sport->port, ctrl, UARTCTRL);
2348+
/* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */
2349+
lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
23502350
/* restore control register */
2351+
lpuart32_write(&sport->port, ctrl, UARTCTRL);
2352+
/* re-enable the CTS if needed */
2353+
lpuart32_write(&sport->port, modem, UARTMODIR);
23512354

23522355
if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE)
23532356
sport->is_cs7 = true;

0 commit comments

Comments
 (0)