Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/jmcneill-usbmp]: src/sys/dev/usb make ohci mostly work again.



details:   https://anonhg.NetBSD.org/src/rev/395398be204b
branches:  jmcneill-usbmp
changeset: 771787:395398be204b
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Dec 08 22:38:47 2011 +0000

description:
make ohci mostly work again.

diffstat:

 sys/dev/usb/ohci.c     |  20 +++++++++++++++-----
 sys/dev/usb/usbdi.c    |  11 +++++------
 sys/dev/usb/usbdivar.h |   4 ++--
 3 files changed, 22 insertions(+), 13 deletions(-)

diffs (162 lines):

diff -r 6ee87d9a7760 -r 395398be204b sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Thu Dec 08 03:10:09 2011 +0000
+++ b/sys/dev/usb/ohci.c        Thu Dec 08 22:38:47 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.218.6.6 2011/12/08 02:51:07 mrg Exp $       */
+/*     $NetBSD: ohci.c,v 1.218.6.7 2011/12/08 22:38:47 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.6 2011/12/08 02:51:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.7 2011/12/08 22:38:47 mrg Exp $");
 
 #include "opt_usb.h"
 
@@ -2163,7 +2163,9 @@
                        goto bad0;
                opipe->sed = sed;
                if (xfertype == UE_ISOCHRONOUS) {
+                       mutex_enter(&sc->sc_lock);
                        sitd = ohci_alloc_sitd(sc);
+                       mutex_exit(&sc->sc_lock);
                        if (sitd == NULL)
                                goto bad1;
                        opipe->tail.itd = sitd;
@@ -2174,7 +2176,9 @@
                        else
                                fmt |= OHCI_ED_DIR_OUT;
                } else {
+                       mutex_enter(&sc->sc_lock);
                        std = ohci_alloc_std(sc);
+                       mutex_exit(&sc->sc_lock);
                        if (std == NULL)
                                goto bad1;
                        opipe->tail.td = std;
@@ -2961,8 +2965,8 @@
        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);
-       ohci_free_std(sc, opipe->tail.td);
 }
 
 /************************/
@@ -3125,8 +3129,8 @@
        DPRINTF(("ohci_device_bulk_close: pipe=%p\n", pipe));
        mutex_enter(&sc->sc_lock);
        ohci_close_pipe(pipe, sc->sc_bulk_head);
+       ohci_free_std(sc, opipe->tail.td);
        mutex_exit(&sc->sc_lock);
-       ohci_free_std(sc, opipe->tail.td);
 }
 
 /************************/
@@ -3175,7 +3179,9 @@
        isread = UE_GET_DIR(endpt) == UE_DIR_IN;
 
        data = opipe->tail.td;
+       mutex_enter(&sc->sc_lock);
        tail = ohci_alloc_std(sc);
+       mutex_exit(&sc->sc_lock);
        if (tail == NULL)
                return (USBD_NOMEM);
        tail->xfer = NULL;
@@ -3429,7 +3435,9 @@
                    OHCI_PAGE(buf + noffs) > bp0 + OHCI_PAGE_SIZE) { /* too many page crossings */
 
                        /* Allocate next ITD */
+                       mutex_enter(&sc->sc_lock);
                        nsitd = ohci_alloc_sitd(sc);
+                       mutex_exit(&sc->sc_lock);
                        if (nsitd == NULL) {
                                /* XXX what now? */
                                printf("%s: isoc TD alloc failed\n",
@@ -3460,7 +3468,9 @@
                sitd->itd.itd_offset[ncur] = HTOO16(OHCI_ITD_MK_OFFS(offs));
                offs = noffs;
        }
+       mutex_enter(&sc->sc_lock);
        nsitd = ohci_alloc_sitd(sc);
+       mutex_exit(&sc->sc_lock);
        if (nsitd == NULL) {
                /* XXX what now? */
                printf("%s: isoc TD alloc failed\n",
@@ -3644,6 +3654,6 @@
 #ifdef DIAGNOSTIC
        opipe->tail.itd->isdone = 1;
 #endif
+       ohci_free_sitd(sc, opipe->tail.itd);
        mutex_exit(&sc->sc_lock);
-       ohci_free_sitd(sc, opipe->tail.itd);
 }
diff -r 6ee87d9a7760 -r 395398be204b sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Thu Dec 08 03:10:09 2011 +0000
+++ b/sys/dev/usb/usbdi.c       Thu Dec 08 22:38:47 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.134.2.3 2011/12/08 03:10:09 mrg Exp $      */
+/*     $NetBSD: usbdi.c,v 1.134.2.4 2011/12/08 22:38:47 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.3 2011/12/08 03:10:09 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.4 2011/12/08 22:38:47 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usb.h"
@@ -229,6 +229,7 @@
 usbd_status
 usbd_close_pipe(usbd_pipe_handle pipe)
 {
+
 #ifdef DIAGNOSTIC
        if (pipe == NULL) {
                printf("usbd_close_pipe: pipe==NULL\n");
@@ -762,7 +763,6 @@
            xfer->status == USBD_TIMEOUT;
        int repeat, polling;
 
-
        DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
                     "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
 
@@ -854,11 +854,10 @@
        }
 
        if (sync && !polling) {
-               if (pipe->device->bus->lock) {
+               if (pipe->device->bus->lock)
                        cv_broadcast(&xfer->cv);
-               } else {
+               else
                        wakeup(xfer);
-               }
        }
 
        if (!repeat) {
diff -r 6ee87d9a7760 -r 395398be204b sys/dev/usb/usbdivar.h
--- a/sys/dev/usb/usbdivar.h    Thu Dec 08 03:10:09 2011 +0000
+++ b/sys/dev/usb/usbdivar.h    Thu Dec 08 22:38:47 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdivar.h,v 1.93.8.2 2011/12/08 02:51:08 mrg Exp $    */
+/*     $NetBSD: usbdivar.h,v 1.93.8.3 2011/12/08 22:38:47 mrg Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $   */
 
 /*
@@ -144,7 +144,7 @@
        /* Filled by usb driver */
        kmutex_t                *intr_lock;
        kmutex_t                *lock;
-       struct usbd_device      *root_hub;
+       struct usbd_device      *root_hub;
        usbd_device_handle      devices[USB_MAX_DEVICES];
        char                    needs_explore;/* a hub a signalled a change */
        char                    use_polling;



Home | Main Index | Thread Index | Old Index