Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys All HCDs were fighting the seriaisation of transfer...



details:   https://anonhg.NetBSD.org/src/rev/a12496ef7d5e
branches:  nick-nhusb
changeset: 334437:a12496ef7d5e
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Mar 17 09:04:53 2016 +0000

description:
All HCDs were fighting the seriaisation of transfers in usbdi.c for isoc
transfers.  Instead allow the HCDs to specify which pipes can handle
removing this serialisation and apply it appropriately.

dwctwo(4) can handle this for all transfer types, but only enable
bulk/isoc for now.

diffstat:

 sys/dev/usb/ehci.c           |  74 +++++++------------------------------------
 sys/dev/usb/ehcivar.h        |  14 ++-----
 sys/dev/usb/ohci.c           |  50 ++++-------------------------
 sys/dev/usb/uhci.c           |  75 +++++++------------------------------------
 sys/dev/usb/uhcivar.h        |  14 ++-----
 sys/dev/usb/usbdi.c          |  12 ++++--
 sys/dev/usb/usbdivar.h       |   3 +-
 sys/external/bsd/dwc2/dwc2.c |  41 +++--------------------
 8 files changed, 56 insertions(+), 227 deletions(-)

diffs (truncated from 704 to 300 lines):

diff -r ea699a1694fb -r a12496ef7d5e sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Thu Mar 17 07:59:45 2016 +0000
+++ b/sys/dev/usb/ehci.c        Thu Mar 17 09:04:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.234.2.91 2016/02/28 09:16:20 skrll Exp $ */
+/*     $NetBSD: ehci.c,v 1.234.2.92 2016/03/17 09:04:53 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.91 2016/02/28 09:16:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.92 2016/03/17 09:04:53 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -209,7 +209,6 @@
 Static int             ehci_device_isoc_init(struct usbd_xfer *);
 Static void            ehci_device_isoc_fini(struct usbd_xfer *);
 Static usbd_status     ehci_device_isoc_transfer(struct usbd_xfer *);
-Static usbd_status     ehci_device_isoc_start(struct usbd_xfer *);
 Static void            ehci_device_isoc_abort(struct usbd_xfer *);
 Static void            ehci_device_isoc_close(struct usbd_pipe *);
 Static void            ehci_device_isoc_done(struct usbd_xfer *);
@@ -217,7 +216,6 @@
 Static int             ehci_device_fs_isoc_init(struct usbd_xfer *);
 Static void            ehci_device_fs_isoc_fini(struct usbd_xfer *);
 Static usbd_status     ehci_device_fs_isoc_transfer(struct usbd_xfer *);
-Static usbd_status     ehci_device_fs_isoc_start(struct usbd_xfer *);
 Static void            ehci_device_fs_isoc_abort(struct usbd_xfer *);
 Static void            ehci_device_fs_isoc_close(struct usbd_pipe *);
 Static void            ehci_device_fs_isoc_done(struct usbd_xfer *);
@@ -366,7 +364,6 @@
        .upm_init =     ehci_device_isoc_init,
        .upm_fini =     ehci_device_isoc_fini,
        .upm_transfer = ehci_device_isoc_transfer,
-       .upm_start =    ehci_device_isoc_start,
        .upm_abort =    ehci_device_isoc_abort,
        .upm_close =    ehci_device_isoc_close,
        .upm_cleartoggle =      ehci_noop,
@@ -377,7 +374,6 @@
        .upm_init =     ehci_device_fs_isoc_init,
        .upm_fini =     ehci_device_fs_isoc_fini,
        .upm_transfer = ehci_device_fs_isoc_transfer,
-       .upm_start =    ehci_device_fs_isoc_start,
        .upm_abort =    ehci_device_fs_isoc_abort,
        .upm_close =    ehci_device_fs_isoc_close,
        .upm_cleartoggle = ehci_noop,
@@ -2066,6 +2062,7 @@
                        goto bad;
                break;
        case UE_ISOCHRONOUS:
+               pipe->up_serialise = false;
                if (speed == EHCI_QH_SPEED_HIGH)
                        pipe->up_methods = &ehci_device_isoc_methods;
                else
@@ -4368,22 +4365,14 @@
 ehci_device_fs_isoc_transfer(struct usbd_xfer *xfer)
 {
        ehci_softc_t *sc = EHCI_XFER2SC(xfer);
-       usbd_status err;
+       usbd_status __diagused err;
 
        mutex_enter(&sc->sc_lock);
        err = usb_insert_transfer(xfer);
        mutex_exit(&sc->sc_lock);
 
-       if (err && err != USBD_IN_PROGRESS)
-               return err;
-
-       return ehci_device_fs_isoc_start(xfer);
-}
-
-Static usbd_status
-ehci_device_fs_isoc_start(struct usbd_xfer *xfer)
-{
-       ehci_softc_t *sc = EHCI_XFER2SC(xfer);
+       KASSERT(err == USBD_NORMAL_COMPLETION);
+
        struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);;
        struct usbd_device *dev = xfer->ux_pipe->up_dev;;
        struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
@@ -4399,16 +4388,6 @@
        sitd = NULL;
        total_length = 0;
 
-       /*
-        * To allow continuous transfers, above we start all transfers
-        * immediately. However, we're still going to get usbd_start_next call
-        * this when another xfer completes. So, check if this is already
-        * in progress or not
-        */
-
-       if (exfer->ex_isrunning) {
-               return USBD_IN_PROGRESS;
-       }
 
        USBHIST_LOG(ehcidebug, "xfer %p len %d flags %d",
            xfer, xfer->ux_length, xfer->ux_flags, 0);
@@ -4604,8 +4583,6 @@
        epipe->isoc.cur_xfers++;
        epipe->isoc.next_frame = frindex;
 
-       exfer->ex_isrunning = true;
-
        ehci_add_intr_list(sc, exfer);
        xfer->ux_status = USBD_IN_PROGRESS;
 
@@ -4646,10 +4623,7 @@
        KASSERT(mutex_owned(&sc->sc_lock));
 
        epipe->isoc.cur_xfers--;
-       if (exfer->ex_isrunning) {
-               ehci_remove_sitd_chain(sc, exfer->ex_itdstart);
-               exfer->ex_isrunning = false;
-       }
+       ehci_remove_sitd_chain(sc, exfer->ex_itdstart);
 
        usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
            BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
@@ -4681,7 +4655,6 @@
        KASSERT(exfer->ex_isdone);
 
        exfer->ex_type = EX_ISOC;
-       exfer->ex_isrunning = false;
 
        /*
         * Step 1: Allocate and initialize itds, how many do we need?
@@ -4770,22 +4743,15 @@
 ehci_device_isoc_transfer(struct usbd_xfer *xfer)
 {
        ehci_softc_t *sc = EHCI_XFER2SC(xfer);
-       usbd_status err;
+       usbd_status __diagused err;
 
        mutex_enter(&sc->sc_lock);
        err = usb_insert_transfer(xfer);
        mutex_exit(&sc->sc_lock);
-       if (err && err != USBD_IN_PROGRESS)
-               return err;
-
-       return ehci_device_isoc_start(xfer);
-}
-
-Static usbd_status
-ehci_device_isoc_start(struct usbd_xfer *xfer)
-{
+
+       KASSERT(err == USBD_NORMAL_COMPLETION);
+
        struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
-       ehci_softc_t *sc = EHCI_XFER2SC(xfer);
        struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
        ehci_soft_itd_t *itd, *prev;
        usb_dma_t *dma_buf;
@@ -4801,17 +4767,6 @@
        trans_count = 0;
        total_length = 0;
 
-       /*
-        * To allow continuous transfers, above we start all transfers
-        * immediately. However, we're still going to get usbd_start_next call
-        * this when another xfer completes. So, check if this is already
-        * in progress or not
-        */
-
-       if (exfer->ex_isrunning) {
-               return USBD_IN_PROGRESS;
-       }
-
        USBHIST_LOG(ehcidebug, "xfer %p flags %d", xfer, xfer->ux_flags, 0, 0);
 
        if (sc->sc_dying)
@@ -5027,8 +4982,6 @@
        epipe->isoc.cur_xfers++;
        epipe->isoc.next_frame = frindex;
 
-       exfer->ex_isrunning = true;
-
        ehci_add_intr_list(sc, exfer);
        xfer->ux_status = USBD_IN_PROGRESS;
 
@@ -5069,10 +5022,7 @@
        KASSERT(mutex_owned(&sc->sc_lock));
 
        epipe->isoc.cur_xfers--;
-       if (exfer->ex_isrunning) {
-               ehci_remove_itd_chain(sc, exfer->ex_sitdstart);
-               exfer->ex_isrunning = false;
-       }
+       ehci_remove_itd_chain(sc, exfer->ex_sitdstart);
        usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
            BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 }
diff -r ea699a1694fb -r a12496ef7d5e sys/dev/usb/ehcivar.h
--- a/sys/dev/usb/ehcivar.h     Thu Mar 17 07:59:45 2016 +0000
+++ b/sys/dev/usb/ehcivar.h     Thu Mar 17 09:04:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehcivar.h,v 1.42.14.22 2016/01/10 16:49:29 skrll Exp $ */
+/*     $NetBSD: ehcivar.h,v 1.42.14.23 2016/03/17 09:04:53 skrll Exp $ */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -103,14 +103,10 @@
                EX_ISOC,
                EX_FS_ISOC
        } ex_type;
-       union {
-               /* ctrl/bulk/intr */
-               struct {
-                       ehci_soft_qtd_t **ex_sqtds;
-                       size_t ex_nsqtd;
-               };
-               /* isoc */
-               bool ex_isrunning;
+       /* ctrl/bulk/intr */
+       struct {
+               ehci_soft_qtd_t **ex_sqtds;
+               size_t ex_nsqtd;
        };
        union {
                /* ctrl */
diff -r ea699a1694fb -r a12496ef7d5e sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Thu Mar 17 07:59:45 2016 +0000
+++ b/sys/dev/usb/ohci.c        Thu Mar 17 09:04:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.254.2.58 2016/03/13 07:11:01 skrll Exp $    */
+/*     $NetBSD: ohci.c,v 1.254.2.59 2016/03/17 09:04:53 skrll Exp $    */
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.58 2016/03/13 07:11:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.59 2016/03/17 09:04:53 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -74,7 +74,7 @@
 #ifndef OHCI_DEBUG
 #define ohcidebug 0
 #else
-static int ohcidebug = 0;
+static int ohcidebug = 10;
 
 SYSCTL_SETUP(sysctl_hw_ohci_setup, "sysctl hw.ohci setup")
 {
@@ -205,7 +205,6 @@
 Static int             ohci_device_isoc_init(struct usbd_xfer *);
 Static void            ohci_device_isoc_fini(struct usbd_xfer *);
 Static usbd_status     ohci_device_isoc_transfer(struct usbd_xfer *);
-Static usbd_status     ohci_device_isoc_start(struct usbd_xfer *);
 Static void            ohci_device_isoc_abort(struct usbd_xfer *);
 Static void            ohci_device_isoc_close(struct usbd_pipe *);
 Static void            ohci_device_isoc_done(struct usbd_xfer *);
@@ -337,7 +336,6 @@
        .upm_init =     ohci_device_isoc_init,
        .upm_fini =     ohci_device_isoc_fini,
        .upm_transfer = ohci_device_isoc_transfer,
-       .upm_start =    ohci_device_isoc_start,
        .upm_abort =    ohci_device_isoc_abort,
        .upm_close =    ohci_device_isoc_close,
        .upm_cleartoggle =      ohci_noop,
@@ -2218,6 +2216,7 @@
                                goto bad;
                        break;
                case UE_ISOCHRONOUS:
+                       pipe->up_serialise = false;
                        pipe->up_methods = &ohci_device_isoc_methods;
                        return ohci_setup_isoc(pipe);
                case UE_BULK:
@@ -3541,7 +3540,7 @@
 ohci_device_isoc_transfer(struct usbd_xfer *xfer)
 {
        ohci_softc_t *sc = OHCI_XFER2SC(xfer);
-       usbd_status err;
+       usbd_status __diagused err;
 
        OHCIHIST_FUNC(); OHCIHIST_CALLED();
 
@@ -3552,20 +3551,13 @@
        err = usb_insert_transfer(xfer);
        mutex_exit(&sc->sc_lock);
 
-       /* bail out on error, */
-       if (err && err != USBD_IN_PROGRESS)
-               return err;
-
-       /* XXX should check inuse here */
+       KASSERT(err == USBD_NORMAL_COMPLETION);
 
        /* insert into schedule, */
        ohci_device_isoc_enter(xfer);
 
        /* and start if the pipe wasn't running */
-       if (!err)



Home | Main Index | Thread Index | Old Index