[Midnightbsd-cvs] src [8771] trunk/sys/dev/uart/uart_dev_ns8250.c: Add a loader tunable "hw.broken_txfifo" which enables a workaround for a bug in old versions of QEMU

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Sep 25 22:53:07 EDT 2016


Revision: 8771
          http://svnweb.midnightbsd.org/src/?rev=8771
Author:   laffer1
Date:     2016-09-25 22:53:07 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
Add a loader tunable "hw.broken_txfifo" which enables a workaround for a bug in old versions of QEMU

Modified Paths:
--------------
    trunk/sys/dev/uart/uart_dev_ns8250.c

Modified: trunk/sys/dev/uart/uart_dev_ns8250.c
===================================================================
--- trunk/sys/dev/uart/uart_dev_ns8250.c	2016-09-26 02:51:41 UTC (rev 8770)
+++ trunk/sys/dev/uart/uart_dev_ns8250.c	2016-09-26 02:53:07 UTC (rev 8771)
@@ -31,6 +31,8 @@
 #include <sys/systm.h>
 #include <sys/bus.h>
 #include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
 #include <machine/bus.h>
 
 #include <dev/uart/uart.h>
@@ -842,6 +844,11 @@
 	return (0);
 }
 
+static int broken_txfifo = 0;
+SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RW | CTLFLAG_TUN,
+	&broken_txfifo, 0, "UART FIFO has QEMU emulation bug");
+TUNABLE_INT("hw.broken_txfifo", &broken_txfifo);
+
 static int
 ns8250_bus_transmit(struct uart_softc *sc)
 {
@@ -859,7 +866,12 @@
 		uart_setreg(bas, REG_DATA, sc->sc_txbuf[i]);
 		uart_barrier(bas);
 	}
-	sc->sc_txbusy = 1;
+	if (broken_txfifo)
+		ns8250_drain(bas, UART_DRAIN_TRANSMITTER);
+	else
+		sc->sc_txbusy = 1;
 	uart_unlock(sc->sc_hwmtx);
+	if (broken_txfifo)
+		uart_sched_softih(sc, SER_INT_TXIDLE);
 	return (0);
 }



More information about the Midnightbsd-cvs mailing list