Commit 24b98e86 authored by Peng Zhang's avatar Peng Zhang Committed by Greg Kroah-Hartman
Browse files

serial: 8250: always disable IRQ during THRE test



commit 039d4926 ("serial: 8250: Toggle IER bits on only after irq
has been set up") moved IRQ setup before the THRE test, in combination
with commit 205d300a ("serial: 8250: change lock order in
serial8250_do_startup()") the interrupt handler can run during the
test and race with its IIR reads. This can produce wrong THRE test
results and cause spurious registration of the
serial8250_backup_timeout timer. Unconditionally disable the IRQ for
the short duration of the test and re-enable it afterwards to avoid
the race.

Fixes: 039d4926 ("serial: 8250: Toggle IER bits on only after irq has been set up")
Depends-on: 205d300a ("serial: 8250: change lock order in serial8250_do_startup()")
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarPeng Zhang <zhangpeng.00@bytedance.com>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarAlban Bedel <alban.bedel@lht.dlh.de>
Tested-by: default avatarMaximilian Lueer <maximilian.lueer@lht.dlh.de>
Link: https://patch.msgid.link/20260224121639.579404-1-alban.bedel@lht.dlh.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a424a34b
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -2147,8 +2147,7 @@ static void serial8250_THRE_test(struct uart_port *port)
	if (up->port.flags & UPF_NO_THRE_TEST)
		return;

	if (port->irqflags & IRQF_SHARED)
		disable_irq_nosync(port->irq);
	disable_irq(port->irq);

	/*
	 * Test for UARTs that do not reassert THRE when the transmitter is idle and the interrupt
@@ -2170,7 +2169,6 @@ static void serial8250_THRE_test(struct uart_port *port)
		serial_port_out(port, UART_IER, 0);
	}

	if (port->irqflags & IRQF_SHARED)
	enable_irq(port->irq);

	/*