Source-Changes-HG archive

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

[src/mrg-ohci-jmcneill-usbmp]: src/sys/dev/usb pull across a few more of the ...



details:   https://anonhg.NetBSD.org/src/rev/fc03e2e47194
branches:  mrg-ohci-jmcneill-usbmp
changeset: 771776:fc03e2e47194
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Dec 08 20:21:31 2011 +0000

description:
pull across a few more of the changes from the main branch.

diffstat:

 sys/dev/usb/ohci.c  |  20 ++++++++++++------
 sys/dev/usb/usbdi.c |  57 ++++++++++++++++++++++++++++------------------------
 2 files changed, 44 insertions(+), 33 deletions(-)

diffs (260 lines):

diff -r 1bbd8a0ed827 -r fc03e2e47194 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Thu Dec 08 10:41:28 2011 +0000
+++ b/sys/dev/usb/ohci.c        Thu Dec 08 20:21:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.218.6.2.2.6 2011/12/08 10:22:40 mrg Exp $   */
+/*     $NetBSD: ohci.c,v 1.218.6.2.2.7 2011/12/08 20:21:31 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.6 2011/12/08 10:22:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.2.2.7 2011/12/08 20:21:31 mrg Exp $");
 
 #include "opt_usb.h"
 
@@ -1900,7 +1900,7 @@
 {
        ohci_soft_ed_t *p;
 
-       KASSERT(mutex_owned(&sc->sc_lock));
+       KASSERT(1 || mutex_owned(&sc->sc_lock));
 
        /* XXX */
        for (p = head; p != NULL && p->next != sed; p = p->next)
@@ -1969,7 +1969,7 @@
 {
        int h = HASH(sitd->physaddr);
 
-       KASSERT(1 || mutex_owned(&sc->sc_lock));
+       KASSERT(mutex_owned(&sc->sc_lock));
 
        DPRINTFN(10,("ohci_hash_add_itd: sitd=%p physaddr=0x%08lx\n",
                    sitd, (u_long)sitd->physaddr));
@@ -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;
@@ -2249,7 +2251,7 @@
        ohci_softc_t *sc = pipe->device->bus->hci_private;
        ohci_soft_ed_t *sed = opipe->sed;
 
-       KASSERT(mutex_owned(&sc->sc_lock));
+       KASSERT(1 || mutex_owned(&sc->sc_lock));
 
 #ifdef DIAGNOSTIC
        sed->ed.ed_flags |= HTOO32(OHCI_ED_SKIP);
@@ -3433,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",
@@ -3464,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",
@@ -3643,11 +3649,11 @@
        ohci_softc_t *sc = pipe->device->bus->hci_private;
 
        DPRINTF(("ohci_device_isoc_close: pipe=%p\n", pipe));
-       mutex_enter(&sc->sc_lock);
+       //mutex_enter(&sc->sc_lock);
        ohci_close_pipe(pipe, sc->sc_isoc_head);
 #ifdef DIAGNOSTIC
        opipe->tail.itd->isdone = 1;
 #endif
-       mutex_exit(&sc->sc_lock);
+       //mutex_exit(&sc->sc_lock);
        ohci_free_sitd(sc, opipe->tail.itd);
 }
diff -r 1bbd8a0ed827 -r fc03e2e47194 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Thu Dec 08 10:41:28 2011 +0000
+++ b/sys/dev/usb/usbdi.c       Thu Dec 08 20:21:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.134.2.1.2.2 2011/12/08 10:22:40 mrg Exp $  */
+/*     $NetBSD: usbdi.c,v 1.134.2.1.2.3 2011/12/08 20:21:31 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.2 2011/12/08 10:22:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.1.2.3 2011/12/08 20:21:31 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usb.h"
@@ -229,6 +229,8 @@
 usbd_status
 usbd_close_pipe(usbd_pipe_handle pipe)
 {
+       //int s;
+
 #ifdef DIAGNOSTIC
        if (pipe == NULL) {
                printf("usbd_close_pipe: pipe==NULL\n");
@@ -236,6 +238,7 @@
        }
 #endif
 
+       //usbd_lock_pipe(pipe);
        if (--pipe->refcnt != 0)
                return (USBD_NORMAL_COMPLETION);
        if (! SIMPLEQ_EMPTY(&pipe->queue))
@@ -243,6 +246,7 @@
        LIST_REMOVE(pipe, next);
        pipe->endpoint->refcnt--;
        pipe->methods->close(pipe);
+       //usbd_lock_pipe(pipe);
        if (pipe->intrxfer != NULL)
                usbd_free_xfer(pipe->intrxfer);
        free(pipe, M_USB);
@@ -310,17 +314,17 @@
        /* Sync transfer, wait for completion. */
        if (err != USBD_IN_PROGRESS)
                return (err);
-       usbd_lock(pipe->lock);
+       usbd_lock_pipe(pipe);
        if (!xfer->done) {
                if (pipe->device->bus->use_polling)
                        panic("usbd_transfer: not done");
-               if (pipe->lock) {
+
+               if (pipe->lock)
                        cv_wait(&xfer->cv, pipe->lock);
-               } else {
+               else
                        tsleep(xfer, PRIBIO, "usbsyn", 0);
-               }
        }
-       usbd_unlock(pipe->lock);
+       usbd_unlock_pipe(pipe);
        return (xfer->status);
 }
 
@@ -537,9 +541,9 @@
                return (USBD_NORMAL_COMPLETION);
        }
 #endif
-       usbd_lock(pipe->lock);
+       usbd_lock_pipe(pipe);
        err = usbd_ar_pipe(pipe);
-       usbd_unlock(pipe->lock);
+       usbd_unlock_pipe(pipe);
        if (pipe->intrxfer != intrxfer)
                usbd_free_xfer(intrxfer);
        return (err);
@@ -727,7 +731,7 @@
 {
        usbd_xfer_handle xfer;
 
-       KASSERT(pipe->lock == NULL || mutex_owned(pipe->lock));
+       KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
 
        DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe));
 #ifdef USB_DEBUG
@@ -740,11 +744,11 @@
                DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n",
                            pipe, xfer, pipe->methods));
                /* Make the HC abort it (and invoke the callback). */
-               if (pipe->lock)
-                       mutex_exit(pipe->lock);
+               if (pipe->device->bus->lock)
+                       mutex_exit(pipe->device->bus->lock);
                pipe->methods->abort(xfer);
-               if (pipe->lock)
-                       mutex_enter(pipe->lock);
+               if (pipe->device->bus->lock)
+                       mutex_enter(pipe->device->bus->lock);
                /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
        }
        pipe->aborting = 0;
@@ -765,7 +769,7 @@
        DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
                     "actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
 
-       KASSERT(pipe->lock == NULL || mutex_owned(pipe->lock));
+       KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
 
 #ifdef DIAGNOSTIC
        if (xfer->busy_free != XFER_ONQU) {
@@ -842,18 +846,19 @@
        } else {
                pipe->methods->done(xfer);
                if (xfer->callback) {
-                       if (pipe->lock) mutex_exit(pipe->lock);
+                       if (pipe->device->bus->lock)
+                               mutex_exit(pipe->device->bus->lock);
                        xfer->callback(xfer, xfer->priv, xfer->status);
-                       if (pipe->lock) mutex_enter(pipe->lock);
+                       if (pipe->device->bus->lock)
+                               mutex_enter(pipe->device->bus->lock);
                }
        }
 
        if (sync && !polling) {
-               if (pipe->lock) {
+               if (pipe->device->bus->lock)
                        cv_broadcast(&xfer->cv);
-               } else {
+               else
                        wakeup(xfer);
-               }
        }
 
        if (!repeat) {
@@ -875,7 +880,7 @@
        DPRINTFN(5,("usb_insert_transfer: pipe=%p running=%d timeout=%d\n",
                    pipe, pipe->running, xfer->timeout));
 
-       //KASSERT(pipe->lock == NULL || mutex_owned(pipe->lock));
+       //KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
 
 #ifdef DIAGNOSTIC
        if (xfer->busy_free != XFER_BUSY) {
@@ -915,7 +920,7 @@
        }
 #endif
 
-       KASSERT(pipe->lock == NULL || mutex_owned(pipe->lock));
+       KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
 
        /* Get next request in queue. */
        xfer = SIMPLEQ_FIRST(&pipe->queue);
@@ -923,11 +928,11 @@
        if (xfer == NULL) {
                pipe->running = 0;
        } else {
-               if (pipe->lock)
-                       mutex_exit(pipe->lock);
+               if (pipe->device->bus->lock)
+                       mutex_exit(pipe->device->bus->lock);
                err = pipe->methods->start(xfer);
-               if (pipe->lock)
-                       mutex_enter(pipe->lock);
+               if (pipe->device->bus->lock)
+                       mutex_enter(pipe->device->bus->lock);
                if (err != USBD_IN_PROGRESS) {
                        printf("usbd_start_next: error=%d\n", err);
                        pipe->running = 0;



Home | Main Index | Thread Index | Old Index