mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
serial: 8250: Check LSR timeout on console flow control
wait_for_xmitr() calls wait_for_lsr() to wait for the transmission registers to be empty. wait_for_lsr() can timeout after a reasonable amount of time. When console flow control is active, wait_for_xmitr() additionally polls CTS, waiting for the peer to signal that it is ready to receive more data. If hardware flow control is enabled (auto CTS) and the peer deasserts CTS, wait_for_lsr() will timeout. If additionally console flow control is active and while polling CTS the peer asserts CTS, the console will assume it can immediately transmit, even though the transmission registers may not be empty. This can lead to data loss. Avoid this problem by performing an extra wait_for_lsr() upon CTS assertion if wait_for_lsr() previously timed out. Signed-off-by: John Ogness <john.ogness@linutronix.de> Link: https://patch.msgid.link/20260511152706.151498-3-john.ogness@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f69ec49224
commit
39d307074f
@@ -1986,16 +1986,20 @@ static bool wait_for_lsr(struct uart_8250_port *up, int bits)
|
||||
static void wait_for_xmitr(struct uart_8250_port *up, int bits)
|
||||
{
|
||||
unsigned int tmout;
|
||||
bool tx_ready;
|
||||
|
||||
wait_for_lsr(up, bits);
|
||||
tx_ready = wait_for_lsr(up, bits);
|
||||
|
||||
/* Wait up to 1s for flow control if necessary */
|
||||
if (uart_cons_flow_enabled(&up->port)) {
|
||||
for (tmout = 1000000; tmout; tmout--) {
|
||||
unsigned int msr = serial_in(up, UART_MSR);
|
||||
up->msr_saved_flags |= msr & MSR_SAVE_FLAGS;
|
||||
if (msr & UART_MSR_CTS)
|
||||
if (msr & UART_MSR_CTS) {
|
||||
if (!tx_ready)
|
||||
wait_for_lsr(up, bits);
|
||||
break;
|
||||
}
|
||||
udelay(1);
|
||||
touch_nmi_watchdog();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user