From 3c7b90774d09d8d7c367e4144f7d57b9bfb87498 Mon Sep 17 00:00:00 2001 From: Michal Meloun Date: Fri, 12 Feb 2016 05:14:58 +0000 Subject: [PATCH] UART: Fix spurious interrupts generated by ns8250 and lpc drivers: - don't enable transmitter empty interrupt before filling TX FIFO. - add missing uart_barrier() call in interrupt service routine --- sys/dev/uart/uart_dev_lpc.c | 5 +++-- sys/dev/uart/uart_dev_ns8250.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/dev/uart/uart_dev_lpc.c b/sys/dev/uart/uart_dev_lpc.c index 6cd10f1ae48c..9a3e12b840fe 100644 --- a/sys/dev/uart/uart_dev_lpc.c +++ b/sys/dev/uart/uart_dev_lpc.c @@ -659,6 +659,7 @@ lpc_ns8250_bus_ipend(struct uart_softc *sc) if (iir & IIR_TXRDY) { ipend |= SER_INT_TXIDLE; uart_setreg(bas, REG_IER, lpc_ns8250->ier); + uart_barrier(bas); } else ipend |= SER_INT_SIGCHG; } @@ -892,12 +893,12 @@ lpc_ns8250_bus_transmit(struct uart_softc *sc) uart_lock(sc->sc_hwmtx); while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0) ; - uart_setreg(bas, REG_IER, lpc_ns8250->ier | IER_ETXRDY); - uart_barrier(bas); for (i = 0; i < sc->sc_txdatasz; i++) { uart_setreg(bas, REG_DATA, sc->sc_txbuf[i]); uart_barrier(bas); } + uart_setreg(bas, REG_IER, lpc_ns8250->ier | IER_ETXRDY); + uart_barrier(bas); sc->sc_txbusy = 1; uart_unlock(sc->sc_hwmtx); return (0); diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index 3bba676c5dc6..9802294d3038 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -708,6 +708,7 @@ ns8250_bus_ipend(struct uart_softc *sc) if (iir & IIR_TXRDY) { ipend |= SER_INT_TXIDLE; uart_setreg(bas, REG_IER, ns8250->ier); + uart_barrier(bas); } else ipend |= SER_INT_SIGCHG; } @@ -979,12 +980,12 @@ ns8250_bus_transmit(struct uart_softc *sc) uart_lock(sc->sc_hwmtx); while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0) ; - uart_setreg(bas, REG_IER, ns8250->ier | IER_ETXRDY); - uart_barrier(bas); for (i = 0; i < sc->sc_txdatasz; i++) { uart_setreg(bas, REG_DATA, sc->sc_txbuf[i]); uart_barrier(bas); } + uart_setreg(bas, REG_IER, ns8250->ier | IER_ETXRDY); + uart_barrier(bas); if (broken_txfifo) ns8250_drain(bas, UART_DRAIN_TRANSMITTER); else