Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/external/bsd/dwc2 Pull up following revision(s) (requ...



details:   https://anonhg.NetBSD.org/src/rev/b05922e45b77
branches:  netbsd-7
changeset: 800692:b05922e45b77
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Dec 05 16:30:17 2019 +0000

description:
Pull up following revision(s) (requested by skrll in ticket #1716):
        sys/external/bsd/dwc2/dwc2.c: revision 1.60
        sys/external/bsd/dwc2/dwc2.c: revision 1.61
        sys/external/bsd/dwc2/dwc2.c: revision 1.62
        sys/external/bsd/dwc2/dwc2.c: revision 1.63
        sys/external/bsd/dwc2/dwc2.c: revision 1.64
        sys/external/bsd/dwc2/dwc2.c: revision 1.65
        sys/external/bsd/dwc2/dwc2.c: revision 1.66
KNF
Make dwc2debug sysctl'able
Need <sys/sysctl.h> for previous
Use size_t for loop count variable
Calulate the right lenght for isoc transfer and the usb_syncmem
PR/54696: Kernel panic in bus_dma.c on Raspberry Pi 3B/3B+
build fix
Consistency.

diffstat:

 sys/external/bsd/dwc2/dwc2.c |  70 +++++++++++++++++++++++++++++++++----------
 1 files changed, 53 insertions(+), 17 deletions(-)

diffs (135 lines):

diff -r cb70484c0850 -r b05922e45b77 sys/external/bsd/dwc2/dwc2.c
--- a/sys/external/bsd/dwc2/dwc2.c      Thu Dec 05 16:29:23 2019 +0000
+++ b/sys/external/bsd/dwc2/dwc2.c      Thu Dec 05 16:30:17 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwc2.c,v 1.31.2.4 2018/08/25 14:57:35 martin Exp $     */
+/*     $NetBSD: dwc2.c,v 1.31.2.5 2019/12/05 16:30:17 bouyer Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,19 +30,21 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.31.2.4 2018/08/25 14:57:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.31.2.5 2019/12/05 16:30:17 bouyer Exp $");
 
 #include "opt_usb.h"
 
 #include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kmem.h>
+
+#include <sys/cpu.h>
+#include <sys/device.h>
 #include <sys/kernel.h>
-#include <sys/device.h>
-#include <sys/select.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/queue.h>
-#include <sys/cpu.h>
+#include <sys/select.h>
+#include <sys/sysctl.h>
+#include <sys/systm.h>
 
 #include <machine/endian.h>
 
@@ -74,6 +76,33 @@
 } while (0)
 #define        DPRINTF(...)    DPRINTFN(1, __VA_ARGS__)
 int dwc2debug = 0;
+
+SYSCTL_SETUP(sysctl_hw_dwc2_setup, "sysctl hw.dwc2 setup")
+{
+       int err;
+       const struct sysctlnode *rnode;
+       const struct sysctlnode *cnode;
+
+       err = sysctl_createv(clog, 0, NULL, &rnode,
+           CTLFLAG_PERMANENT, CTLTYPE_NODE, "dwc2",
+           SYSCTL_DESCR("dwc2 global controls"),
+           NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+       if (err)
+               goto fail;
+
+       /* control debugging printfs */
+       err = sysctl_createv(clog, 0, &rnode, &cnode,
+           CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+           "debug", SYSCTL_DESCR("Enable debugging output"),
+           NULL, 0, &dwc2debug, sizeof(dwc2debug), CTL_CREATE, CTL_EOL);
+       if (err)
+               goto fail;
+
+       return;
+fail:
+       aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
 #else
 #define        DPRINTF(...) do { } while (0)
 #define        DPRINTFN(...) do { } while (0)
@@ -944,7 +973,6 @@
        uint32_t off = 0;
        int retval, err;
        int alloc_bandwidth = 0;
-       int i;
 
        DPRINTFN(1, "xfer=%p pipe=%p\n", xfer, xfer->ux_pipe);
 
@@ -984,6 +1012,14 @@
                DPRINTFN(3, "req = %p dma = %" PRIxBUSADDR " len %d dir %s\n",
                    KERNADDR(&dpipe->req_dma, 0), DMAADDR(&dpipe->req_dma, 0),
                    len, dir == UE_DIR_IN ? "in" : "out");
+       } else if (xfertype == UE_ISOCHRONOUS) {
+               DPRINTFN(3, "xfer=%p nframes=%d flags=%d addr=%d endpt=%d,"
+                   " mps=%d dir %s\n", xfer, xfer->ux_nframes, xfer->ux_flags, addr,
+                   epnum, mps, dir == UT_READ ? "in" :"out");
+
+               len = 0;
+               for (size_t i = 0; i < xfer->ux_nframes; i++)
+                       len += xfer->ux_frlengths[i];
        } else {
                DPRINTFN(3, "xfer=%p len=%d flags=%d addr=%d endpt=%d,"
                    " mps=%d dir %s\n", xfer, xfer->ux_length, xfer->ux_flags, addr,
@@ -1077,8 +1113,9 @@
        KASSERTMSG(xfer->ux_nframes == 0 || xfertype == UE_ISOCHRONOUS,
            "nframes %d xfertype %d\n", xfer->ux_nframes, xfertype);
 
-       for (off = i = 0; i < xfer->ux_nframes; ++i) {
-               DPRINTFN(3, "xfer=%p frame=%d offset=%d length=%d\n", xfer, i,
+       off = 0;
+       for (size_t i = 0; i < xfer->ux_nframes; ++i) {
+               DPRINTFN(3, "xfer=%p frame=%zd offset=%d length=%d\n", xfer, i,
                    off, xfer->ux_frlengths[i]);
 
                dwc2_hcd_urb_set_iso_desc_params(dwc2_urb, i, off,
@@ -1469,22 +1506,21 @@
        DPRINTFN(3, "xfer=%p actlen=%d\n", xfer, xfer->ux_actlen);
 
        if (xfertype == UE_ISOCHRONOUS) {
-               int i;
-
                xfer->ux_actlen = 0;
-               for (i = 0; i < xfer->ux_nframes; ++i) {
+               for (size_t i = 0; i < xfer->ux_nframes; ++i) {
                        xfer->ux_frlengths[i] =
                                dwc2_hcd_urb_get_iso_desc_actual_length(
                                                urb, i);
+                       DPRINTFN(1, "xfer=%p frame=%zu length=%d\n", xfer, i,
+                           xfer->ux_frlengths[i]);
                        xfer->ux_actlen += xfer->ux_frlengths[i];
                }
+               DPRINTFN(1, "xfer=%p actlen=%d (isoc)\n", xfer, xfer->ux_actlen);
        }
 
        if (xfertype == UE_ISOCHRONOUS && dbg_perio()) {
-               int i;
-
-               for (i = 0; i < xfer->ux_nframes; i++)
-                       dev_vdbg(hsotg->dev, " ISO Desc %d status %d\n",
+               for (size_t i = 0; i < xfer->ux_nframes; i++)
+                       dev_vdbg(hsotg->dev, " ISO Desc %zu status %d\n",
                                 i, urb->iso_descs[i].status);
        }
 



Home | Main Index | Thread Index | Old Index