]> www.infradead.org Git - users/jedix/linux-maple.git/commit
serial: imx: ensure RTS signal is not left active after shutdown
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Tue, 25 Jun 2024 18:42:05 +0000 (20:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jul 2024 14:12:49 +0000 (16:12 +0200)
commit1af2156e58f3af1216ce2f0456b3b8949faa5c7e
tree2e44e94d244685254e73b0c90c234a14b8ef9f8b
parentacd09ac253b5de8fd79fc61a482ee19154914c7a
serial: imx: ensure RTS signal is not left active after shutdown

If a process is killed while writing to a /dev/ttymxc* device in RS485
mode, we observe that the RTS signal is left high, thus making it
impossible for other devices to transmit anything.

Moreover, the ->tx_state variable is left in state SEND, which means
that when one next opens the device and configures baud rate etc., the
initialization code in imx_uart_set_termios dutifully ensures the RTS
pin is pulled down, but since ->tx_state is already SEND, the logic in
imx_uart_start_tx() does not in fact pull the pin high before
transmitting, so nothing actually gets on the wire on the other side
of the transceiver. Only when that transmission is allowed to complete
is the state machine then back in a consistent state.

This is completely reproducible by doing something as simple as

  seq 10000 > /dev/ttymxc0

and hitting ctrl-C, and watching with a logic analyzer.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: stable <stable@kernel.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20240625184206.508837-1-linux@rasmusvillemoes.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c