ns8250: use LSR_THRE instead of LSR_TEMT for checking tx flush

LSR_TEMT bit is set if both transmit hold and shift registers are
empty, but the flush command flushes only the hold register.

While here, update the diagnostic message to report which registers
could not be flushed.

MFC after:	2 weeks
This commit is contained in:
Andriy Gapon 2024-11-10 13:15:30 +02:00
parent 964b0ece79
commit 0d2fd5b99c

View file

@ -265,12 +265,12 @@ ns8250_flush(struct uart_bas *bas, int what)
* https://github.com/rust-vmm/vm-superio/issues/83
*/
lsr = uart_getreg(bas, REG_LSR);
if (((lsr & LSR_TEMT) == 0) && (what & UART_FLUSH_TRANSMITTER))
if (((lsr & LSR_THRE) == 0) && (what & UART_FLUSH_TRANSMITTER))
drain |= UART_DRAIN_TRANSMITTER;
if ((lsr & LSR_RXRDY) && (what & UART_FLUSH_RECEIVER))
drain |= UART_DRAIN_RECEIVER;
if (drain != 0) {
printf("uart: ns8250: UART FCR is broken\n");
printf("uart: ns8250: UART FCR is broken (%#x)\n", drain);
ns8250_drain(bas, drain);
}
}