From owner-freebsd-arm@FreeBSD.ORG Mon Oct 7 20:56:35 2013 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 078A0917; Mon, 7 Oct 2013 20:56:35 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mho-01-ewr.mailhop.org (mho-03-ewr.mailhop.org [204.13.248.66]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CC08B22CC; Mon, 7 Oct 2013 20:56:34 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1VTHqu-000Bea-BJ; Mon, 07 Oct 2013 20:56:28 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r97KuPpa017656; Mon, 7 Oct 2013 14:56:25 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19BSbxbcp5aiKIGKTOX+AWR Subject: Re: Changes to UART ns8250 From: Ian Lepore To: Zbigniew Bodek In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-Kqv6EfxlCQV1TR9DVG7S" Date: Mon, 07 Oct 2013 14:56:25 -0600 Message-ID: <1381179385.1130.18.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: freebsd-current , "freebsd-arm@freebsd.org" , "freebsd-embedded@freebsd.org" X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Oct 2013 20:56:35 -0000 --=-Kqv6EfxlCQV1TR9DVG7S Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, 2013-10-07 at 22:36 +0200, Zbigniew Bodek wrote: > Hello Adrian, > > Thank you for your remarks. > Please check my answers in-line. > > Best regards > Zbigniew Bodek > > > 2013/10/7 Adrian Chadd > > > Hi, > > > > You should add: > > > > * a loop counter, to break out after a while; > > > [ZBB] In general as long as UART is busy we cannot proceed but if the > timeout occurs we could return an error. Do you agree? > > > * a DELAY(1) or something. > > > [ZBB] DELAY is also a busy wait after all. The reasonable solution might be > to use ns8250_delay() to get the transmission time and use it for timeout > from the first point. I would DELAY(1) in each loop and decrement value > acquired from ns8250_delay(). The loop should break during that time or we > return an error. What do you think? > Is it possible to not busy-wait at all? Something like the attached? -- Ian --=-Kqv6EfxlCQV1TR9DVG7S Content-Disposition: inline; filename="temp.diff" Content-Type: text/x-patch; name="temp.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: sys/dev/uart/uart_dev_ns8250.c =================================================================== --- sys/dev/uart/uart_dev_ns8250.c (revision 255916) +++ sys/dev/uart/uart_dev_ns8250.c (working copy) @@ -614,6 +614,7 @@ ns8250_bus_ipend(struct uart_softc *sc) if (ns8250->busy_detect && (iir & IIR_BUSY) == IIR_BUSY) { (void)uart_getreg(bas, DW_REG_USR); + wakeup(&ns8250->busy_detect); uart_unlock(sc->sc_hwmtx); return (0); } @@ -652,6 +653,16 @@ ns8250_bus_param(struct uart_softc *sc, int baudra bas = &sc->sc_bas; uart_lock(sc->sc_hwmtx); + /* + * When using DW UART with BUSY detection it is necessary to wait + * until all serial transfers are finished before manipulating the + * line control. LCR will not be affected when UART is busy. + */ + while (ns8250->busy_detect && + (uart_getreg(bas, DW_REG_USR) & USR_BUSY) == 0) { + msleep(&ns8250->busy_detect, sc->sc_hwmtx, "dwbusy", 10); + } + error = ns8250_param(bas, baudrate, databits, stopbits, parity); uart_unlock(sc->sc_hwmtx); return (error); --=-Kqv6EfxlCQV1TR9DVG7S--