Index: sys/dev/uart/uart_dev_ns8250.c =================================================================== --- sys/dev/uart/uart_dev_ns8250.c +++ sys/dev/uart/uart_dev_ns8250.c @@ -178,13 +178,21 @@ * limit high enough to handle large FIFOs and integrated * UARTs. The HP rx2600 for example has 3 UARTs on the * management board that tend to get a lot of data send - * to it when the UART is first activated. + * to it when the UART is first activated. Assume that we + * have finished draining if LSR_RXRDY is not asserted both + * prior to and after a DELAY; but as long as LSR_RXRDY is + * asserted, read (and discard) characters as quickly as + * possible. */ - limit=10*4096; - while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) && --limit) { + for (limit = 10 * 4096; limit > 0; limit--) { + if ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) == 0) { + DELAY(delay << 2); + uart_barrier(bas); + if ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) == 0) + break; + } (void)uart_getreg(bas, REG_DATA); uart_barrier(bas); - DELAY(delay << 2); } if (limit == 0) { /* printf("ns8250: receiver appears broken... "); */