Date: Thu, 29 Mar 2007 19:45:55 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 116868 for review Message-ID: <200703291945.l2TJjtgp015855@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=116868 Change 116868 by marcel@marcel_jnpr on 2007/03/29 19:45:01 In ns8250_putc() and ns8250_getc(), don't calculate the a delay value of about 1/10th the time it takes to send a character. In ns8250_putc() we only want to avoid waiting indefinitely for some status change and in ns8250_getc() we just want to back-off from the bus when we wait for some status change (and unlocking the hardware while we're at it). This really doesn't need exact timing. It's sufficient to assume that regardless of the baudrate, we should not have to wait longer than a second for the status to change and we can express everything in terms of a fixed delay (DELAY(4) in this case). The upshot is that we eliminate expensive calculations for every character we send, with a positive side-effect that if we lack the precision (e.g. the exact frequency of the baudrate clock) we don't mess up any low-level I/O. Affected files ... .. //depot/projects/uart/dev/uart/uart_dev_ns8250.c#49 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_dev_ns8250.c#49 (text+ko) ==== @@ -285,19 +285,16 @@ 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 @@ 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703291945.l2TJjtgp015855>