Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Debug updates to work with vmstat(1) -u



details:   https://anonhg.NetBSD.org/src/rev/e2e58412b2c9
branches:  trunk
changeset: 816119:e2e58412b2c9
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Jun 18 19:30:24 2016 +0000

description:
Debug updates to work with vmstat(1) -u

diffstat:

 sys/dev/ic/sl811hs.c |  324 ++++++++++++++++++++++----------------------------
 1 files changed, 141 insertions(+), 183 deletions(-)

diffs (truncated from 667 to 300 lines):

diff -r 894267d3f5a9 -r e2e58412b2c9 sys/dev/ic/sl811hs.c
--- a/sys/dev/ic/sl811hs.c      Sat Jun 18 16:51:44 2016 +0000
+++ b/sys/dev/ic/sl811hs.c      Sat Jun 18 19:30:24 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sl811hs.c,v 1.78 2016/06/17 16:07:40 skrll Exp $       */
+/*     $NetBSD: sl811hs.c,v 1.79 2016/06/18 19:30:24 skrll Exp $       */
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.78 2016/06/17 16:07:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.79 2016/06/18 19:30:24 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_slhci.h"
@@ -160,18 +160,59 @@
 
 #ifdef SLHCI_DEBUG
 #define SLHCI_MEM_ACCOUNTING
-static const char *
-pnames(int ptype)
-{
-       static const char * const names[] = { "ROOT Ctrl", "ROOT Intr",
-           "Control (setup)", "Control (data)", "Control (status)",
-           "Interrupt", "Bulk", "BAD PTYPE" };
-
-       KASSERT(sizeof(names) / sizeof(names[0]) == PT_MAX + 2);
-       if (ptype > PT_MAX)
-               ptype = PT_MAX + 1;
-       return names[ptype];
-}
+
+#define DDOLOGCTRL(x)  do {                                            \
+    DDOLOG("CTRL suspend=%d", !!((x) & SL11_CTRL_SUSPEND), 0, 0, 0);   \
+    DDOLOG("CTRL ls     =%d  jk     =%d  reset  =%d  sof    =%d",      \
+       !!((x) & SL11_CTRL_LOWSPEED), !!((x) & SL11_CTRL_JKSTATE),      \
+       !!((x) & SL11_CTRL_RESETENGINE), !!((x) & SL11_CTRL_ENABLESOF));\
+} while (0)
+
+#define DDOLOGISR(r)   do {                                            \
+    DDOLOG("ISR  data   =%d  det/res=%d  insert =%d  sof    =%d",      \
+       !!((r) & SL11_ISR_DATA), !!((r) & SL11_ISR_RESUME),             \
+       !!((r) & SL11_ISR_INSERT), !!!!((r) & SL11_ISR_SOF));           \
+    DDOLOG("ISR             babble =%d  usbb   =%d  usba   =%d",       \
+       !!((r) & SL11_ISR_BABBLE), !!((r) & SL11_ISR_USBB),             \
+       !!((r) & SL11_ISR_USBA), 0);                                    \
+} while (0)
+
+#define DDOLOGIER(r)   do {                                            \
+    DDOLOG("IER              det/res=%d  insert =%d  sof    =%d",      \
+       !!((r) & SL11_IER_RESUME),                                      \
+       !!((r) & SL11_IER_INSERT), !!!!((r) & SL11_IER_SOF), 0);                \
+    DDOLOG("IER              babble =%d  usbb   =%d  usba   =%d",      \
+       !!((r) & SL11_IER_BABBLE), !!((r) & SL11_IER_USBB),             \
+       !!((r) & SL11_IER_USBA), 0);                                    \
+} while (0)
+
+#define DDLOGSTATUS(s) do {                                            \
+    DDOLOG("STAT stall   =%d  nak     =%d  overflow =%d  setup   =%d", \
+       !!((s) & SL11_EPSTAT_STALL), !!((s) & SL11_EPSTAT_NAK),         \
+       !!((s) & SL11_EPSTAT_OVERFLOW), !!((s) & SL11_EPSTAT_SETUP));   \
+    DDOLOG("STAT sequence=%d  timeout =%d  error    =%d  ack   =%d",   \
+       !!((s) & SL11_EPSTAT_SEQUENCE), !!((s) & SL11_EPSTAT_TIMEOUT),  \
+       !!((s) & SL11_EPSTAT_ERROR), !!((s) & SL11_EPSTAT_ACK));        \
+} while (0)
+
+#define DDLOGEPCTRL(r) do {                                            \
+    DDOLOG("CTRL preamble=%d  toggle  =%d  sof     =%d  iso     =%d",  \
+       !!((r) & SL11_EPCTRL_PREAMBLE), !!((r) & SL11_EPCTRL_DATATOGGLE),\
+       !!((r) & SL11_EPCTRL_SOF), !!((r) & SL11_EPCTRL_ISO));          \
+    DDOLOG("CTRL              out     =%d  enable  =%d  arm     =%d",  \
+       !!((r) & SL11_EPCTRL_DIRECTION),                                \
+       !!((r) & SL11_EPCTRL_ENABLE), !!((r) & SL11_EPCTRL_ARM), 0);    \
+} while (0)
+
+#define DDLOGEPSTAT(r) do {                                            \
+    DDOLOG("STAT stall   =%d  nak     =%d  overflow =%d  setup   =%d", \
+       !!((r) & SL11_EPSTAT_STALL), !!((r) & SL11_EPSTAT_NAK),         \
+       !!((r) & SL11_EPSTAT_OVERFLOW), !!((r) & SL11_EPSTAT_SETUP));   \
+    DDOLOG("STAT sequence=%d  timeout =%d  error    =%d  ack   =%d",   \
+       !!((r) & SL11_EPSTAT_SEQUENCE), !!((r) & SL11_EPSTAT_TIMEOUT),  \
+       !!((r) & SL11_EPSTAT_ERROR), !!((r) & SL11_EPSTAT_ACK));        \
+} while (0)
+
 #endif
 
 /*
@@ -530,7 +571,6 @@
 #ifdef SLHCI_DEBUG
 void slhci_log_buffer(struct usbd_xfer *);
 void slhci_log_req(usb_device_request_t *);
-void slhci_log_req_hub(usb_device_request_t *);
 void slhci_log_dumpreg(void);
 void slhci_log_xfer(struct usbd_xfer *);
 void slhci_log_spipe(struct slhci_pipe *);
@@ -590,21 +630,7 @@
 #define DDOLOG(f, a, b, c, d) do { KERNHIST_LOG(usbhist, f, a, b, c, d); \
 } while (/*CONSTCOND*/0)
 #define DLOG(x, f, a, b, c, d) SLHCI_DEXEC(x, DDOLOG(f, a, b, c, d))
-/*
- * DLOGFLAG8 is a macro not a function so that flag name expressions are not
- * evaluated unless the flag bit is set (which could save a register read).
- * x is debug mask, y is flag identifier, z is flag variable,
- * a-h are flag names (must evaluate to string constants, msb first).
- */
-#define DDOLOGFLAG8(y, z, a, b, c, d, e, f, g, h) do { uint8_t _DLF8 = (z);   \
-    if (_DLF8 & 0xf0) KERNHIST_LOG(usbhist, y " %s %s %s %s", _DLF8 & 0x80 ?  \
-    (a) : "", _DLF8 & 0x40 ? (b) : "", _DLF8 & 0x20 ? (c) : "", _DLF8 & 0x10 ? \
-    (d) : ""); if (_DLF8 & 0x0f) KERNHIST_LOG(usbhist, y " %s %s %s %s",      \
-    _DLF8 & 0x08 ? (e) : "", _DLF8 & 0x04 ? (f) : "", _DLF8 & 0x02 ? (g) : "", \
-    _DLF8 & 0x01 ? (h) : "");                                                 \
-} while (/*CONSTCOND*/ 0)
-#define DLOGFLAG8(x, y, z, a, b, c, d, e, f, g, h) \
-    SLHCI_DEXEC(x, DDOLOGFLAG8(y, z, a, b, c, d, e, f, g, h))
+
 /*
  * DDOLOGBUF logs a buffer up to 8 bytes at a time. No identifier so that we
  * can make it a real function.
@@ -647,8 +673,6 @@
 #define SLHCI_DEXEC(x, y) ((void)0)
 #define DDOLOG(f, a, b, c, d) ((void)0)
 #define DLOG(x, f, a, b, c, d) ((void)0)
-#define DDOLOGFLAG8(y, z, a, b, c, d, e, f, g, h) ((void)0)
-#define DLOGFLAG8(x, y, z, a, b, c, d, e, f, g, h) ((void)0)
 #define DDOLOGBUF(b, l) ((void)0)
 #define DLOGBUF(x, b, l) ((void)0)
 #endif /* SLHCI_DEBUG */
@@ -658,8 +682,6 @@
        if (!(exp)) {                                                   \
                printf("%s: assertion %s failed line %u function %s!"   \
                " halted\n", SC_NAME(sc), #exp, __LINE__, __func__);\
-               DDOLOG("%s: assertion %s failed line %u function %s!"   \
-               " halted\n", SC_NAME(sc), #exp, __LINE__, __func__);\
                slhci_halt(sc, spipe, xfer);                            \
                ext;                                                    \
        }                                                               \
@@ -668,8 +690,6 @@
        if (!(exp)) {                                                   \
                printf("%s: assertion %s failed line %u function %s!"   \
                " halted\n", SC_NAME(sc), #exp, __LINE__, __func__);    \
-               DDOLOG("%s: assertion %s failed line %u function %s!"   \
-               " halted\n", SC_NAME(sc), #exp, __LINE__, __func__);    \
                slhci_lock_call(sc, &slhci_halt, spipe, xfer);          \
                ext;                                                    \
        }                                                               \
@@ -793,8 +813,8 @@
                struct slhci_softc *sc = SLHCI_BUS2SC(bus);
                printf("%s: slhci_freex: xfer=%p not busy, %#08x halted\n",
                    SC_NAME(sc), xfer, xfer->ux_state);
-               DDOLOG("%s: slhci_freex: xfer=%p not busy, %#08x halted\n",
-                   SC_NAME(sc), xfer, xfer->ux_state, 0);
+               DDOLOG("xfer=%p not busy, %#08x halted\n", xfer,
+                   xfer->ux_state, 0, 0);
                slhci_lock_call(sc, &slhci_halt, NULL, NULL);
                return;
        }
@@ -819,8 +839,8 @@
        struct slhci_softc *sc = SLHCI_XFER2SC(xfer);
        usbd_status error;
 
-       DLOG(D_TRACE, "%s transfer xfer %p spipe %p ",
-           pnames(SLHCI_XFER_TYPE(xfer)), xfer, xfer->ux_pipe,0);
+       DLOG(D_TRACE, "transfer type %d xfer %p spipe %p ",
+           SLHCI_XFER_TYPE(xfer), xfer, xfer->ux_pipe, 0);
 
        /* Insert last in queue */
        mutex_enter(&sc->sc_lock);
@@ -862,8 +882,8 @@
 
        max_packet = UGETW(ed->wMaxPacketSize);
 
-       DLOG(D_TRACE, "%s start xfer %p spipe %p length %d",
-           pnames(spipe->ptype), xfer, spipe, xfer->ux_length);
+       DLOG(D_TRACE, "transfer type %d start xfer %p spipe %p length %d",
+           spipe->ptype, xfer, spipe, xfer->ux_length);
 
        /* root transfers use slhci_root_start */
 
@@ -898,8 +918,7 @@
                    xfer->ux_length > spipe->tregs[LEN])) {
                        printf("%s: Long INTR transfer not supported!\n",
                            SC_NAME(sc));
-                       DDOLOG("%s: Long INTR transfer not supported!\n",
-                           SC_NAME(sc), 0,0,0);
+                       DDOLOG("Long INTR transfer not supported!", 0, 0, 0, 0);
                        xfer->ux_status = USBD_INVAL;
                }
 #endif
@@ -995,7 +1014,7 @@
        LK_SLASSERT(spipe != NULL && xfer != NULL, sc, spipe, xfer, return
            USBD_CANCELLED);
 
-       DLOG(D_TRACE, "%s start", pnames(SLHCI_XFER_TYPE(xfer)), 0,0,0);
+       DLOG(D_TRACE, "transfer type %d start", SLHCI_XFER_TYPE(xfer), 0, 0, 0);
 
        KASSERT(spipe->ptype == PT_ROOT_INTR);
 
@@ -1076,8 +1095,7 @@
                        break;
                default:
                        printf("%s: Invalid root endpoint!\n", SC_NAME(sc));
-                       DDOLOG("%s: Invalid root endpoint!\n", SC_NAME(sc),
-                           0,0,0);
+                       DDOLOG("Invalid root endpoint", 0, 0, 0, 0);
                        return USBD_INVAL;
                }
                return USBD_NORMAL_COMPLETION;
@@ -1101,7 +1119,7 @@
                        break;
                }
 
-               DLOG(D_MSG, "open pipe %s interval %d", pnames(spipe->ptype),
+               DLOG(D_MSG, "open pipe type %d interval %d", spipe->ptype,
                    pipe->up_interval, 0,0);
 
                pipe->up_methods = __UNCONST(&slhci_pipe_methods);
@@ -1276,8 +1294,8 @@
        if (sc->sc_mem_use) {
                printf("%s: Memory still in use after detach! mem_use (count)"
                    " = %d\n", SC_NAME(sc), sc->sc_mem_use);
-               DDOLOG("%s: Memory still in use after detach! mem_use (count)"
-                   " = %d\n", SC_NAME(sc), sc->sc_mem_use, 0,0);
+               DDOLOG("Memory still in use after detach! mem_use (count)"
+                   " = %d", sc->sc_mem_use, 0, 0, 0);
        }
 #endif
 
@@ -1313,8 +1331,8 @@
        sc = SLHCI_XFER2SC(xfer);
        KASSERT(mutex_owned(&sc->sc_lock));
 
-       DLOG(D_TRACE, "%s abort xfer %p spipe %p spipe->xfer %p",
-           pnames(spipe->ptype), xfer, spipe, spipe->xfer);
+       DLOG(D_TRACE, "transfer type %d abort xfer %p spipe %p spipe->xfer %p",
+           spipe->ptype, xfer, spipe, spipe->xfer);
 
        slhci_lock_call(sc, &slhci_do_abort, spipe, xfer);
 
@@ -1333,8 +1351,8 @@
        sc = SLHCI_PIPE2SC(pipe);
        spipe = SLHCI_PIPE2SPIPE(pipe);
 
-       DLOG(D_TRACE, "%s close spipe %p spipe->xfer %p",
-           pnames(spipe->ptype), spipe, spipe->xfer, 0);
+       DLOG(D_TRACE, "transfer type %d close spipe %p spipe->xfer %p",
+           spipe->ptype, spipe, spipe->xfer, 0);
 
        slhci_lock_call(sc, &slhci_close_pipe, spipe, NULL);
 }
@@ -1347,7 +1365,7 @@
 
        spipe = SLHCI_PIPE2SPIPE(pipe);
 
-       DLOG(D_TRACE, "%s toggle spipe %p", pnames(spipe->ptype),
+       DLOG(D_TRACE, "transfer type %d toggle spipe %p", spipe->ptype,
            spipe,0,0);
 
        spipe->pflags &= ~PF_TOGGLE;
@@ -1359,8 +1377,8 @@
 
                printf("%s: Clear toggle on transfer in progress! halted\n",
                    SC_NAME(sc));
-               DDOLOG("%s: Clear toggle on transfer in progress! halted\n",
-                   SC_NAME(sc), 0,0,0);
+               DDOLOG("Clear toggle on transfer in progress! halted",
+                   0, 0, 0, 0);
                slhci_halt(sc, NULL, NULL);
        }
 #endif
@@ -1549,6 +1567,7 @@
                slhci_dotransfer(sc);
                goto waitcheck;
        }
+       DLOG(D_INTR, "... done", 0, 0, 0, 0);
 }
 
 /* End lock entry functions. Start in lock function. */
@@ -1750,10 +1769,9 @@
 
                e = slhci_read(sc, SL11_IER);
                f = slhci_read(sc, SL11_CTRL);
-               DDOLOG("Flags=%#x IER=%#x ISR=%#x", t->flags, e, r, 0);
-               DDOLOGFLAG8("Status=", r, "D+", (f & SL11_CTRL_SUSPEND) ?
-                   "RESUME" : "NODEV", "INSERT", "SOF", "res", "BABBLE",
-                   "USBB", "USBA");
+               DDOLOG("Flags=%#x IER=%#x ISR=%#x CTRL=%#x", t->flags, e, r, f);
+               DDOLOGCTRL(f);
+               DDOLOGISR(r);
        }
 #endif
 
@@ -1766,8 +1784,7 @@
                if (sc->sc_ier != slhci_read(sc, SL11_IER)) {
                        printf("%s: IER value corrupted! halted\n",
                            SC_NAME(sc));
-                       DDOLOG("%s: IER value corrupted! halted\n",
-                           SC_NAME(sc), 0,0,0);



Home | Main Index | Thread Index | Old Index