Page MenuHomeFreeBSD

D56096.diff
No OneTemporary

D56096.diff

diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c
--- a/sys/dev/uart/uart_dev_ns8250.c
+++ b/sys/dev/uart/uart_dev_ns8250.c
@@ -228,21 +228,12 @@
delay = ns8250_delay(bas);
- if (what & UART_DRAIN_TRANSMITTER) {
- /*
- * Pick an arbitrary high limit to avoid getting stuck in
- * an infinite loop when the hardware is broken. Make the
- * limit high enough to handle large FIFOs.
- */
- limit = 10*1024;
- while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit)
- DELAY(delay);
- if (limit == 0) {
- /* printf("uart: ns8250: transmitter appears stuck... "); */
- return (EIO);
- }
- }
-
+ /*
+ * Some UARTs (seen on Alder Lake AMT SOL Redirection device) get stuck
+ * when probing for the FIFO queue length in ns8250_bus_probe(), and
+ * the only way to unlock them is to drain the RX queue first.
+ * Otherwise the device never sets TEMT in LSR.
+ */
if (what & UART_DRAIN_RECEIVER) {
/*
* Pick an arbitrary high limit to avoid getting stuck in
@@ -271,6 +262,21 @@
}
}
+ if (what & UART_DRAIN_TRANSMITTER) {
+ /*
+ * Pick an arbitrary high limit to avoid getting stuck in
+ * an infinite loop when the hardware is broken. Make the
+ * limit high enough to handle large FIFOs.
+ */
+ limit = 10*1024;
+ while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit)
+ DELAY(delay);
+ if (limit == 0) {
+ /* printf("uart: ns8250: transmitter appears stuck... "); */
+ return (EIO);
+ }
+ }
+
return (0);
}
@@ -1008,10 +1014,11 @@
uart_setreg(bas, REG_MCR, mcr);
- /* Reset FIFOs. */
+ describe:
+ /* Reset FIFOs & drain. */
ns8250_flush(bas, UART_FLUSH_RECEIVER|UART_FLUSH_TRANSMITTER);
+ ns8250_drain(bas, UART_DRAIN_RECEIVER|UART_DRAIN_TRANSMITTER);
- describe:
if (count >= 14 && count <= 16) {
sc->sc_rxfifosz = 16;
device_set_desc(sc->sc_dev, "16550 or compatible");

File Metadata

Mime Type
text/plain
Expires
Fri, Aug 28, 10:10 AM (3 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37275997
Default Alt Text
D56096.diff (1 KB)

Event Timeline