Skip to content

Commit 8d5cfb1

Browse files
jognessgregkh
authored andcommitted
serial: 8250: Use frame time to determine timeout
Rather than using a hard-coded per-character Tx-timeout of 10ms, use the frame time to determine a timeout value. The value is doubled to ensure that a timeout is only hit during unexpected circumstances. Since the frame time may not be available during early printing, the previous 10ms value is kept as a fallback. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d91f98b commit 8d5cfb1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/tty/serial/8250/8250_port.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,9 +2081,17 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state)
20812081
/* Returns true if @bits were set, false on timeout */
20822082
static bool wait_for_lsr(struct uart_8250_port *up, int bits)
20832083
{
2084-
unsigned int status, tmout = 10000;
2084+
unsigned int status, tmout;
2085+
2086+
/*
2087+
* Wait for a character to be sent. Fallback to a safe default
2088+
* timeout value if @frame_time is not available.
2089+
*/
2090+
if (up->port.frame_time)
2091+
tmout = up->port.frame_time * 2 / NSEC_PER_USEC;
2092+
else
2093+
tmout = 10000;
20852094

2086-
/* Wait up to 10ms for the character(s) to be sent. */
20872095
for (;;) {
20882096
status = serial_lsr_in(up);
20892097

0 commit comments

Comments
 (0)