From owner-freebsd-bugs Fri May 10 8:20:56 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0078B37B409 for ; Fri, 10 May 2002 08:20:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g4AFK1N07375; Fri, 10 May 2002 08:20:01 -0700 (PDT) (envelope-from gnats) Received: from mail504.nifty.com (mail504.nifty.com [202.248.37.212]) by hub.freebsd.org (Postfix) with ESMTP id 21A5337B409 for ; Fri, 10 May 2002 08:15:35 -0700 (PDT) Received: from localhost by mail504.nifty.com (8.12.3/3.7W-02/25/02) with ESMTP id g4AFFADM025799 for ; Sat, 11 May 2002 00:15:10 +0900 Message-Id: <20020511.001016.74758161.toshi@altair.weganet.jp> Date: Sat, 11 May 2002 00:10:16 +0900 (JST) From: Toshikazu ICHINOSEKI To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/37928: [PATCH] can't go single user mode after usb mouse attached Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 37928 >Category: kern >Synopsis: [PATCH] can't go single user mode after usb mouse attached >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri May 10 08:20:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Toshikazu Ichinoseki >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD altair 5.0-CURRENT FreeBSD 5.0-CURRENT #33: Fri May 10 21:22:34 JST 2002 toshi@altair:/usr/src/sys/i386/compile/ALTAIR i386 Machine: Aopen AX59pro + AMD K6-2 450MHz + 512MB Mem (Chip set is Apollo MVP3, uhci0: ) >Description: When I try to go single user mode after usb mouse attached, I get following message on console: init: some process would not die; ps axl advised init: can't get /dev/console for controlling terminal: Operation not permitted. In DDB, ps shows that moused sleeps with wmesg "uhciab". This means uhci driver sleeps in uhci_abort_xfer() and is not waken up. >How-To-Repeat: Whenever I try to go single user mode, after usb mouse is attached . >Fix: Following patch fixes this problem. And I can use HP Diskjet 957c USB printer after this patch applied. Before I apply this patch, lpr fails to open /dev/ulpt0, so I can print nothing. I don't have a FreeBSD box which has ohci device, so patch to ohci.c and ohciver.h is not tested. On recent change to usb_port.h, USB_USE_SOFTINTR is defined. Patched uhci driver works whether USB_USE_SOFTINTR is defined or not. ------------------------------------------------------------ Index: ohci.c =================================================================== RCS file: /local/cvsroot/src/sys/dev/usb/ohci.c,v retrieving revision 1.104 diff -u -r1.104 ohci.c --- ohci.c 29 Apr 2002 16:23:14 -0000 1.104 +++ ohci.c 9 May 2002 15:05:30 -0000 @@ -140,6 +140,7 @@ #endif Static usbd_status ohci_open(usbd_pipe_handle); Static void ohci_poll(struct usbd_bus *); +Static void ohci_softintr_do_wakeup(void *ident); Static void ohci_softintr(void *); Static void ohci_waitintr(ohci_softc_t *, usbd_xfer_handle); Static void ohci_add_done(ohci_softc_t *, ohci_physaddr_t); @@ -891,6 +892,7 @@ #endif usb_callout_init(sc->sc_tmo_rhsc); + usb_callout_init(sc->sc_softintr_handle); return (USBD_NORMAL_COMPLETION); @@ -1301,9 +1303,24 @@ } void +ohci_softintr_do_wakeup(void *ident) +{ + int s; + + s = splusb(); + wakeup(ident); + splx(s); +} + +void ohci_softintr(void *v) { +#if defined(__FreeBSD__) + struct usbd_bus *bus = v; + ohci_softc_t *sc = device_get_ivars(bus->bdev); +#else ohci_softc_t *sc = v; +#endif ohci_soft_itd_t *sitd, *sidone, *sitdnext; ohci_soft_td_t *std, *sdone, *stdnext; usbd_xfer_handle xfer; @@ -1456,7 +1473,9 @@ if (sc->sc_softwake) { sc->sc_softwake = 0; - wakeup(&sc->sc_softwake); + /* wake up after 1 tick */ + usb_callout(sc->sc_softintr_handle, 1, + ohci_softintr_do_wakeup, &sc->sc_softwake); } sc->sc_bus.intr_context--; Index: ohcivar.h =================================================================== RCS file: /local/cvsroot/src/sys/dev/usb/ohcivar.h,v retrieving revision 1.32 diff -u -r1.32 ohcivar.h --- ohcivar.h 7 Apr 2002 15:16:31 -0000 1.32 +++ ohcivar.h 9 May 2002 14:37:17 -0000 @@ -141,6 +141,8 @@ device_ptr_t sc_child; char sc_dying; + + usb_callout_t sc_softintr_handle; } ohci_softc_t; struct ohci_xfer { Index: uhci.c =================================================================== RCS file: /local/cvsroot/src/sys/dev/usb/uhci.c,v retrieving revision 1.120 diff -u -r1.120 uhci.c --- uhci.c 26 Apr 2002 22:48:22 -0000 1.120 +++ uhci.c 9 May 2002 15:04:11 -0000 @@ -247,6 +247,7 @@ Static usbd_status uhci_open(usbd_pipe_handle); Static void uhci_poll(struct usbd_bus *); +Static void uhci_softintr_do_wakeup(void *ident); Static void uhci_softintr(void *); Static usbd_status uhci_device_request(usbd_xfer_handle xfer); @@ -506,6 +507,7 @@ SIMPLEQ_INIT(&sc->sc_free_xfers); usb_callout_init(sc->sc_poll_handle); + usb_callout_init(sc->sc_softintr_handle); /* Set up the bus struct. */ sc->sc_bus.methods = &uhci_bus_methods; @@ -1262,9 +1264,24 @@ } void +uhci_softintr_do_wakeup(void *ident) +{ + int s; + + s = splusb(); + wakeup(ident); + splx(s); +} + +void uhci_softintr(void *v) { +#if defined(__FreeBSD__) + struct usbd_bus *bus = v; + uhci_softc_t *sc = device_get_ivars(bus->bdev); +#else uhci_softc_t *sc = v; +#endif uhci_intr_info_t *ii; DPRINTFN(10,("%s: uhci_softintr (%d)\n", USBDEVNAME(sc->sc_bus.bdev), @@ -1288,7 +1305,9 @@ if (sc->sc_softwake) { sc->sc_softwake = 0; - wakeup(&sc->sc_softwake); + /* wake up after 1 tick */ + usb_callout(sc->sc_softintr_handle, 1, + uhci_softintr_do_wakeup, &sc->sc_softwake); } sc->sc_bus.intr_context--; Index: uhcivar.h =================================================================== RCS file: /local/cvsroot/src/sys/dev/usb/uhcivar.h,v retrieving revision 1.33 diff -u -r1.33 uhcivar.h --- uhcivar.h 7 Apr 2002 18:06:34 -0000 1.33 +++ uhcivar.h 9 May 2002 14:22:29 -0000 @@ -188,6 +188,8 @@ #endif device_ptr_t sc_child; /* /dev/usb# device */ + + usb_callout_t sc_softintr_handle; } uhci_softc_t; usbd_status uhci_init(uhci_softc_t *); --------------------------------------------------------------- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message