Module Name: src
Committed By: skrll
Date: Tue Apr 26 10:38:43 UTC 2016
Modified Files:
src/sys/conf: files
src/sys/dev/ic: sl811hs.c
src/sys/dev/usb: files.usb
Log Message:
First pass at adapting SLHCI_DEBUG to USBHIST
To generate a diff of this commit:
cvs rdiff -u -r1.1155 -r1.1156 src/sys/conf/files
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/ic/sl811hs.c
cvs rdiff -u -r1.138 -r1.139 src/sys/dev/usb/files.usb
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1155 src/sys/conf/files:1.1156
--- src/sys/conf/files:1.1155 Sat Apr 23 12:50:35 2016
+++ src/sys/conf/files Tue Apr 26 10:38:42 2016
@@ -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 @@ device motg: usbus, usbroothub
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
Index: src/sys/dev/ic/sl811hs.c
diff -u src/sys/dev/ic/sl811hs.c:1.55 src/sys/dev/ic/sl811hs.c:1.56
--- src/sys/dev/ic/sl811hs.c:1.55 Tue Apr 26 10:28:28 2016
+++ src/sys/dev/ic/sl811hs.c Tue Apr 26 10:38:42 2016
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v
#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 void slhci_get_status(struct slhc
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_print_intr(void);
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_SOF = 0x1000;
const int SLHCI_D_NAK = 0x2000;
int slhcidebug = 0x1cbc; /* 0xc8c; */ /* 0xffff; */ /* 0xd8c; */
-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
+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);
+}
-#ifndef SLHCI_NHIST
-#define SLHCI_NHIST 409600
-#endif
-const unsigned int SLHCI_HISTMASK = KERNHIST_SLHCI;
-struct kern_history_ent slhci_he[SLHCI_NHIST];
+struct slhci_softc *ssc;
#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 @@ struct kern_history_ent slhci_he[SLHCI_N
* 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 @@ struct kern_history_ent slhci_he[SLHCI_N
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 @@ DDOLOGBUF(uint8_t *buf, unsigned int len
}
#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 @@ enter_all_pipes(struct slhci_transfers *
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 @@ slhci_allocx(struct usbd_bus *bus, unsig
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 @@ slhci_get_lock(struct usbd_bus *bus, kmu
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 @@ slhci_transfer(struct usbd_xfer *xfer)
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 @@ slhci_root_start(struct usbd_xfer *xfer)
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 @@ slhci_preinit(struct slhci_softc *sc, Po
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 @@ slhci_attach(struct slhci_softc *sc)
#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 @@ slhci_detach(struct slhci_softc *sc, int
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 @@ slhci_activate(device_t self, enum devac
void
slhci_abort(struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
struct slhci_pipe *spipe;
@@ -1318,6 +1318,7 @@ callback:
void
slhci_close(struct usbd_pipe *pipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
struct slhci_pipe *spipe;
@@ -1333,6 +1334,7 @@ slhci_close(struct usbd_pipe *pipe)
void
slhci_clear_toggle(struct usbd_pipe *pipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_pipe *spipe;
spipe = SLHCI_PIPE2SPIPE(pipe);
@@ -1359,6 +1361,7 @@ slhci_clear_toggle(struct usbd_pipe *pip
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 @@ slhci_start_entry(struct slhci_softc *sc
void
slhci_callback_entry(void *arg)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc;
struct slhci_transfers *t;
@@ -1694,6 +1698,7 @@ slhci_read_multi(struct slhci_softc *sc,
static void
slhci_waitintr(struct slhci_softc *sc, int wait_time)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
t = &sc->sc_transfers;
@@ -1716,6 +1721,7 @@ slhci_waitintr(struct slhci_softc *sc, i
static int
slhci_dointr(struct slhci_softc *sc)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *tosp;
uint8_t r;
@@ -1888,6 +1894,7 @@ slhci_dointr(struct slhci_softc *sc)
static void
slhci_abdone(struct slhci_softc *sc, int ab)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *spipe;
struct usbd_xfer *xfer;
@@ -2251,6 +2258,7 @@ pend:
static void
slhci_dotransfer(struct slhci_softc *sc)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *spipe;
int ab, i;
@@ -2331,6 +2339,7 @@ slhci_dotransfer(struct slhci_softc *sc)
static void
slhci_callback(struct slhci_softc *sc)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *spipe;
struct usbd_xfer *xfer;
@@ -2373,6 +2382,7 @@ do_callback:
static void
slhci_enter_xfer(struct slhci_softc *sc, struct slhci_pipe *spipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
t = &sc->sc_transfers;
@@ -2442,6 +2452,7 @@ slhci_xfer_timer(struct slhci_softc *sc,
static void
slhci_do_repeat(struct slhci_softc *sc, struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *spipe;
@@ -2517,6 +2528,7 @@ static usbd_status
slhci_lsvh_warn(struct slhci_softc *sc, struct slhci_pipe *spipe, struct
usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
t = &sc->sc_transfers;
@@ -2535,6 +2547,7 @@ static usbd_status
slhci_isoc_warn(struct slhci_softc *sc, struct slhci_pipe *spipe, struct
usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
t = &sc->sc_transfers;
@@ -2629,6 +2642,7 @@ static usbd_status
slhci_halt(struct slhci_softc *sc, struct slhci_pipe *spipe,
struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
KASSERT(mutex_owned(&sc->sc_intr_lock));
@@ -2695,6 +2709,7 @@ slhci_intrchange(struct slhci_softc *sc,
static void
slhci_drain(struct slhci_softc *sc)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *spipe;
struct gcq *q;
@@ -2753,6 +2768,7 @@ slhci_drain(struct slhci_softc *sc)
void
slhci_reset(struct slhci_softc *sc)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
struct slhci_pipe *spipe;
struct gcq *q;
@@ -2860,6 +2876,7 @@ static int
slhci_reserve_bustime(struct slhci_softc *sc, struct slhci_pipe *spipe, int
reserve)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
int bustime, max_packet;
@@ -2916,6 +2933,7 @@ slhci_reserve_bustime(struct slhci_softc
static void
slhci_insert(struct slhci_softc *sc)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
t = &sc->sc_transfers;
@@ -2940,6 +2958,7 @@ slhci_insert(struct slhci_softc *sc)
static usbd_status
slhci_clear_feature(struct slhci_softc *sc, unsigned int what)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
usbd_status error;
@@ -2977,6 +2996,7 @@ slhci_clear_feature(struct slhci_softc *
static usbd_status
slhci_set_feature(struct slhci_softc *sc, unsigned int what)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
uint8_t r;
@@ -3048,6 +3068,7 @@ slhci_set_feature(struct slhci_softc *sc
static void
slhci_get_status(struct slhci_softc *sc, usb_port_status_t *ps)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
unsigned int status, change;
@@ -3086,6 +3107,7 @@ static usbd_status
slhci_root(struct slhci_softc *sc, struct slhci_pipe *spipe,
struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_transfers *t;
t = &sc->sc_transfers;
@@ -3109,6 +3131,7 @@ static int
slhci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req,
void *buf, int buflen)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
struct slhci_softc *sc = SLHCI_BUS2SC(bus);
struct slhci_transfers *t = &sc->sc_transfers;
usbd_status error = USBD_IOERROR; /* XXX should be STALL */
@@ -3273,6 +3296,7 @@ slhci_roothub_ctrl(struct usbd_bus *bus,
void
slhci_log_buffer(struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
u_char *buf;
if(xfer->ux_length > 0 &&
@@ -3288,6 +3312,7 @@ slhci_log_buffer(struct usbd_xfer *xfer)
void
slhci_log_req(usb_device_request_t *r)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
static const char *xmes[]={
"GETSTAT",
"CLRFEAT",
@@ -3320,6 +3345,7 @@ slhci_log_req(usb_device_request_t *r)
void
slhci_log_req_hub(usb_device_request_t *r)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
static const struct {
int req;
int type;
@@ -3359,6 +3385,7 @@ slhci_log_req_hub(usb_device_request_t *
void
slhci_log_dumpreg(void)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
uint8_t r;
unsigned int aaddr, alen, baddr, blen;
static u_char buf[240];
@@ -3429,16 +3456,17 @@ slhci_log_dumpreg(void)
void
slhci_log_xfer(struct usbd_xfer *xfer)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
DDOLOG("xfer: length=%u, actlen=%u, flags=%#x, timeout=%u,",
xfer->ux_length, xfer->ux_actlen, xfer->ux_flags, xfer->ux_timeout);
- if (xfer->ux_dmabuf.block)
- DDOLOG("buffer=%p", xfer->ux_buf, 0,0,0);
+ DDOLOG("buffer=%p", xfer->ux_buf, 0,0,0);
slhci_log_req_hub(&xfer->ux_request);
}
void
slhci_log_spipe(struct slhci_pipe *spipe)
{
+ SLHCIHIST_FUNC(); SLHCIHIST_CALLED();
DDOLOG("spipe %p onlists: %s %s %s", spipe, gcq_onlist(&spipe->ap) ?
"AP" : "", gcq_onlist(&spipe->to) ? "TO" : "",
gcq_onlist(&spipe->xq) ? "XQ" : "");
Index: src/sys/dev/usb/files.usb
diff -u src/sys/dev/usb/files.usb:1.138 src/sys/dev/usb/files.usb:1.139
--- src/sys/dev/usb/files.usb:1.138 Sat Apr 23 10:15:31 2016
+++ src/sys/dev/usb/files.usb Tue Apr 26 10:38:43 2016
@@ -1,4 +1,4 @@
-# $NetBSD: files.usb,v 1.138 2016/04/23 10:15:31 skrll Exp $
+# $NetBSD: files.usb,v 1.139 2016/04/26 10:38:43 skrll Exp $
#
# Config file and device description for machine-independent USB code.
# Included by ports that need it. Ports that use it must provide
@@ -18,6 +18,7 @@ defflag opt_usb.h UHCI_DEBUG: USB_DEBUG
defflag opt_usb.h DWC2_DEBUG: USB_DEBUG
defflag opt_usb.h XHCI_DEBUG: USB_DEBUG
defflag opt_usb.h MOTG_DEBUG: USB_DEBUG
+defflag opt_usb.h SLHCI_DEBUG: USB_DEBUG
# HUB driver
defflag opt_usb.h UHUB_DEBUG: USB_DEBUG