renesas-drivers-2017-03-21-v4.11-rc3 based on renesas-devel-20170321-v4.11-rc3
serial: sh-sci: Fix hang in sci_reset()
When the .set_termios() callback resets the UART, it first waits until
all characters in the transmit FIFO have been transmitted, to prevent a
port configuration change from impacting these characters.
However, if the previous user of the UART had dedicated RTS/CTS hardware
flow control enabled, these characters may have been stuck in the FIFO
due to CTS not being asserted. When the new user opens the port,
.set_termios() is called while transmission is still disabled, leading
to an infinite loop:
NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s!
This has been observed with SCIFA (on r8a7740/armadillo) and SCIFB (on
r8a7791/koelsch).
The issue does not seem to happen when using:
- GPIO RTS/CTS hardware flow control,
- No hardware flow control,
- HSCIF (on r8a7791/koelsch).
To fix this, wait for the draining of the transmit FIFO only if
transmission is already enabled.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
To reproduce:
stty -echo < /dev/scifb0
stty crtscts < /dev/scifb0
echo hello > /dev/scifb0 # returns early (wrote to FIFO)
echo hello > /dev/scifb0 # hangs
1 file changed