From owner-p4-projects@FreeBSD.ORG Thu Mar 29 19:45:56 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2A6A616A46B; Thu, 29 Mar 2007 19:45:56 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D473416A468 for ; Thu, 29 Mar 2007 19:45:55 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id C310B13C484 for ; Thu, 29 Mar 2007 19:45:55 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l2TJjtEA015858 for ; Thu, 29 Mar 2007 19:45:55 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l2TJjtgp015855 for perforce@freebsd.org; Thu, 29 Mar 2007 19:45:55 GMT (envelope-from marcel@freebsd.org) Date: Thu, 29 Mar 2007 19:45:55 GMT Message-Id: <200703291945.l2TJjtgp015855@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 116868 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2007 19:45:56 -0000 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); }