Module Name: src Committed By: mrg Date: Thu Dec 8 10:22:40 UTC 2011
Modified Files: src/sys/dev/usb [mrg-ohci-jmcneill-usbmp]: ohci.c usb_subr.c usbdi.c usbdivar.h Log Message: merge a few more things from the main branch. uaudio@ohci still works. To generate a diff of this commit: cvs rdiff -u -r1.218.6.2.2.5 -r1.218.6.2.2.6 src/sys/dev/usb/ohci.c cvs rdiff -u -r1.180.6.1.2.1 -r1.180.6.1.2.2 src/sys/dev/usb/usb_subr.c cvs rdiff -u -r1.134.2.1.2.1 -r1.134.2.1.2.2 src/sys/dev/usb/usbdi.c cvs rdiff -u -r1.93.8.1 -r1.93.8.1.2.1 src/sys/dev/usb/usbdivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.218.6.2.2.5 src/sys/dev/usb/ohci.c:1.218.6.2.2.6 --- src/sys/dev/usb/ohci.c:1.218.6.2.2.5 Thu Dec 8 09:36:49 2011 +++ src/sys/dev/usb/ohci.c Thu Dec 8 10:22:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.218.6.2.2.5 2011/12/08 09:36:49 mrg Exp $ */ +/* $NetBSD: ohci.c,v 1.218.6.2.2.6 2011/12/08 10:22:40 mrg Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ /* @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.2.2.5 2011/12/08 09:36:49 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.2.2.6 2011/12/08 10:22:40 mrg Exp $"); #include "opt_usb.h" @@ -2961,8 +2961,10 @@ ohci_device_ctrl_close(usbd_pipe_handle ohci_softc_t *sc = pipe->device->bus->hci_private; DPRINTF(("ohci_device_ctrl_close: pipe=%p\n", pipe)); + mutex_enter(&sc->sc_lock); ohci_close_pipe(pipe, sc->sc_ctrl_head); ohci_free_std(sc, opipe->tail.td); + mutex_exit(&sc->sc_lock); } /************************/ @@ -3125,8 +3127,8 @@ ohci_device_bulk_close(usbd_pipe_handle DPRINTF(("ohci_device_bulk_close: pipe=%p\n", pipe)); mutex_enter(&sc->sc_lock); ohci_close_pipe(pipe, sc->sc_bulk_head); - mutex_exit(&sc->sc_lock); ohci_free_std(sc, opipe->tail.td); + mutex_exit(&sc->sc_lock); } /************************/ Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.180.6.1.2.1 src/sys/dev/usb/usb_subr.c:1.180.6.1.2.2 --- src/sys/dev/usb/usb_subr.c:1.180.6.1.2.1 Thu Dec 8 09:36:49 2011 +++ src/sys/dev/usb/usb_subr.c Thu Dec 8 10:22:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.180.6.1.2.1 2011/12/08 09:36:49 mrg Exp $ */ +/* $NetBSD: usb_subr.c,v 1.180.6.1.2.2 2011/12/08 10:22:40 mrg Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.180.6.1.2.1 2011/12/08 09:36:49 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.180.6.1.2.2 2011/12/08 10:22:40 mrg Exp $"); #include "opt_compat_netbsd.h" #include "opt_usbverbose.h" @@ -765,11 +765,7 @@ void usbd_kill_pipe(usbd_pipe_handle pipe) { usbd_abort_pipe(pipe); - if (pipe->lock) - mutex_enter(pipe->lock); pipe->methods->close(pipe); - if (pipe->lock) - mutex_exit(pipe->lock); pipe->endpoint->refcnt--; free(pipe, M_USB); } Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.134.2.1.2.1 src/sys/dev/usb/usbdi.c:1.134.2.1.2.2 --- src/sys/dev/usb/usbdi.c:1.134.2.1.2.1 Thu Dec 8 07:53:56 2011 +++ src/sys/dev/usb/usbdi.c Thu Dec 8 10:22:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.134.2.1.2.1 2011/12/08 07:53:56 mrg Exp $ */ +/* $NetBSD: usbdi.c,v 1.134.2.1.2.2 2011/12/08 10:22:40 mrg Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.1.2.1 2011/12/08 07:53:56 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.1.2.2 2011/12/08 10:22:40 mrg Exp $"); #include "opt_compat_netbsd.h" #include "opt_usb.h" @@ -727,7 +727,6 @@ usbd_ar_pipe(usbd_pipe_handle pipe) { usbd_xfer_handle xfer; - SPLUSBCHECK; KASSERT(pipe->lock == NULL || mutex_owned(pipe->lock)); DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe)); @@ -763,8 +762,6 @@ usb_transfer_complete(usbd_xfer_handle x xfer->status == USBD_TIMEOUT; int repeat, polling; - SPLUSBCHECK; - DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d " "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen)); @@ -907,8 +904,6 @@ usbd_start_next(usbd_pipe_handle pipe) usbd_xfer_handle xfer; usbd_status err; - SPLUSBCHECK; - #ifdef DIAGNOSTIC if (pipe == NULL) { printf("usbd_start_next: pipe == NULL\n"); Index: src/sys/dev/usb/usbdivar.h diff -u src/sys/dev/usb/usbdivar.h:1.93.8.1 src/sys/dev/usb/usbdivar.h:1.93.8.1.2.1 --- src/sys/dev/usb/usbdivar.h:1.93.8.1 Sun Dec 4 13:23:17 2011 +++ src/sys/dev/usb/usbdivar.h Thu Dec 8 10:22:40 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdivar.h,v 1.93.8.1 2011/12/04 13:23:17 jmcneill Exp $ */ +/* $NetBSD: usbdivar.h,v 1.93.8.1.2.1 2011/12/08 10:22:40 mrg Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ /* @@ -34,6 +34,41 @@ #include <sys/callout.h> #include <sys/mutex.h> +/* + * Discussion about locking in the USB code: + * + * There are two locks presented by the host controller: the interrupt lock + * and the thread lock. The interrupt lock, either a spin or adaptive mutex, + * manages hardware state and anything else touched in an interrupt context. + * The thread lock has everything else. + * + * List of hardware interface methods, and which locks are held when each + * is called by this module: + * + * BUS METHOD INTR THREAD NOTES + * ----------------------- ------- ------- ------------------------- + * open_pipe - - might want to take thread lock? + * soft_intr - - intr lock is taken sometimes, thread lock taken often, but nothing demanded? + * do_poll - - might want to take thread lock? + * allocm - - + * freem - - + * allocx - - + * freex - - + * get_locks - - Called at attach time + * + * PIPE METHOD INTR THREAD NOTES + * ----------------------- ------- ------- ------------------------- + * transfer - - + * start - - + * abort - - + * close - x + * cleartoggle - - + * done - x + * + * The above semantics are likely to change. + * + */ + /* From usb_mem.h */ struct usb_dma_block; typedef struct { @@ -269,17 +304,3 @@ void usb_schedsoftintr(struct usbd_bus #define usbd_lock(m) if (m) { s = -1; mutex_enter(m); } else s = splusb() #define usbd_unlock(m) if (m) { s = -1; mutex_exit(m); } else splx(s) - -/* - * XXX This check is extremely bogus. Bad Bad Bad. - */ -#if defined(DIAGNOSTIC) && 0 -#define SPLUSBCHECK \ - do { int _s = splusb(), _su = splusb(); \ - if (!cold && _s != _su) printf("SPLUSBCHECK failed 0x%x!=0x%x, %s:%d\n", \ - _s, _su, __FILE__, __LINE__); \ - splx(_s); \ - } while (0) -#else -#define SPLUSBCHECK -#endif