Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Change the internal API to allow DMA buffers to ...



details:   https://anonhg.NetBSD.org/src/rev/2c113739d1b2
branches:  trunk
changeset: 476195:2c113739d1b2
user:      augustss <augustss%NetBSD.org@localhost>
date:      Thu Sep 09 12:26:43 1999 +0000

description:
Change the internal API to allow DMA buffers to be pre-allocated by
the device driver instead of happening automagically in the HC driver.
This affects both the HC-USBD interface as well as the USBD-device
interface.
This change will allow DMA buffers to be reused e.g. in isochronous
traffic.

Add isochronous support to the UHCI driver (not for OHCI yet).

diffstat:

 sys/dev/usb/files.usb    |    4 +-
 sys/dev/usb/ohci.c       |   67 +++++-
 sys/dev/usb/ucom.c       |    6 +-
 sys/dev/usb/ugen.c       |    6 +-
 sys/dev/usb/uhci.c       |  448 ++++++++++++++++++++++++++++++++--------------
 sys/dev/usb/ulpt.c       |    7 +-
 sys/dev/usb/umass.c      |    7 +-
 sys/dev/usb/umodem.c     |   29 +-
 sys/dev/usb/usb_mem.c    |    4 +-
 sys/dev/usb/usb_mem.h    |    7 +-
 sys/dev/usb/usb_subr.c   |    4 +-
 sys/dev/usb/usbdi.c      |  169 +++++++++-------
 sys/dev/usb/usbdi.h      |   20 +-
 sys/dev/usb/usbdi_util.c |    8 +-
 sys/dev/usb/usbdivar.h   |   51 ++++-
 15 files changed, 535 insertions(+), 302 deletions(-)

diffs (truncated from 1666 to 300 lines):

diff -r 00470fb801be -r 2c113739d1b2 sys/dev/usb/files.usb
--- a/sys/dev/usb/files.usb     Thu Sep 09 10:24:39 1999 +0000
+++ b/sys/dev/usb/files.usb     Thu Sep 09 12:26:43 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.usb,v 1.10 1999/08/23 07:07:47 augustss Exp $
+#      $NetBSD: files.usb,v 1.11 1999/09/09 12:26:43 augustss Exp $
 #
 # Config file and device description for machine-independent USB code.
 # Included by ports that need it.  Ports that use it must provide
@@ -64,5 +64,3 @@
 device ums: wsmousedev
 attach ums at uhub
 file   dev/usb/ums.c                   ums
-
-
diff -r 00470fb801be -r 2c113739d1b2 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Thu Sep 09 10:24:39 1999 +0000
+++ b/sys/dev/usb/ohci.c        Thu Sep 09 12:26:43 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.41 1999/09/05 21:22:38 augustss Exp $       */
+/*     $NetBSD: ohci.c,v 1.42 1999/09/09 12:26:44 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -115,6 +115,9 @@
 void           ohci_hash_rem_td __P((ohci_softc_t *, ohci_soft_td_t *));
 ohci_soft_td_t *ohci_hash_find_td __P((ohci_softc_t *, ohci_physaddr_t));
 
+usbd_status    ohci_allocm __P((struct usbd_bus *, usb_dma_t *, u_int32_t));
+void           ohci_freem __P((struct usbd_bus *, usb_dma_t *));
+
 usbd_status    ohci_root_ctrl_transfer __P((usbd_request_handle));
 usbd_status    ohci_root_ctrl_start __P((usbd_request_handle));
 void           ohci_root_ctrl_abort __P((usbd_request_handle));
@@ -210,54 +213,56 @@
 
 #define OHCI_INTR_ENDPT 1
 
-struct usbd_methods ohci_root_ctrl_methods = { 
+struct usbd_bus_methods ohci_bus_methods = {
+       ohci_open,
+       ohci_poll,
+       ohci_allocm,
+       ohci_freem,
+};
+
+struct usbd_pipe_methods ohci_root_ctrl_methods = {    
        ohci_root_ctrl_transfer,
        ohci_root_ctrl_start,
        ohci_root_ctrl_abort,
        ohci_root_ctrl_close,
        ohci_noop,
        0,
-       0,
 };
 
-struct usbd_methods ohci_root_intr_methods = { 
+struct usbd_pipe_methods ohci_root_intr_methods = {    
        ohci_root_intr_transfer,
        ohci_root_intr_start,
        ohci_root_intr_abort,
        ohci_root_intr_close,
        ohci_noop,
        ohci_root_intr_done,
-       0,
 };
 
-struct usbd_methods ohci_device_ctrl_methods = {       
+struct usbd_pipe_methods ohci_device_ctrl_methods = {  
        ohci_device_ctrl_transfer,
        ohci_device_ctrl_start,
        ohci_device_ctrl_abort,
        ohci_device_ctrl_close,
        ohci_noop,
        ohci_device_ctrl_done,
-       0,
 };
 
-struct usbd_methods ohci_device_intr_methods = {       
+struct usbd_pipe_methods ohci_device_intr_methods = {  
        ohci_device_intr_transfer,
        ohci_device_intr_start,
        ohci_device_intr_abort,
        ohci_device_intr_close,
        ohci_device_clear_toggle,
        ohci_device_intr_done,
-       0,
 };
 
-struct usbd_methods ohci_device_bulk_methods = {       
+struct usbd_pipe_methods ohci_device_bulk_methods = {  
        ohci_device_bulk_transfer,
        ohci_device_bulk_start,
        ohci_device_bulk_abort,
        ohci_device_bulk_close,
        ohci_device_clear_toggle,
        ohci_device_bulk_done,
-       0,
 };
 
 ohci_soft_ed_t *
@@ -513,9 +518,8 @@
 #endif
        
        /* Set up the bus struct. */
-       sc->sc_bus.open_pipe = ohci_open;
+       sc->sc_bus.methods = &ohci_bus_methods;
        sc->sc_bus.pipe_size = sizeof(struct ohci_pipe);
-       sc->sc_bus.do_poll = ohci_poll;
 
        powerhook_establish(ohci_power, sc);
 
@@ -530,6 +534,27 @@
        return (r);
 }
 
+usbd_status
+ohci_allocm(bus, dma, size)
+       struct usbd_bus *bus;
+       usb_dma_t *dma;
+       u_int32_t size;
+{
+       struct ohci_softc *sc = (struct ohci_softc *)bus;
+
+       return (usb_allocmem(sc->sc_dmatag, size, 0, dma));
+}
+
+void
+ohci_freem(bus, dma)
+       struct usbd_bus *bus;
+       usb_dma_t *dma;
+{
+       struct ohci_softc *sc = (struct ohci_softc *)bus;
+
+       usb_freemem(sc->sc_dmatag, dma);
+}
+
 #if !defined(__OpenBSD__)
 void
 ohci_power(why, v)
@@ -792,7 +817,7 @@
        DPRINTFN(10,("ohci_ctrl_done: reqh=%p\n", reqh));
 
 #ifdef DIAGNOSTIC
-       if (!reqh->isreq) {
+       if (!(reqh->rqflags & URQ_REQUEST)) {
                panic("ohci_ctrl_done: not a request\n");
        }
 #endif
@@ -1566,9 +1591,11 @@
        usbd_status r;
        u_int32_t v;
 
-       if (!reqh->isreq)
+#ifdef DIAGNOSTIC
+       if (!(reqh->rqflags & URQ_REQUEST))
                /* XXX panic */
                return (USBD_INVAL);
+#endif
        req = &reqh->request;
        buf = reqh->buffer;
 
@@ -1946,11 +1973,13 @@
        ohci_softc_t *sc = (ohci_softc_t *)reqh->pipe->device->bus;
        usbd_status r;
 
-       if (!reqh->isreq) {
+#ifdef DIAGNOSTIC
+       if (!(reqh->rqflags & URQ_REQUEST)) {
                /* XXX panic */
                printf("ohci_device_ctrl_transfer: not a request\n");
                return (USBD_INVAL);
        }
+#endif
 
        r = ohci_device_request(reqh);
        if (r != USBD_NORMAL_COMPLETION)
@@ -2029,7 +2058,7 @@
        int s, len, isread, endpt;
 
 #ifdef DIAGNOSTIC
-       if (reqh->isreq) {
+       if (reqh->rqflags & URQ_REQUEST) {
                /* XXX panic */
                printf("ohci_device_bulk_start: a request\n");
                return (USBD_INVAL);
@@ -2184,8 +2213,10 @@
                     "flags=%d priv=%p\n",
                 reqh, reqh->buffer, reqh->length, reqh->flags, reqh->priv));
 
-       if (reqh->isreq)
+#ifdef DIAGNOSTIC
+       if (reqh->rqflags & URQ_REQUEST)
                panic("ohci_device_intr_transfer: a request\n");
+#endif
 
        len = reqh->length;
        dmap = &opipe->u.intr.datadma;
diff -r 00470fb801be -r 2c113739d1b2 sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c        Thu Sep 09 10:24:39 1999 +0000
+++ b/sys/dev/usb/ucom.c        Thu Sep 09 12:26:43 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucom.c,v 1.9 1999/08/14 14:49:31 augustss Exp $        */
+/*     $NetBSD: ucom.c,v 1.10 1999/09/09 12:26:44 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -37,8 +37,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <dev/usb/usb_port.h>
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
@@ -97,7 +95,7 @@
        id = usbd_get_interface_descriptor(uaa->iface);
        if (id &&
            id->bInterfaceClass != UCLASS_CDC ||
-           id->bInterfaceSubClass != USUBCLASS_MODEM)
+           id->bInterfaceSubClass != USUBCLASS_ABSTRACT_CONTROL_MODEL)
                return (UMATCH_NONE);
        return (UMATCH_IFACECLASS_IFACESUBCLASS);
 }
diff -r 00470fb801be -r 2c113739d1b2 sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c        Thu Sep 09 10:24:39 1999 +0000
+++ b/sys/dev/usb/ugen.c        Thu Sep 09 12:26:43 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ugen.c,v 1.22 1999/09/05 19:32:18 augustss Exp $       */
+/*     $NetBSD: ugen.c,v 1.23 1999/09/09 12:26:44 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -463,7 +463,7 @@
                }
                break;
        case UE_BULK:
-               reqh = usbd_alloc_request();
+               reqh = usbd_alloc_request(sc->sc_udev);
                if (reqh == 0)
                        return (ENOMEM);
                while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) {
@@ -544,7 +544,7 @@
        DPRINTF(("ugenwrite\n"));
        switch (sce->edesc->bmAttributes & UE_XFERTYPE) {
        case UE_BULK:
-               reqh = usbd_alloc_request();
+               reqh = usbd_alloc_request(sc->sc_udev);
                if (reqh == 0)
                        return (EIO);
                while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) {
diff -r 00470fb801be -r 2c113739d1b2 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c        Thu Sep 09 10:24:39 1999 +0000
+++ b/sys/dev/usb/uhci.c        Thu Sep 09 12:26:43 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci.c,v 1.47 1999/09/05 21:22:39 augustss Exp $       */
+/*     $NetBSD: uhci.c,v 1.48 1999/09/09 12:26:45 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -129,10 +129,8 @@
                } bulk;
                /* Iso pipe */
                struct iso {
-                       u_int bufsize;
-                       u_int nbuf;
-                       usb_dma_t *bufs;
                        uhci_soft_td_t **stds;
+                       int next, inuse;
                } iso;
        } u;
 };
@@ -179,9 +177,14 @@
 void           uhci_remove_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *));
 void           uhci_remove_bulk __P((uhci_softc_t *, uhci_soft_qh_t *));
 int            uhci_str __P((usb_string_descriptor_t *, int, char *));
+usbd_status    uhci_setup_isoc __P((usbd_pipe_handle pipe));
+void           uhci_device_isoc_enter __P((usbd_request_handle));
 
 void           uhci_wakeup_cb __P((usbd_request_handle reqh));
 
+usbd_status    uhci_allocm __P((struct usbd_bus *, usb_dma_t *, u_int32_t));
+void           uhci_freem __P((struct usbd_bus *, usb_dma_t *));
+
 usbd_status    uhci_device_ctrl_transfer __P((usbd_request_handle));
 usbd_status    uhci_device_ctrl_start __P((usbd_request_handle));
 void           uhci_device_ctrl_abort __P((usbd_request_handle));
@@ -205,7 +208,6 @@
 void           uhci_device_isoc_abort __P((usbd_request_handle));
 void           uhci_device_isoc_close __P((usbd_pipe_handle));
 void           uhci_device_isoc_done  __P((usbd_request_handle));
-usbd_status    uhci_device_isoc_setbuf __P((usbd_pipe_handle, u_int, u_int));
 
 usbd_status    uhci_root_ctrl_transfer __P((usbd_request_handle));
 usbd_status    uhci_root_ctrl_start __P((usbd_request_handle));
@@ -254,64 +256,65 @@
 
 #define UHCI_INTR_ENDPT 1
 



Home | Main Index | Thread Index | Old Index