Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys First pass at adapting SLHCI_DEBUG to USBHIST
details: https://anonhg.NetBSD.org/src/rev/e79e38e64244
branches: trunk
changeset: 344893:e79e38e64244
user: skrll <skrll%NetBSD.org@localhost>
date: Tue Apr 26 10:38:42 2016 +0000
description:
First pass at adapting SLHCI_DEBUG to USBHIST
diffstat:
sys/conf/files | 4 +-
sys/dev/ic/sl811hs.c | 136 ++++++++++++++++++++++++++++++-------------------
sys/dev/usb/files.usb | 3 +-
3 files changed, 86 insertions(+), 57 deletions(-)
diffs (truncated from 515 to 300 lines):
diff -r 1e2b96f255ee -r e79e38e64244 sys/conf/files
--- a/sys/conf/files Tue Apr 26 10:28:28 2016 +0000
+++ b/sys/conf/files Tue Apr 26 10:38:42 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.1155 2016/04/23 12:50:35 skrll Exp $
+# $NetBSD: files,v 1.1156 2016/04/26 10:38:42 skrll Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20150846
@@ -1261,7 +1261,7 @@
file dev/usb/motg.c motg needs-flag
# SL811HS/T USB controller
-defflag opt_slhci.h SLHCI_DEBUG SLHCI_TRY_LSVH SLHCI_PROFILE_TRANSFER
+defflag opt_slhci.h SLHCI_TRY_LSVH SLHCI_PROFILE_TRANSFER
device slhci: usbus, usbroothub
file dev/ic/sl811hs.c slhci needs-flag
diff -r 1e2b96f255ee -r e79e38e64244 sys/dev/ic/sl811hs.c
--- a/sys/dev/ic/sl811hs.c Tue Apr 26 10:28:28 2016 +0000
+++ b/sys/dev/ic/sl811hs.c Tue Apr 26 10:38:42 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sl811hs.c,v 1.55 2016/04/26 10:28:28 skrll Exp $ */
+/* $NetBSD: sl811hs.c,v 1.56 2016/04/26 10:38:42 skrll Exp $ */
/*
* Not (c) 2007 Matthew Orgass
@@ -68,11 +68,16 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.55 2016/04/26 10:28:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.56 2016/04/26 10:38:42 skrll Exp $");
#include "opt_slhci.h"
+#ifdef _KERNEL_OPT
+#include "opt_usb.h"
+#endif
+
#include <sys/param.h>
+
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/device.h>
@@ -82,11 +87,13 @@
#include <sys/kmem.h>
#include <sys/proc.h>
#include <sys/queue.h>
+#include <sys/sysctl.h>
#include <sys/systm.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdivar.h>
+#include <dev/usb/usbhist.h>
#include <dev/usb/usb_mem.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/usbroothub.h>
@@ -521,6 +528,9 @@
static usbd_status slhci_root(struct slhci_softc *, struct slhci_pipe *,
struct usbd_xfer *);
+#define SLHCIHIST_FUNC() USBHIST_FUNC()
+#define SLHCIHIST_CALLED() USBHIST_CALLED(slhcidebug)
+
#ifdef SLHCI_DEBUG
void slhci_log_buffer(struct usbd_xfer *);
void slhci_log_req(usb_device_request_t *);
@@ -532,8 +542,6 @@
void slhci_log_sc(void);
void slhci_log_slreq(struct slhci_pipe *);
-extern int usbdebug;
-
/* Constified so you can read the values from ddb */
const int SLHCI_D_TRACE = 0x0001;
const int SLHCI_D_MSG = 0x0002;
@@ -551,48 +559,39 @@
const int SLHCI_D_NAK = 0x2000;
int slhcidebug = 0x1cbc; /* 0xc8c; */ /* 0xffff; */ /* 0xd8c; */
+
+SYSCTL_SETUP(sysctl_hw_slhci_setup, "sysctl hw.slhci setup")
+{
+ int err;
+ const struct sysctlnode *rnode;
+ const struct sysctlnode *cnode;
+
+ err = sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE, "slhci",
+ SYSCTL_DESCR("slhci 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, &slhcidebug, sizeof(slhcidebug), CTL_CREATE, CTL_EOL);
+ if (err)
+ goto fail;
+
+ return;
+fail:
+ aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
struct slhci_softc *ssc;
-#ifdef USB_DEBUG
-int slhci_usbdebug = -1; /* value to set usbdebug on attach, -1 = leave alone */
-#endif
-
-/*
- * XXXMRG the SLHCI UVMHIST code has been converted to KERNHIST, but it has
- * not been tested. the extra instructions to enable it can probably be
- * commited to the kernhist code, and these instructions reduced to simply
- * enabling SLHCI_DEBUG.
- */
-
-/*
- * Add KERNHIST history for debugging:
- *
- * Before kern_hist in sys/kern/subr_kernhist.c add:
- * KERNHIST_DECL(slhcihist);
- *
- * In kern_hist add:
- * if ((bitmask & KERNHIST_SLHCI))
- * hists[i++] = &slhcihist;
- *
- * In sys/sys/kernhist.h add KERNHIST_SLHCI define.
- */
-
-#include <sys/kernhist.h>
-KERNHIST_DECL(slhcihist);
-
-#if !defined(KERNHIST) || !defined(KERNHIST_SLHCI)
-#error "SLHCI_DEBUG requires KERNHIST (with modifications, see sys/dev/ic/sl81hs.c)"
-#endif
-
-#ifndef SLHCI_NHIST
-#define SLHCI_NHIST 409600
-#endif
-const unsigned int SLHCI_HISTMASK = KERNHIST_SLHCI;
-struct kern_history_ent slhci_he[SLHCI_NHIST];
#define SLHCI_DEXEC(x, y) do { if ((slhcidebug & SLHCI_ ## x)) { y; } \
} while (/*CONSTCOND*/ 0)
-#define DDOLOG(f, a, b, c, d) do { const char *_kernhist_name = __func__; \
- u_long _kernhist_call = 0; KERNHIST_LOG(slhcihist, f, a, b, c, d); \
+#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))
/*
@@ -602,10 +601,9 @@
* 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); \
- const char *_kernhist_name = __func__; u_long _kernhist_call = 0; \
- if (_DLF8 & 0xf0) KERNHIST_LOG(slhcihist, y " %s %s %s %s", _DLF8 & 0x80 ? \
+ 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(slhcihist, y " %s %s %s %s", \
+ (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)
@@ -618,6 +616,7 @@
static void
DDOLOGBUF(uint8_t *buf, unsigned int length)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
int i;
for(i=0; i+8 <= length; i+=8)
@@ -646,6 +645,7 @@
}
#define DLOGBUF(x, b, l) SLHCI_DEXEC(x, DDOLOGBUF(b, l))
#else /* now !SLHCI_DEBUG */
+#define slhcidebug 0
#define slhci_log_spipe(spipe) ((void)0)
#define slhci_log_xfer(xfer) ((void)0)
#define SLHCI_DEXEC(x, y) ((void)0)
@@ -766,6 +766,7 @@
struct usbd_xfer *
slhci_allocx(struct usbd_bus *bus, unsigned int nframes)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct usbd_xfer *xfer;
xfer = kmem_zalloc(sizeof(*xfer), KM_SLEEP);
@@ -785,6 +786,7 @@
void
slhci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
DLOG(D_MEM, "freex xfer %p spipe %p", xfer, xfer->ux_pipe,0,0);
#ifdef SLHCI_MEM_ACCOUNTING
@@ -817,6 +819,7 @@
usbd_status
slhci_transfer(struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc = SLHCI_XFER2SC(xfer);
usbd_status error;
@@ -851,6 +854,7 @@
usbd_status
slhci_start(struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc = SLHCI_XFER2SC(xfer);
struct usbd_pipe *pipe = xfer->ux_pipe;
struct slhci_pipe *spipe = SLHCI_PIPE2SPIPE(pipe);
@@ -995,6 +999,7 @@
usbd_status
slhci_open(struct usbd_pipe *pipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct usbd_device *dev;
struct slhci_softc *sc;
struct slhci_pipe *spipe;
@@ -1115,9 +1120,6 @@
t = &sc->sc_transfers;
-#ifdef SLHCI_DEBUG
- KERNHIST_INIT_STATIC(slhcihist, slhci_he);
-#endif
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
@@ -1178,10 +1180,6 @@
#ifdef SLHCI_DEBUG
ssc = sc;
-#ifdef USB_DEBUG
- if (slhci_usbdebug >= 0)
- usbdebug = slhci_usbdebug;
-#endif
#endif
if (t->sltype == SLTYPE_SL811HS_R12)
@@ -1264,6 +1262,7 @@
ret = config_detach(sc->sc_child, flags);
#ifdef SLHCI_MEM_ACCOUNTING
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
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);
@@ -1292,6 +1291,7 @@
void
slhci_abort(struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
struct slhci_pipe *spipe;
@@ -1318,6 +1318,7 @@
void
slhci_close(struct usbd_pipe *pipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
struct slhci_pipe *spipe;
@@ -1333,6 +1334,7 @@
void
slhci_clear_toggle(struct usbd_pipe *pipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_pipe *spipe;
spipe = SLHCI_PIPE2SPIPE(pipe);
@@ -1359,6 +1361,7 @@
void
slhci_poll(struct usbd_bus *bus) /* XXX necessary? */
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
sc = SLHCI_BUS2SC(bus);
@@ -1444,6 +1447,7 @@
void
slhci_callback_entry(void *arg)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
struct slhci_transfers *t;
@@ -1694,6 +1698,7 @@
static void
slhci_waitintr(struct slhci_softc *sc, int wait_time)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
Home |
Main Index |
Thread Index |
Old Index