Commit 0ccad87012c6c2e7446e4dc0f0894cf182a5270a

Authored by Haavard Skinnemoen
Committed by Linus Torvalds
1 parent dc9879291b

atmel_serial: fix hang in set_termios when crtscts is enabled

After enabling hardware flow control, any subsequent termios call may hang
waiting for the transmitter to drain.  This appears to be caused by a
busy-loop in set_termios() waiting for the transmitter to become empty,
which may take a very long time (or hang indefinitely) if the device at
the other end is blocking us.

A quick look through the tty and serial_core code indicates that any
necessary flushing (which is optional) has already been done at this
point, so there's no need for the driver to flush the transmitter on its
own.

Fix it by removing the busy-loop altogether.

Tested-by: Eirik Aanonsen <eaa@wprmedical.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 5 additions and 3 deletions Side-by-side Diff

drivers/serial/atmel_serial.c
... ... @@ -1104,11 +1104,13 @@
1104 1104 /* update the per-port timeout */
1105 1105 uart_update_timeout(port, termios->c_cflag, baud);
1106 1106  
1107   - /* save/disable interrupts and drain transmitter */
  1107 + /*
  1108 + * save/disable interrupts. The tty layer will ensure that the
  1109 + * transmitter is empty if requested by the caller, so there's
  1110 + * no need to wait for it here.
  1111 + */
1108 1112 imr = UART_GET_IMR(port);
1109 1113 UART_PUT_IDR(port, -1);
1110   - while (!(UART_GET_CSR(port) & ATMEL_US_TXEMPTY))
1111   - cpu_relax();
1112 1114  
1113 1115 /* disable receiver and transmitter */
1114 1116 UART_PUT_CR(port, ATMEL_US_TXDIS | ATMEL_US_RXDIS);