svn commit: r246626 - stable/8/sys/dev/uart

Colin Percival cperciva at FreeBSD.org
Sun Feb 10 17:50:56 UTC 2013


Author: cperciva
Date: Sun Feb 10 17:50:56 2013
New Revision: 246626
URL: http://svnweb.freebsd.org/changeset/base/246626

Log:
  MFC r246016:
    Add a loader tunable "hw.broken_txfifo" which enables a workaround for a
    bug in old versions of QEMU (and Xen, and other places using QEMU code).

Modified:
  stable/8/sys/dev/uart/uart_dev_ns8250.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/uart/   (props changed)

Modified: stable/8/sys/dev/uart/uart_dev_ns8250.c
==============================================================================
--- stable/8/sys/dev/uart/uart_dev_ns8250.c	Sun Feb 10 17:48:46 2013	(r246625)
+++ stable/8/sys/dev/uart/uart_dev_ns8250.c	Sun Feb 10 17:50:56 2013	(r246626)
@@ -31,6 +31,8 @@ __FBSDID("$FreeBSD$");
 #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 @@ ns8250_bus_setsig(struct uart_softc *sc,
 	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 @@ ns8250_bus_transmit(struct uart_softc *s
 		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 svn-src-stable-8 mailing list