diff options
Diffstat (limited to 'queue-4.19/tty-serial-fsl_lpuart-avoid-idle-preamble-pending-if-cts-is-enabled.patch')
-rw-r--r-- | queue-4.19/tty-serial-fsl_lpuart-avoid-idle-preamble-pending-if-cts-is-enabled.patch | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/queue-4.19/tty-serial-fsl_lpuart-avoid-idle-preamble-pending-if-cts-is-enabled.patch b/queue-4.19/tty-serial-fsl_lpuart-avoid-idle-preamble-pending-if-cts-is-enabled.patch new file mode 100644 index 0000000000..3980791f9b --- /dev/null +++ b/queue-4.19/tty-serial-fsl_lpuart-avoid-idle-preamble-pending-if-cts-is-enabled.patch @@ -0,0 +1,52 @@ +From 74cb7e0355fae9641f825afa389d3fba3b617714 Mon Sep 17 00:00:00 2001 +From: Sherry Sun <sherry.sun@nxp.com> +Date: Tue, 5 Mar 2024 09:57:06 +0800 +Subject: tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Sherry Sun <sherry.sun@nxp.com> + +commit 74cb7e0355fae9641f825afa389d3fba3b617714 upstream. + +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: 380c966c093e ("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> +--- + drivers/tty/serial/fsl_lpuart.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/tty/serial/fsl_lpuart.c ++++ b/drivers/tty/serial/fsl_lpuart.c +@@ -1753,9 +1753,12 @@ lpuart32_set_termios(struct uart_port *p + UARTCTRL); + + lpuart32_serial_setbrg(sport, baud); +- lpuart32_write(&sport->port, modem, UARTMODIR); +- lpuart32_write(&sport->port, ctrl, UARTCTRL); ++ /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ ++ lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); + /* restore control register */ ++ lpuart32_write(&sport->port, ctrl, UARTCTRL); ++ /* re-enable the CTS if needed */ ++ lpuart32_write(&sport->port, modem, UARTMODIR); + + spin_unlock_irqrestore(&sport->port.lock, flags); + } |