From owner-freebsd-arm@FreeBSD.ORG Mon Oct 7 21:20:45 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 09EDABFB; Mon, 7 Oct 2013 21:20:45 +0000 (UTC) (envelope-from zbodek@gmail.com) Received: from mail-wi0-x22d.google.com (mail-wi0-x22d.google.com [IPv6:2a00:1450:400c:c05::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1D58024F5; Mon, 7 Oct 2013 21:20:43 +0000 (UTC) Received: by mail-wi0-f173.google.com with SMTP id hq15so5539069wib.12 for ; Mon, 07 Oct 2013 14:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=HkVwl181jzxkRBOQX0mJoFpolErA49EzP70seO12wfA=; b=daUyBm7fbigZehpVk2hPCGXI46B+tZIfVTJyAPhq+tLmPP7ppU3pvS5rJgMUv+ASKW Dn1C8d8ovdYK3tGdrxA6R82gGY9aQOpg7l/c7r0MgLpF5upDiW6XgU9XsHlKv0RzIVEU uWnu4qKQB2mU19XHr51DgBnThxN0LScYmMlZxLvcqHAe3fmsNhaDk7eZCyOYseU2sI5T 039j1FBpbPi/3m6j24FwCYbhB+uSHMIuZqLSA/WnWC76Q6BOB4ebzHT9g/R8V1nCs7Zt A1Dmk9PVkykNkFLtL7hla927HV/fptiwDiR1cGGH4M/MR+9/i1v2aUrENoRX5sZBTu3R b/rQ== MIME-Version: 1.0 X-Received: by 10.180.81.71 with SMTP id y7mr20587288wix.63.1381180842515; Mon, 07 Oct 2013 14:20:42 -0700 (PDT) Sender: zbodek@gmail.com Received: by 10.216.160.70 with HTTP; Mon, 7 Oct 2013 14:20:42 -0700 (PDT) In-Reply-To: <1381179800.1130.21.camel@revolution.hippie.lan> References: <1381179385.1130.18.camel@revolution.hippie.lan> <1381179800.1130.21.camel@revolution.hippie.lan> Date: Mon, 7 Oct 2013 23:20:42 +0200 X-Google-Sender-Auth: -5ze0Vq-CNFksmlSBW2M3ilboD0 Message-ID: Subject: Re: Changes to UART ns8250 From: Zbigniew Bodek To: Ian Lepore Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "freebsd-arm@freebsd.org" , freebsd-current , "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 21:20:45 -0000 Hello Ian. Well you can't really perform wake event basing on busy interrupt because we are busy waiting/sleeping i.a. to avoid that interrupt to occur. I tried to use pause() that should switch to another task for the declared amount of time and I got: "panic: mi_switch: switch in a critical section" Best regards Zbigniew Bodek 2013/10/7 Ian Lepore > On Mon, 2013-10-07 at 14:56 -0600, Ian Lepore wrote: > > 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 > > > > differences between files attachment (temp.diff) > > 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); > > Ooops, that should be != 0 in that USR_BUSY test. Also, I haven't > tested this at all because I don't I have any boards that use DW uarts. > > -- Ian > > >