From owner-freebsd-hackers@FreeBSD.ORG Sun Apr 22 05:44:42 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6613516A400; Sun, 22 Apr 2007 05:44:42 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 20BCB13C448; Sun, 22 Apr 2007 05:44:42 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.13.8/8.13.4) with ESMTP id l3M5gkt5076231; Sat, 21 Apr 2007 23:42:46 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 21 Apr 2007 23:42:53 -0600 (MDT) Message-Id: <20070421.234253.-937378175.imp@bsdimp.com> To: alfred@freebsd.org From: "M. Warner Losh" In-Reply-To: <20070419211021.GH69188@elvis.mu.org> References: <20070419211021.GH69188@elvis.mu.org> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Sat, 21 Apr 2007 23:42:46 -0600 (MDT) Cc: hackers@freebsd.org, bde@freebsd.org Subject: Re: serial help ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Apr 2007 05:44:42 -0000 In message: <20070419211021.GH69188@elvis.mu.org> Alfred Perlstein writes: : : I'm working on some custom hardware and I'm getting garbled console : output. : : I noticed that siocntxwait looks like this: : : static void : siocntxwait(iobase) : Port_t iobase; : { : int timo; : : /* : * Wait for any pending transmission to finish. Required to avoid : * the UART lockup bug when the speed is changed, and for normal : * transmits. : */ : timo = 100000; : while ((inb(iobase + com_lsr) & (LSR_TSRE | LSR_TXRDY)) : != (LSR_TSRE | LSR_TXRDY) && --timo != 0) : ; : } : : Shouldn't there be some sort of DELAY in there? : : My platform has an emulated serial device in hardware, so it : may be that the loop could run a LOT faster than transmit can : happen... : : any ideas of what the DELAY should be? The inb() is assumed to provide a delay of 1us, so this has a timeout of 100ms. Even with newer PCI devices that run about 4-5 times faster, the timeout is still on the order of 20ms, which is adequate for most modern baudrates (9600 baud takes 1ms, 115200 takes 10us). Warner