Source-Changes-HG archive

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

[src/trunk]: src/sys Change the usb_mem API to take a bus_dma_tag_t in usb_al...



details:   https://anonhg.NetBSD.org/src/rev/7a4f08369019
branches:  trunk
changeset: 1029085:7a4f08369019
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Dec 21 09:51:22 2021 +0000

description:
Change the usb_mem API to take a bus_dma_tag_t in usb_allocmem instead of
a struct usbd_bus *.

This allows an HCD to use more than one tag.

diffstat:

 sys/arch/mips/adm5120/dev/ahci.c           |   8 +++---
 sys/dev/usb/ehci.c                         |  21 ++++++++-------
 sys/dev/usb/ohci.c                         |  20 +++++++-------
 sys/dev/usb/uhci.c                         |  14 +++++-----
 sys/dev/usb/usb_mem.c                      |   9 +++---
 sys/dev/usb/usb_mem.h                      |   8 +++---
 sys/dev/usb/usbdi.c                        |   8 +++---
 sys/dev/usb/xhci.c                         |  38 +++++++++++++++---------------
 sys/external/bsd/dwc2/dist/dwc2_hcd.c      |  13 ++++-----
 sys/external/bsd/dwc2/dist/dwc2_hcdddma.c  |  18 +++++++-------
 sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c |   6 ++--
 sys/external/bsd/dwc2/dwc2.c               |   9 +++---
 12 files changed, 85 insertions(+), 87 deletions(-)

diffs (truncated from 710 to 300 lines):

diff -r b45c3792be81 -r 7a4f08369019 sys/arch/mips/adm5120/dev/ahci.c
--- a/sys/arch/mips/adm5120/dev/ahci.c  Tue Dec 21 09:25:17 2021 +0000
+++ b/sys/arch/mips/adm5120/dev/ahci.c  Tue Dec 21 09:51:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahci.c,v 1.27 2021/12/07 06:49:15 skrll Exp $  */
+/*     $NetBSD: ahci.c,v 1.28 2021/12/21 09:51:22 skrll Exp $  */
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.27 2021/12/07 06:49:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.28 2021/12/21 09:51:22 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -877,7 +877,7 @@
                td1 = (struct admhcd_td *)KSEG1ADDR(&td_v[1]);
                td2 = (struct admhcd_td *)KSEG1ADDR(&td_v[2]);
                td3 = (struct admhcd_td *)KSEG1ADDR(&td_v[3]);
-               err = usb_allocmem(&sc->sc_bus,
+               err = usb_allocmem(sc->sc_bus.ub_dmatag,
                        sizeof(usb_device_request_t),
                        0, USBMALLOC_COHERENT, &reqdma);
                if (err)
@@ -990,7 +990,7 @@
        usb_transfer_complete(xfer);
        mutex_exit(&sc->sc_lock);
 
-       usb_freemem(&sc->sc_bus, &reqdma);
+       usb_freemem(&reqdma);
 
        return USBD_NORMAL_COMPLETION;
 }
diff -r b45c3792be81 -r 7a4f08369019 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Tue Dec 21 09:25:17 2021 +0000
+++ b/sys/dev/usb/ehci.c        Tue Dec 21 09:51:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.292 2021/12/21 08:49:03 skrll Exp $ */
+/*     $NetBSD: ehci.c,v 1.293 2021/12/21 09:51:22 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.292 2021/12/21 08:49:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.293 2021/12/21 09:51:22 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -517,7 +517,8 @@
        case 2: sc->sc_flsize = 256; break;
        case 3: return EIO;
        }
-       err = usb_allocmem(&sc->sc_bus, sc->sc_flsize * sizeof(ehci_link_t),
+       err = usb_allocmem(sc->sc_bus.ub_dmatag,
+           sc->sc_flsize * sizeof(ehci_link_t),
            EHCI_FLALIGN_ALIGN, USBMALLOC_COHERENT, &sc->sc_fldma);
        if (err)
                return err;
@@ -654,7 +655,7 @@
        ehci_free_sqh(sc, sc->sc_async_head);
 #endif
  bad1:
-       usb_freemem(&sc->sc_bus, &sc->sc_fldma);
+       usb_freemem(&sc->sc_fldma);
        return err;
 }
 
@@ -1999,7 +2000,7 @@
 
        switch (xfertype) {
        case UE_CONTROL:
-               err = usb_allocmem(&sc->sc_bus, sizeof(usb_device_request_t),
+               err = usb_allocmem(sc->sc_bus.ub_dmatag, sizeof(usb_device_request_t),
                    0, USBMALLOC_COHERENT, &epipe->ctrl.reqdma);
 #ifdef EHCI_DEBUG
                if (err)
@@ -2796,7 +2797,7 @@
                mutex_exit(&sc->sc_lock);
 
                usb_dma_t dma;
-               int err = usb_allocmem(&sc->sc_bus,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag,
                    EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
                    EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
 
@@ -2852,7 +2853,7 @@
                mutex_exit(&sc->sc_lock);
 
                usb_dma_t dma;
-               int err = usb_allocmem(&sc->sc_bus,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag,
                    EHCI_SQTD_SIZE * EHCI_SQTD_CHUNK,
                    EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
 
@@ -3112,7 +3113,7 @@
                mutex_exit(&sc->sc_lock);
 
                usb_dma_t dma;
-               int err = usb_allocmem(&sc->sc_bus,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag,
                    EHCI_ITD_SIZE * EHCI_ITD_CHUNK,
                    EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
 
@@ -3166,7 +3167,7 @@
                mutex_exit(&sc->sc_lock);
 
                usb_dma_t dma;
-               int err = usb_allocmem(&sc->sc_bus,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag,
                    EHCI_SITD_SIZE * EHCI_SITD_CHUNK,
                    EHCI_PAGE_SIZE, USBMALLOC_COHERENT, &dma);
 
@@ -3772,7 +3773,7 @@
 
        ehci_close_pipe(pipe, sc->sc_async_head);
 
-       usb_freemem(&sc->sc_bus, &epipe->ctrl.reqdma);
+       usb_freemem(&epipe->ctrl.reqdma);
 }
 
 /*
diff -r b45c3792be81 -r 7a4f08369019 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Tue Dec 21 09:25:17 2021 +0000
+++ b/sys/dev/usb/ohci.c        Tue Dec 21 09:51:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.317 2021/06/24 23:01:03 mrg Exp $   */
+/*     $NetBSD: ohci.c,v 1.318 2021/12/21 09:51:22 skrll Exp $ */
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.317 2021/06/24 23:01:03 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.318 2021/12/21 09:51:22 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -388,7 +388,7 @@
        mutex_destroy(&sc->sc_intr_lock);
 
        if (sc->sc_hcca != NULL)
-               usb_freemem(&sc->sc_bus, &sc->sc_hccadma);
+               usb_freemem(&sc->sc_hccadma);
        pool_cache_destroy(sc->sc_xferpool);
        cv_destroy(&sc->sc_abort_cv);
 
@@ -409,7 +409,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               int err = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_SED_SIZE * OHCI_SED_CHUNK,
                    OHCI_ED_ALIGN, 0 /*!USBMALLOC_COHERENT*/, &dma);
                if (err)
                        return NULL;
@@ -467,7 +467,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               int err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_STD_SIZE * OHCI_STD_CHUNK,
                   OHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -719,7 +719,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               int err = usb_allocmem(&sc->sc_bus, OHCI_SITD_SIZE * OHCI_SITD_CHUNK,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_SITD_SIZE * OHCI_SITD_CHUNK,
                    OHCI_ITD_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -826,7 +826,7 @@
 
        /* XXX determine alignment by R/W */
        /* Allocate the HCCA area. */
-       err = usb_allocmem(&sc->sc_bus, OHCI_HCCA_SIZE, OHCI_HCCA_ALIGN,
+       err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_HCCA_SIZE,        OHCI_HCCA_ALIGN,
            USBMALLOC_COHERENT, &sc->sc_hccadma);
        if (err) {
                sc->sc_hcca = NULL;
@@ -1073,7 +1073,7 @@
  bad2:
        ohci_free_sed(sc, sc->sc_ctrl_head);
  bad1:
-       usb_freemem(&sc->sc_bus, &sc->sc_hccadma);
+       usb_freemem(&sc->sc_hccadma);
        sc->sc_hcca = NULL;
        return err;
 }
@@ -2140,7 +2140,7 @@
                switch (xfertype) {
                case UE_CONTROL:
                        pipe->up_methods = &ohci_device_ctrl_methods;
-                       int error = usb_allocmem(&sc->sc_bus,
+                       int error = usb_allocmem(sc->sc_bus.ub_dmatag,
                            sizeof(usb_device_request_t), 0,
                            USBMALLOC_COHERENT, &opipe->ctrl.reqdma);
                        if (error)
@@ -2989,7 +2989,7 @@
        ohci_close_pipe(pipe, sc->sc_ctrl_head);
        ohci_free_std_locked(sc, opipe->tail.td);
 
-       usb_freemem(&sc->sc_bus, &opipe->ctrl.reqdma);
+       usb_freemem(&opipe->ctrl.reqdma);
 }
 
 /************************/
diff -r b45c3792be81 -r 7a4f08369019 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c        Tue Dec 21 09:25:17 2021 +0000
+++ b/sys/dev/usb/uhci.c        Tue Dec 21 09:51:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci.c,v 1.307 2021/10/04 21:02:39 andvar Exp $        */
+/*     $NetBSD: uhci.c,v 1.308 2021/12/21 09:51:22 skrll Exp $ */
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.307 2021/10/04 21:02:39 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.308 2021/12/21 09:51:22 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -453,7 +453,7 @@
        uhci_reset(sc);
 
        /* Allocate and initialize real frame array. */
-       int err = usb_allocmem(&sc->sc_bus,
+       int err = usb_allocmem(sc->sc_bus.ub_dmatag,
            UHCI_FRAMELIST_COUNT * sizeof(uhci_physaddr_t),
            UHCI_FRAMELIST_ALIGN, USBMALLOC_COHERENT, &sc->sc_dma);
        if (err)
@@ -1844,7 +1844,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               int err = usb_allocmem(&sc->sc_bus, UHCI_STD_SIZE * UHCI_STD_CHUNK,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag, UHCI_STD_SIZE * UHCI_STD_CHUNK,
                    UHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -1910,7 +1910,7 @@
                DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                mutex_exit(&sc->sc_lock);
 
-               int err = usb_allocmem(&sc->sc_bus, UHCI_SQH_SIZE * UHCI_SQH_CHUNK,
+               int err = usb_allocmem(sc->sc_bus.ub_dmatag, UHCI_SQH_SIZE * UHCI_SQH_CHUNK,
                    UHCI_QH_ALIGN, USBMALLOC_COHERENT, &dma);
                if (err)
                        return NULL;
@@ -2823,7 +2823,7 @@
        uhci_free_std_locked(sc, upipe->ctrl.setup);
        uhci_free_std_locked(sc, upipe->ctrl.stat);
 
-       usb_freemem(&sc->sc_bus, &upipe->ctrl.reqdma);
+       usb_freemem(&upipe->ctrl.reqdma);
 }
 
 /* Abort a device interrupt request. */
@@ -3505,7 +3505,7 @@
                                uhci_free_std(sc, upipe->ctrl.setup);
                                goto bad;
                        }
-                       int err = usb_allocmem(&sc->sc_bus,
+                       int err = usb_allocmem(sc->sc_bus.ub_dmatag,
                            sizeof(usb_device_request_t), 0,
                            USBMALLOC_COHERENT, &upipe->ctrl.reqdma);
                        if (err) {
diff -r b45c3792be81 -r 7a4f08369019 sys/dev/usb/usb_mem.c
--- a/sys/dev/usb/usb_mem.c     Tue Dec 21 09:25:17 2021 +0000
+++ b/sys/dev/usb/usb_mem.c     Tue Dec 21 09:51:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_mem.c,v 1.83 2021/12/21 09:25:17 skrll Exp $       */
+/*     $NetBSD: usb_mem.c,v 1.84 2021/12/21 09:51:22 skrll Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.83 2021/12/21 09:25:17 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.84 2021/12/21 09:51:22 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -262,10 +262,9 @@
 }



Home | Main Index | Thread Index | Old Index