Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106334575
D36979.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D36979.diff
View Options
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
@@ -210,6 +210,8 @@
ns8250_flush(struct uart_bas *bas, int what)
{
uint8_t fcr;
+ uint8_t lsr;
+ int drain = 0;
fcr = FCR_ENABLE;
#ifdef CPU_XBURST
@@ -221,6 +223,23 @@
fcr |= FCR_RCV_RST;
uart_setreg(bas, REG_FCR, fcr);
uart_barrier(bas);
+
+ /*
+ * Detect and work around emulated UARTs which don't implement the
+ * FCR register; on these systems we need to drain the FIFO since
+ * the flush we request doesn't happen. One such system is the
+ * Firecracker VMM, aka. the rust-vmm/vm-superio emulation code:
+ * https://github.com/rust-vmm/vm-superio/issues/83
+ */
+ lsr = uart_getreg(bas, REG_LSR);
+ if ((lsr & LSR_TEMT) && (what & UART_FLUSH_TRANSMITTER))
+ drain |= UART_DRAIN_TRANSMITTER;
+ if ((lsr & LSR_RXRDY) && (what & UART_FLUSH_RECEIVER))
+ drain |= UART_DRAIN_RECEIVER;
+ if (drain != 0) {
+ printf("ns8250: UART FCR is broken\n");
+ ns8250_drain(bas, drain);
+ }
}
static int
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 29, 9:30 PM (8 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15633253
Default Alt Text
D36979.diff (1 KB)
Attached To
Mode
D36979: ns8250: Check if flush via FCR succeeded
Attached
Detach File
Event Timeline
Log In to Comment