Index: sys/dev/uart/uart_dev_ns8250.c =================================================================== --- sys/dev/uart/uart_dev_ns8250.c (revision 255916) +++ sys/dev/uart/uart_dev_ns8250.c (working copy) @@ -614,6 +614,7 @@ ns8250_bus_ipend(struct uart_softc *sc) if (ns8250->busy_detect && (iir & IIR_BUSY) == IIR_BUSY) { (void)uart_getreg(bas, DW_REG_USR); + wakeup(&ns8250->busy_detect); uart_unlock(sc->sc_hwmtx); return (0); } @@ -652,6 +653,16 @@ ns8250_bus_param(struct uart_softc *sc, int baudra bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); + /* + * When using DW UART with BUSY detection it is necessary to wait + * until all serial transfers are finished before manipulating the + * line control. LCR will not be affected when UART is busy. + */ + while (ns8250->busy_detect && + (uart_getreg(bas, DW_REG_USR) & USR_BUSY) == 0) { + msleep(&ns8250->busy_detect, sc->sc_hwmtx, "dwbusy", 10); + } + error = ns8250_param(bas, baudrate, databits, stopbits, parity); uart_unlock(sc->sc_hwmtx); return (error);