mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-12 09:58:36 +00:00
Don't use a time-limiting loop that's defined in terms of the baudrate
in the putc() method. Likewise, in the getc() method, don't check for received characters with an interval defined in terms of the baudrate. In both cases it works equally well to implement a fixed delay. More importantly, it avoids calculating a delay that's roughly 1/10th the time it takes to send/receive a character. The calculation is costly and happens for every character sent or received, affecting low-level console or debug port performance significantly. Secondly, when the RCLK is not available or unreliable, the delays could disrupt normal operation. The fixed delay is 1/10th the time it takes to send a character at 230400 bps.
This commit is contained in:
parent
7bd5b79de4
commit
35777a2a79
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168285
@ -285,19 +285,16 @@ ns8250_term(struct uart_bas *bas)
|
||||
static void
|
||||
ns8250_putc(struct uart_bas *bas, int c)
|
||||
{
|
||||
int delay, limit;
|
||||
int limit;
|
||||
|
||||
/* 1/10th the time to transmit 1 character (estimate). */
|
||||
delay = ns8250_delay(bas);
|
||||
|
||||
limit = 20;
|
||||
limit = 250000;
|
||||
while ((uart_getreg(bas, REG_LSR) & LSR_THRE) == 0 && --limit)
|
||||
DELAY(delay);
|
||||
DELAY(4);
|
||||
uart_setreg(bas, REG_DATA, c);
|
||||
uart_barrier(bas);
|
||||
limit = 40;
|
||||
limit = 250000;
|
||||
while ((uart_getreg(bas, REG_LSR) & LSR_TEMT) == 0 && --limit)
|
||||
DELAY(delay);
|
||||
DELAY(4);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -310,16 +307,13 @@ ns8250_rxready(struct uart_bas *bas)
|
||||
static int
|
||||
ns8250_getc(struct uart_bas *bas, struct mtx *hwmtx)
|
||||
{
|
||||
int c, delay;
|
||||
int c;
|
||||
|
||||
uart_lock(hwmtx);
|
||||
|
||||
/* 1/10th the time to transmit 1 character (estimate). */
|
||||
delay = ns8250_delay(bas);
|
||||
|
||||
while ((uart_getreg(bas, REG_LSR) & LSR_RXRDY) == 0) {
|
||||
uart_unlock(hwmtx);
|
||||
DELAY(delay);
|
||||
DELAY(4);
|
||||
uart_lock(hwmtx);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user