Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/usb Convert to USBHIST



details:   https://anonhg.NetBSD.org/src/rev/5db0adba1974
branches:  nick-nhusb
changeset: 334117:5db0adba1974
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Feb 24 16:57:02 2015 +0000

description:
Convert to USBHIST

diffstat:

 sys/dev/usb/ohci.c |  556 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 326 insertions(+), 230 deletions(-)

diffs (truncated from 1364 to 300 lines):

diff -r d37a11ccca15 -r 5db0adba1974 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Sun Feb 22 14:50:07 2015 +0000
+++ b/sys/dev/usb/ohci.c        Tue Feb 24 16:57:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.254.2.17 2015/02/22 08:25:02 skrll Exp $    */
+/*     $NetBSD: ohci.c,v 1.254.2.18 2015/02/24 16:57:02 skrll Exp $    */
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.17 2015/02/22 08:25:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.18 2015/02/24 16:57:02 skrll Exp $");
+
+#include "opt_usb.h"
 
 #include <sys/param.h>
 
@@ -52,6 +54,7 @@
 #include <sys/proc.h>
 #include <sys/queue.h>
 #include <sys/select.h>
+#include <sys/sysctl.h>
 #include <sys/systm.h>
 
 #include <machine/endian.h>
@@ -65,17 +68,48 @@
 #include <dev/usb/ohcireg.h>
 #include <dev/usb/ohcivar.h>
 #include <dev/usb/usbroothub.h>
-
-
-
-#ifdef OHCI_DEBUG
-#define DPRINTF(x)     if (ohcidebug) printf x
-#define DPRINTFN(n,x)  if (ohcidebug>(n)) printf x
-int ohcidebug = 0;
+#include <dev/usb/usbhist.h>
+
+#ifdef USB_DEBUG
+#ifndef OHCI_DEBUG
+#define ohcidebug 0
 #else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
+static int ohcidebug = 0;
+
+SYSCTL_SETUP(sysctl_hw_ohci_setup, "sysctl hw.ohci setup")
+{
+       int err;
+       const struct sysctlnode *rnode;
+       const struct sysctlnode *cnode;
+
+       err = sysctl_createv(clog, 0, NULL, &rnode,
+           CTLFLAG_PERMANENT, CTLTYPE_NODE, "ohci",
+           SYSCTL_DESCR("ohci 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, &ohcidebug, sizeof(ohcidebug), CTL_CREATE, CTL_EOL);
+       if (err)
+               goto fail;
+
+       return;
+fail:
+       aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
+#endif /* OHCI_DEBUG */
+#endif /* USB_DEBUG */
+
+#define        DPRINTF(FMT,A,B,C,D)    USBHIST_LOG(ohcidebug,FMT,A,B,C,D)
+#define        DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(ohcidebug,N,FMT,A,B,C,D)
+#define        OHCIHIST_FUNC()         USBHIST_FUNC()
+#define        OHCIHIST_CALLED(name)   USBHIST_CALLED(ohcidebug)
 
 #if BYTE_ORDER == BIG_ENDIAN
 #define        SWAP_ENDIAN     OHCI_LITTLE_ENDIAN
@@ -358,8 +392,10 @@
        int i, offs;
        usb_dma_t dma;
 
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+
        if (sc->sc_freeeds == NULL) {
-               DPRINTFN(2, ("ohci_alloc_sed: allocating chunk\n"));
+               DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                err = usb_allocmem(&sc->sc_bus, OHCI_SED_SIZE * OHCI_SED_CHUNK,
                          OHCI_ED_ALIGN, &dma);
                if (err)
@@ -396,10 +432,12 @@
        int i, offs;
        usb_dma_t dma;
 
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+
        KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
 
        if (sc->sc_freetds == NULL) {
-               DPRINTFN(2, ("ohci_alloc_std: allocating chunk\n"));
+               DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                err = usb_allocmem(&sc->sc_bus, OHCI_STD_SIZE * OHCI_STD_CHUNK,
                          OHCI_TD_ALIGN, &dma);
                if (err)
@@ -448,10 +486,16 @@
        usb_dma_t *dma = &xfer->ux_dmabuf;
        uint16_t flags = xfer->ux_flags;
 
-       DPRINTFN(alen < 4096,("ohci_alloc_std_chain: start len=%d\n", alen));
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+       DPRINTF("start len=%d", alen, 0, 0, 0);
 
        KASSERT(mutex_owned(&sc->sc_lock));
 
+       DPRINTFN(8, "addr=%d endpt=%d len=%d speed=%d",
+           opipe->pipe.up_dev->ud_addr,
+           UE_GET_ADDR(opipe->pipe.up_endpoint->ue_edesc->bEndpointAddress),
+           alen, opipe->pipe.up_dev->ud_speed);
+
        len = alen;
        cur = sp;
        dataphys = DMAADDR(dma, 0);
@@ -484,10 +528,8 @@
                                panic("ohci_alloc_std: curlen == 0");
 #endif
                }
-               DPRINTFN(4,("ohci_alloc_std_chain: dataphys=0x%08x "
-                           "dataphysend=0x%08x len=%d curlen=%d\n",
-                           dataphys, dataphysend,
-                           len, curlen));
+               DPRINTFN(4, "dataphys=0x%08x dataphysend=0x%08x "
+                   "len=%d curlen=%d",  dataphys, dataphysend, len, curlen);
                len -= curlen;
 
                cur->td.td_flags = tdflags;
@@ -500,11 +542,11 @@
                cur->xfer = xfer;
                usb_syncmem(&cur->dma, cur->offs, sizeof(cur->td),
                    BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-               DPRINTFN(10,("ohci_alloc_std_chain: cbp=0x%08x be=0x%08x\n",
-                           dataphys, dataphys + curlen - 1));
+               DPRINTFN(10, "cbp=0x%08x be=0x%08x", dataphys,
+                   dataphys + curlen - 1, 0, 0);
                if (len == 0)
                        break;
-               DPRINTFN(10,("ohci_alloc_std_chain: extend chain\n"));
+               DPRINTFN(10, "extend chain", 0, 0, 0, 0);
                dataphys += curlen;
                cur = next;
        }
@@ -527,7 +569,7 @@
                cur->xfer = xfer;
                usb_syncmem(&cur->dma, cur->offs, sizeof(cur->td),
                    BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-               DPRINTFN(2,("ohci_alloc_std_chain: add 0 xfer\n"));
+               DPRINTFN(2, "add 0 xfer", 0, 0, 0, 0);
        }
        *ep = cur;
 
@@ -561,8 +603,10 @@
        int i, offs;
        usb_dma_t dma;
 
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+
        if (sc->sc_freeitds == NULL) {
-               DPRINTFN(2, ("ohci_alloc_sitd: allocating chunk\n"));
+               DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
                err = usb_allocmem(&sc->sc_bus, OHCI_SITD_SIZE * OHCI_SITD_CHUNK,
                          OHCI_ITD_ALIGN, &dma);
                if (err)
@@ -596,7 +640,8 @@
 ohci_free_sitd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
 {
 
-       DPRINTFN(10,("ohci_free_sitd: sitd=%p\n", sitd));
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+       DPRINTFN(10, "sitd=%p", sitd, 0, 0, 0);
 
 #ifdef DIAGNOSTIC
        if (!sitd->isdone) {
@@ -620,7 +665,8 @@
        int i;
        uint32_t s, ctl, rwc, ival, hcr, fm, per, rev, desca /*, descb */;
 
-       DPRINTF(("ohci_init: start\n"));
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+
        aprint_normal_dev(sc->sc_dev, "");
 
        sc->sc_hcca = NULL;
@@ -729,14 +775,16 @@
            BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
 #ifdef OHCI_DEBUG
+       DPRINTFN(15, "--- dump start ---", 0, 0, 0 ,0);
        if (ohcidebug > 15) {
                for (i = 0; i < OHCI_NO_EDS; i++) {
-                       printf("ed#%d ", i);
+                       DPRINTFN(15, "ed#%d ", i, 0, 0, 0);
                        ohci_dump_ed(sc, sc->sc_eds[i]);
                }
-               printf("iso ");
+               DPRINTFN(15, "iso", 0, 0, 0 ,0);
                ohci_dump_ed(sc, sc->sc_isoc_head);
        }
+       DPRINTFN(15, "--- dump end ---", 0, 0, 0 ,0);
 #endif
 
        /* Preserve values programmed by SMM/BIOS but lost over reset. */
@@ -749,7 +797,7 @@
        /* Determine in what context we are running. */
        if (ctl & OHCI_IR) {
                /* SMM active, request change */
-               DPRINTF(("ohci_init: SMM active, request owner change\n"));
+               DPRINTF("SMM active, request owner change", 0, 0, 0, 0);
                if ((sc->sc_intre & (OHCI_OC | OHCI_MIE)) ==
                    (OHCI_OC | OHCI_MIE))
                        OWRITE4(sc, OHCI_INTERRUPT_ENABLE, OHCI_MIE);
@@ -770,14 +818,14 @@
 /* Don't bother trying to reuse the BIOS init, we'll reset it anyway. */
        } else if ((ctl & OHCI_HCFS_MASK) != OHCI_HCFS_RESET) {
                /* BIOS started controller. */
-               DPRINTF(("ohci_init: BIOS active\n"));
+               DPRINTF("BIOS active", 0, 0, 0, 0);
                if ((ctl & OHCI_HCFS_MASK) != OHCI_HCFS_OPERATIONAL) {
                        OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_OPERATIONAL | rwc);
                        usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY);
                }
 #endif
        } else {
-               DPRINTF(("ohci_init: cold started\n"));
+               DPRINTF("cold started", 0 ,0 ,0 ,0);
        reset:
                /* Controller was cold started. */
                usb_delay_ms(&sc->sc_bus, USB_BUS_RESET_DELAY);
@@ -787,7 +835,7 @@
         * This reset should not be necessary according to the OHCI spec, but
         * without it some controllers do not start.
         */
-       DPRINTF(("%s: resetting\n", device_xname(sc->sc_dev)));
+       DPRINTF("sc %p: resetting", sc, 0, 0, 0);
        OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET | rwc);
        usb_delay_ms(&sc->sc_bus, USB_BUS_RESET_DELAY);
 
@@ -879,7 +927,7 @@
        sc->sc_control = sc->sc_intre = 0;
 
        /* Finally, turn on interrupts. */
-       DPRINTFN(1,("ohci_init: enabling %#x\n", sc->sc_eintrs | OHCI_MIE));
+       DPRINTF("enabling %#x", sc->sc_eintrs | OHCI_MIE, 0, 0, 0);
        OWRITE4(sc, OHCI_INTERRUPT_ENABLE, sc->sc_eintrs | OHCI_MIE);
 
        return 0;
@@ -946,7 +994,9 @@
 {
        ohci_softc_t *sc = device_private(self);
 
-       DPRINTF(("ohci_shutdown: stopping the HC\n"));
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+
+       DPRINTF("stopping the HC", 0, 0, 0, 0);
        OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
        return true;
 }
@@ -1024,40 +1074,42 @@
 void
 ohci_dumpregs(ohci_softc_t *sc)
 {
-       DPRINTF(("ohci_dumpregs: rev=0x%08x control=0x%08x command=0x%08x\n",
+       OHCIHIST_FUNC(); OHCIHIST_CALLED();
+
+       DPRINTF("rev=0x%08x control=0x%08x command=0x%08x",
                 OREAD4(sc, OHCI_REVISION),
                 OREAD4(sc, OHCI_CONTROL),
-                OREAD4(sc, OHCI_COMMAND_STATUS)));
-       DPRINTF(("               intrstat=0x%08x intre=0x%08x intrd=0x%08x\n",
+                OREAD4(sc, OHCI_COMMAND_STATUS), 0);
+       DPRINTF("               intrstat=0x%08x intre=0x%08x intrd=0x%08x",
                 OREAD4(sc, OHCI_INTERRUPT_STATUS),
                 OREAD4(sc, OHCI_INTERRUPT_ENABLE),
-                OREAD4(sc, OHCI_INTERRUPT_DISABLE)));
-       DPRINTF(("               hcca=0x%08x percur=0x%08x ctrlhd=0x%08x\n",
+                OREAD4(sc, OHCI_INTERRUPT_DISABLE), 0);
+       DPRINTF("               hcca=0x%08x percur=0x%08x ctrlhd=0x%08x",
                 OREAD4(sc, OHCI_HCCA),
                 OREAD4(sc, OHCI_PERIOD_CURRENT_ED),
-                OREAD4(sc, OHCI_CONTROL_HEAD_ED)));
-       DPRINTF(("               ctrlcur=0x%08x bulkhd=0x%08x bulkcur=0x%08x\n",
+                OREAD4(sc, OHCI_CONTROL_HEAD_ED), 0);
+       DPRINTF("               ctrlcur=0x%08x bulkhd=0x%08x bulkcur=0x%08x",



Home | Main Index | Thread Index | Old Index