From owner-svn-src-head@FreeBSD.ORG Wed Feb 11 14:25:09 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A53FF1065670; Wed, 11 Feb 2009 14:25:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 791628FC19; Wed, 11 Feb 2009 14:25:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1BEP9ml027832; Wed, 11 Feb 2009 14:25:09 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1BEP9Ov027831; Wed, 11 Feb 2009 14:25:09 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200902111425.n1BEP9Ov027831@svn.freebsd.org> From: John Baldwin Date: Wed, 11 Feb 2009 14:25:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188484 - head/sys/dev/ppbus X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2009 14:25:10 -0000 Author: jhb Date: Wed Feb 11 14:25:09 2009 New Revision: 188484 URL: http://svn.freebsd.org/changeset/base/188484 Log: Fix lptopen() and lptclose() to not trash the state of the HAVEBUS flag in 'sc_state'. This allows the lpt_release_ppbus() calls in those two routines to actually release the ppbus and thus fixes the hangs noticed with the lpt(4) driver since the recent ppbus changes. The old lpt(4) driver didn't actually check the HAVEBUS flag in lpt_release_ppbus() which is why these bugs weren't noticed before. Modified: head/sys/dev/ppbus/lpt.c Modified: head/sys/dev/ppbus/lpt.c ============================================================================== --- head/sys/dev/ppbus/lpt.c Wed Feb 11 13:44:27 2009 (r188483) +++ head/sys/dev/ppbus/lpt.c Wed Feb 11 14:25:09 2009 (r188484) @@ -544,10 +544,10 @@ lptopen(struct cdev *dev, int flags, int 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 @@ lptopen(struct cdev *dev, int flags, int /* wait 1/4 second, give up if we get a signal */ if (ppb_sleep(ppbus, lptdev, LPPRI | PCATCH, "lptinit", hz / 4) != EWOULDBLOCK) { - sc->sc_state = 0; - lpt_release_ppbus(lptdev); + sc->sc_state = 0; ppb_unlock(ppbus); return (EBUSY); } @@ -577,7 +576,8 @@ lptopen(struct cdev *dev, int flags, int 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 @@ lptclose(struct cdev *dev, int flags, in 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 @@ lptclose(struct cdev *dev, int flags, in 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); }