From owner-freebsd-current@FreeBSD.ORG Tue Feb 10 22:34:30 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A24E106564A for ; Tue, 10 Feb 2009 22:34:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 293E48FC12 for ; Tue, 10 Feb 2009 22:34:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 71BCF46B51; Tue, 10 Feb 2009 17:34:29 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n1AMYN6A016673; Tue, 10 Feb 2009 17:34:23 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: "Alexey Shuvaev" Date: Tue, 10 Feb 2009 17:34:10 -0500 User-Agent: KMail/1.9.7 References: <200902021643.39862.c47g@gmx.at> <200902101612.57922.jhb@freebsd.org> <20090210215720.GA1594@wep4035.physik.uni-wuerzburg.de> In-Reply-To: <20090210215720.GA1594@wep4035.physik.uni-wuerzburg.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902101734.10365.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 10 Feb 2009 17:34:23 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8977/Tue Feb 10 14:33:54 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: freebsd-current@freebsd.org Subject: Re: lpt stopped working X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 22:34:30 -0000 On Tuesday 10 February 2009 4:57:20 pm Alexey Shuvaev wrote: > On Tue, Feb 10, 2009 at 04:12:57PM -0500, John Baldwin wrote: > > Ok, so the first cat works, the second one gets EBUSY? > > > Mmm... I don't think the first cat really works. > It hangs, I suppose nothing goes to the wire, > and during this I got the above printigs from kgdb. > > > Hmm, I think I've found it. Due to a bug, lptclose() wasn't releasing the > > bus. Grr, lptopen() was also busted. The old lpt driver didn't actually check the HAVEBUS flag in lpt_release_ppbus() which masked the bugs in lptopen(). Try this: --- //depot/vendor/freebsd/src/sys/dev/ppbus/lpt.c 2009/01/26 21:00:15 +++ //depot/user/jhb/acpipci/dev/ppbus/lpt.c 2009/02/10 22:32:11 @@ -544,10 +544,10 @@ do { /* ran out of waiting for the printer */ if (trys++ >= LPINITRDY*4) { - sc->sc_state = 0; lprintf(("status %x\n", ppb_rstr(ppbus))); lpt_release_ppbus(lptdev); + sc->sc_state = 0; ppb_unlock(ppbus); return (EBUSY); } @@ -555,9 +555,8 @@ /* wait 1/4 second, give up if we get a signal */ if (ppb_sleep(ppbus, lptdev, LPPRI | PCATCH, "lptinit", hz / 4) != EWOULDBLOCK) { + lpt_release_ppbus(lptdev); sc->sc_state = 0; - - lpt_release_ppbus(lptdev); ppb_unlock(ppbus); return (EBUSY); } @@ -577,7 +576,8 @@ ppb_wctr(ppbus, sc->sc_control); - sc->sc_state = OPEN; + sc->sc_state &= ~LPTINIT; + sc->sc_state |= OPEN; sc->sc_xfercnt = 0; /* only use timeout if using interrupt */ @@ -611,11 +611,8 @@ int err; ppb_lock(ppbus); - if (sc->sc_flags & LP_BYPASS) { - sc->sc_state = 0; - ppb_unlock(ppbus); + if (sc->sc_flags & LP_BYPASS) goto end_close; - } if ((err = lpt_request_ppbus(lptdev, PPB_WAIT|PPB_INTR)) != 0) { ppb_unlock(ppbus); @@ -635,16 +632,16 @@ sc->sc_state &= ~OPEN; callout_stop(&sc->sc_timer); ppb_wctr(ppbus, LPC_NINIT); - sc->sc_state = 0; - sc->sc_xfercnt = 0; /* * unregistration of interrupt forced by release */ lpt_release_ppbus(lptdev); - ppb_unlock(ppbus); end_close: + sc->sc_state = 0; + sc->sc_xfercnt = 0; + ppb_unlock(ppbus); lprintf(("closed.\n")); return(0); } -- John Baldwin