Improve USB debugging with USBHIST based on KERNHIST.
Convert some DPRINTFs to USBHIST_LOG and allow usbdebug, ehcidebug and umassdebug to be changed via sysctl. Remove the #define mess in usb.h. This was started by mrg@ and updated by reinoud@
This commit is contained in:
parent
f6dcbec3a9
commit
7c2a9a0993
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,95 @@
|
||||
# $NetBSD: files.usb,v 1.133 2014/08/12 13:28:44 skrll Exp $
|
||||
# $NetBSD: files.usb,v 1.134 2014/09/12 16:40:38 skrll Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent USB code.
|
||||
# Included by ports that need it. Ports that use it must provide
|
||||
# their own "major" declarations for the appropriate devices.
|
||||
|
||||
defflag USBVERBOSE
|
||||
defparam opt_usb.h USBHIST_SIZE
|
||||
defflag opt_usb.h USB_FRAG_DMA_WORKAROUND
|
||||
defflag opt_usb.h UHUB_DEBUG USB_DEBUG
|
||||
defflag opt_usb.h EHCI_DEBUG OHCI_DEBUG UHCI_DEBUG XHCI_DEBUG
|
||||
|
||||
defflag opt_umodem.h UMODEM_DEBUG
|
||||
defflag opt_uvideo.h UVIDEO_DEBUG
|
||||
defflag opt_umass.h UMASS_DEBUG
|
||||
defflag opt_uatp.h UATP_DEBUG
|
||||
# top level usb debug defines
|
||||
defflag opt_usb.h USBHIST: KERNHIST
|
||||
defflag opt_usb.h USB_DEBUG: USBHIST
|
||||
|
||||
# HC controllers
|
||||
defflag opt_usb.h EHCI_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h OHCI_DEBUG: USB_DEBUG
|
||||
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
|
||||
|
||||
# HUB driver
|
||||
defflag opt_usb.h UHUB_DEBUG: USB_DEBUG
|
||||
|
||||
# Device drivers
|
||||
|
||||
defflag opt_usb.h ATU_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h AUE_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h AUVITEK_I2C_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h AXE_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h AXEN_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h CUE_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h EZLOAD_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h KUE_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h OTUS_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h RUM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h RUN_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UARK_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UATP_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UAUDIO_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UBERRY_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UBSA_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UBT_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UCHCOM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UCOM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UCYCOM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UDAV_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UDL_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UDSBR_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UFTDI_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UGENSA_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UGEN_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UHIDEV_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UHID_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UHMODEM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UHSO_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UIPAD_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UIPAQ_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UIRDA_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UISDATA_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UKBD_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UKYOPON_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h ULPT_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UMASS_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UMCT_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UMIDIQUIRK_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UMIDI_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UMODEM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UMS_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UPGT_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UPLCOM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UPL_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h URAL_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h URIO_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h URL_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h URNDIS_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h URTWN_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h URTW_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h USCANNER_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h USLSA_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h USSCANNER_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h USTIR_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UTHUM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UTOPPY_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UTS_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UVIDEO_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UVISOR_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UVSCOM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UYUREX_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h UZCOM_DEBUG: USB_DEBUG
|
||||
defflag opt_usb.h ZYD_DEBUG: USB_DEBUG
|
||||
|
||||
define usbroothubif { }
|
||||
define usbdevif { [port = -1], [configuration = -1], [interface = -1],
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_smsc.c,v 1.19 2014/08/10 16:44:36 tls Exp $ */
|
||||
/* $NetBSD: if_smsc.c,v 1.20 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
|
||||
@ -61,6 +61,7 @@
|
||||
*/
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
#include "opt_inet.h"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umass.c,v 1.148 2013/12/22 18:30:21 mlelstv Exp $ */
|
||||
/* $NetBSD: umass.c,v 1.149 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
@ -124,10 +124,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.148 2013/12/22 18:30:21 mlelstv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.149 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_umass.h"
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
#include "atapibus.h"
|
||||
@ -141,11 +141,13 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.148 2013/12/22 18:30:21 mlelstv Exp $");
|
||||
#include <sys/buf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
#include <dev/usb/usbdi_util.h>
|
||||
#include <dev/usb/usbdevs.h>
|
||||
#include <dev/usb/usbhist.h>
|
||||
|
||||
#include <dev/usb/umassvar.h>
|
||||
#include <dev/usb/umass_quirks.h>
|
||||
@ -155,10 +157,36 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.148 2013/12/22 18:30:21 mlelstv Exp $");
|
||||
#include <dev/scsipi/scsipi_all.h>
|
||||
#include <dev/scsipi/scsipiconf.h>
|
||||
|
||||
|
||||
#ifdef UMASS_DEBUG
|
||||
#ifdef USB_DEBUG
|
||||
int umassdebug = 0;
|
||||
|
||||
SYSCTL_SETUP(sysctl_hw_umass_setup, "sysctl hw.umass setup")
|
||||
{
|
||||
int err;
|
||||
const struct sysctlnode *rnode;
|
||||
const struct sysctlnode *cnode;
|
||||
|
||||
err = sysctl_createv(clog, 0, NULL, &rnode,
|
||||
CTLFLAG_PERMANENT, CTLTYPE_NODE, "umass",
|
||||
SYSCTL_DESCR("umass 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, &umassdebug, sizeof(umassdebug), CTL_CREATE, CTL_EOL);
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
return;
|
||||
fail:
|
||||
aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
|
||||
}
|
||||
|
||||
const char *states[TSTATE_STATES+1] = {
|
||||
/* should be kept in sync with the list at transfer_state */
|
||||
"Idle",
|
||||
@ -786,6 +814,8 @@ umass_setup_transfer(struct umass_softc *sc, usbd_pipe_handle pipe,
|
||||
{
|
||||
usbd_status err;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(umassdebug);
|
||||
|
||||
if (sc->sc_dying)
|
||||
return (USBD_IOERROR);
|
||||
|
||||
@ -794,6 +824,8 @@ umass_setup_transfer(struct umass_softc *sc, usbd_pipe_handle pipe,
|
||||
usbd_setup_xfer(xfer, pipe, (void *)sc, buffer, buflen,
|
||||
flags, sc->timeout, sc->sc_methods->wire_state);
|
||||
|
||||
USBHIST_LOG(umassdebug, "xfer %p, flags %d", xfer, flags, 0, 0);
|
||||
|
||||
err = usbd_transfer(xfer);
|
||||
DPRINTF(UDMASS_XFER,("%s: start xfer buffer=%p buflen=%d flags=0x%x "
|
||||
"timeout=%d\n", device_xname(sc->sc_dev),
|
||||
@ -1037,6 +1069,8 @@ umass_bbb_state(usbd_xfer_handle xfer, usbd_private_handle priv,
|
||||
usbd_xfer_handle next_xfer;
|
||||
int residue;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(umassdebug);
|
||||
|
||||
KASSERTMSG(sc->sc_wire & UMASS_WPROTO_BBB,
|
||||
"sc->sc_wire == 0x%02x wrong for umass_bbb_state\n",
|
||||
sc->sc_wire);
|
||||
@ -1059,6 +1093,9 @@ umass_bbb_state(usbd_xfer_handle xfer, usbd_private_handle priv,
|
||||
device_xname(sc->sc_dev), sc->transfer_state,
|
||||
states[sc->transfer_state], xfer, usbd_errstr(err)));
|
||||
|
||||
USBHIST_LOG(umassdebug, "xfer %p, transfer_state %d dir %d", xfer,
|
||||
sc->transfer_state, sc->transfer_dir, 0);
|
||||
|
||||
switch (sc->transfer_state) {
|
||||
|
||||
/***** Bulk Transfer *****/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umass_isdata.c,v 1.29 2013/10/30 15:37:49 drochner Exp $ */
|
||||
/* $NetBSD: umass_isdata.c,v 1.30 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
@ -37,11 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.29 2013/10/30 15:37:49 drochner Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_umass.h"
|
||||
#endif
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.30 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umass_quirks.c,v 1.95 2013/05/14 14:03:53 kiyohara Exp $ */
|
||||
/* $NetBSD: umass_quirks.c,v 1.96 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
|
||||
@ -32,11 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_quirks.c,v 1.95 2013/05/14 14:03:53 kiyohara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_umass.h"
|
||||
#endif
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_quirks.c,v 1.96 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umass_scsipi.c,v 1.48 2013/01/05 14:54:06 christos Exp $ */
|
||||
/* $NetBSD: umass_scsipi.c,v 1.49 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
|
||||
@ -31,10 +31,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.48 2013/01/05 14:54:06 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.49 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_umass.h"
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
#include "atapibus.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb.c,v 1.155 2014/08/12 13:36:40 skrll Exp $ */
|
||||
/* $NetBSD: usb.c,v 1.156 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
|
||||
@ -37,9 +37,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.155 2014/08/12 13:36:40 skrll Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.156 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
#include "opt_compat_netbsd.h"
|
||||
#endif
|
||||
|
||||
@ -62,6 +63,7 @@ __KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.155 2014/08/12 13:36:40 skrll Exp $");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/once.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
@ -69,6 +71,16 @@ __KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.155 2014/08/12 13:36:40 skrll Exp $");
|
||||
#include <dev/usb/usbdivar.h>
|
||||
#include <dev/usb/usb_verbose.h>
|
||||
#include <dev/usb/usb_quirks.h>
|
||||
#include <dev/usb/usbhist.h>
|
||||
|
||||
#if defined(USBHIST)
|
||||
|
||||
USBHIST_DEFINE(usbhist);
|
||||
#ifndef USBHIST_SIZE
|
||||
#define USBHIST_SIZE 50000
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define USB_DEV_MINOR 255
|
||||
|
||||
@ -82,6 +94,34 @@ int usbdebug = 0;
|
||||
* >1 - do no exploration
|
||||
*/
|
||||
int usb_noexplore = 0;
|
||||
|
||||
SYSCTL_SETUP(sysctl_hw_usb_setup, "sysctl hw.usb setup")
|
||||
{
|
||||
int err;
|
||||
const struct sysctlnode *rnode;
|
||||
const struct sysctlnode *cnode;
|
||||
|
||||
err = sysctl_createv(clog, 0, NULL, &rnode,
|
||||
CTLFLAG_PERMANENT, CTLTYPE_NODE, "usb",
|
||||
SYSCTL_DESCR("usb 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, &usbdebug, sizeof(usbdebug), CTL_CREATE, CTL_EOL);
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
return;
|
||||
fail:
|
||||
aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
|
||||
}
|
||||
|
||||
#else
|
||||
#define DPRINTF(x)
|
||||
#define DPRINTFN(n,x)
|
||||
@ -235,6 +275,8 @@ usb_once_init(void)
|
||||
struct usb_taskq *taskq;
|
||||
int i;
|
||||
|
||||
USBHIST_INIT(usbhist, USBHIST_SIZE);
|
||||
|
||||
selinit(&usb_selevent);
|
||||
mutex_init(&usb_event_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&usb_event_cv, "usbrea");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb.h,v 1.109 2014/08/12 14:22:51 skrll Exp $ */
|
||||
/* $NetBSD: usb.h,v 1.110 2014/09/12 16:40:38 skrll Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -40,10 +40,6 @@
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_usb.h" /* for USB_DEBUG */
|
||||
#endif
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#include <sys/mallocvar.h>
|
||||
|
||||
@ -56,78 +52,6 @@ MALLOC_DECLARE(M_USBHC);
|
||||
#endif
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
#define ATU_DEBUG 1
|
||||
#define AUE_DEBUG 1
|
||||
#define AUVITEK_I2C_DEBUG 1
|
||||
#define AXE_DEBUG 1
|
||||
#define AXEN_DEBUG 1
|
||||
#define CUE_DEBUG 1
|
||||
#define DWC2_DEBUG 1
|
||||
#define EHCI_DEBUG 1
|
||||
#define EZLOAD_DEBUG 1
|
||||
#define KUE_DEBUG 1
|
||||
#define OHCI_DEBUG 1
|
||||
#define OTUS_DEBUG 1
|
||||
#define RUM_DEBUG 1
|
||||
#define RUN_DEBUG 1
|
||||
#define UARK_DEBUG 1
|
||||
#define UATP_DEBUG 1
|
||||
#define UAUDIO_DEBUG 1
|
||||
#define UBERRY_DEBUG 1
|
||||
#define UBSA_DEBUG 1
|
||||
#define UBT_DEBUG 1
|
||||
#define UCHCOM_DEBUG 1
|
||||
#define UCOM_DEBUG 1
|
||||
#define UCYCOM_DEBUG 1
|
||||
#define UDAV_DEBUG 1
|
||||
#define UDL_DEBUG 1
|
||||
#define UDSBR_DEBUG 1
|
||||
#define UFTDI_DEBUG 1
|
||||
#define UGENSA_DEBUG 1
|
||||
#define UGEN_DEBUG 1
|
||||
#define UHCI_DEBUG 1
|
||||
#define UHIDEV_DEBUG 1
|
||||
#define UHID_DEBUG 1
|
||||
#define UHMODEM_DEBUG 1
|
||||
#define UHSO_DEBUG 1
|
||||
#define UHUB_DEBUG 1
|
||||
#define UIPAD_DEBUG 1
|
||||
#define UIPAQ_DEBUG 1
|
||||
#define UIRDA_DEBUG 1
|
||||
#define UISDATA_DEBUG 1
|
||||
#define UKBD_DEBUG 1
|
||||
#define UKYOPON_DEBUG 1
|
||||
#define ULPT_DEBUG 1
|
||||
#define UMASS_DEBUG 1
|
||||
#define UMCT_DEBUG 1
|
||||
#define UMIDIQUIRK_DEBUG 1
|
||||
#define UMIDI_DEBUG 1
|
||||
#define UMODEM_DEBUG 1
|
||||
#define UMS_DEBUG 1
|
||||
#define UPGT_DEBUG 1
|
||||
#define UPLCOM_DEBUG 1
|
||||
#define UPL_DEBUG 1
|
||||
#define URAL_DEBUG 1
|
||||
#define URIO_DEBUG 1
|
||||
#define URL_DEBUG 1
|
||||
#define URNDIS_DEBUG 1
|
||||
#define URTWN_DEBUG 1
|
||||
#define URTW_DEBUG 1
|
||||
#define USB_DEBUG 1
|
||||
#define USCANNER_DEBUG 1
|
||||
#define USLSA_DEBUG 1
|
||||
#define USSCANNER_DEBUG 1
|
||||
#define USTIR_DEBUG 1
|
||||
#define UTHUM_DEBUG 1
|
||||
#define UTOPPY_DEBUG 1
|
||||
#define UTS_DEBUG 1
|
||||
#define UVIDEO_DEBUG 1
|
||||
#define UVISOR_DEBUG 1
|
||||
#define UVSCOM_DEBUG 1
|
||||
#define UYUREX_DEBUG 1
|
||||
#define UZCOM_DEBUG 1
|
||||
#define XHCI_DEBUG 1
|
||||
#define ZYD_DEBUG 1
|
||||
#define Static
|
||||
#else
|
||||
#define Static static
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb_mem.c,v 1.64 2013/12/22 18:29:25 mlelstv Exp $ */
|
||||
/* $NetBSD: usb_mem.c,v 1.65 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,11 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.64 2013/12/22 18:29:25 mlelstv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.65 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb_quirks.c,v 1.80 2013/11/14 16:33:20 nonaka Exp $ */
|
||||
/* $NetBSD: usb_quirks.c,v 1.81 2014/09/12 16:40:38 skrll Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $ */
|
||||
|
||||
/*
|
||||
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.80 2013/11/14 16:33:20 nonaka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.81 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb_subr.c,v 1.196 2014/02/17 07:34:21 skrll Exp $ */
|
||||
/* $NetBSD: usb_subr.c,v 1.197 2014/09/12 16:40:38 skrll Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -32,10 +32,11 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.196 2014/02/17 07:34:21 skrll Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.197 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_usb.h"
|
||||
#include "opt_usbverbose.h"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usbdi.c,v 1.161 2014/08/05 06:35:24 skrll Exp $ */
|
||||
/* $NetBSD: usbdi.c,v 1.162 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
|
||||
@ -31,9 +31,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.161 2014/08/05 06:35:24 skrll Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
#include "opt_compat_netbsd.h"
|
||||
#endif
|
||||
|
||||
@ -52,18 +53,12 @@ __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.161 2014/08/05 06:35:24 skrll Exp $");
|
||||
#include <dev/usb/usbdivar.h>
|
||||
#include <dev/usb/usb_mem.h>
|
||||
#include <dev/usb/usb_quirks.h>
|
||||
#include <dev/usb/usbhist.h>
|
||||
|
||||
/* UTF-8 encoding stuff */
|
||||
#include <fs/unicode.h>
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
#define DPRINTF(x) if (usbdebug) printf x
|
||||
#define DPRINTFN(n,x) if (usbdebug>(n)) printf x
|
||||
extern int usbdebug;
|
||||
#else
|
||||
#define DPRINTF(x)
|
||||
#define DPRINTFN(n,x)
|
||||
#endif
|
||||
|
||||
Static usbd_status usbd_ar_pipe(usbd_pipe_handle);
|
||||
Static void usbd_start_next(usbd_pipe_handle);
|
||||
@ -80,41 +75,51 @@ usbd_xfer_isread(usbd_xfer_handle xfer)
|
||||
UE_DIR_IN);
|
||||
}
|
||||
|
||||
#if defined(USB_DEBUG) || defined(EHCI_DEBUG) || defined(OHCI_DEBUG)
|
||||
#if defined(USB_DEBUG)
|
||||
void
|
||||
usbd_dump_iface(struct usbd_interface *iface)
|
||||
{
|
||||
printf("usbd_dump_iface: iface=%p\n", iface);
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "iface %p\n", iface, 0, 0, 0);
|
||||
if (iface == NULL)
|
||||
return;
|
||||
printf(" device=%p idesc=%p index=%d altindex=%d priv=%p\n",
|
||||
iface->device, iface->idesc, iface->index, iface->altindex,
|
||||
iface->priv);
|
||||
USBHIST_LOG(usbdebug, " device = %p idesc = %p index = %d",
|
||||
iface->device, iface->idesc, iface->index, 0);
|
||||
USBHIST_LOG(usbdebug, " altindex=%d priv=%p",
|
||||
iface->altindex, iface->priv, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
usbd_dump_device(struct usbd_device *dev)
|
||||
{
|
||||
printf("usbd_dump_device: dev=%p\n", dev);
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "dev = %p", dev, 0, 0, 0);
|
||||
if (dev == NULL)
|
||||
return;
|
||||
printf(" bus=%p default_pipe=%p\n", dev->bus, dev->default_pipe);
|
||||
printf(" address=%d config=%d depth=%d speed=%d self_powered=%d "
|
||||
"power=%d langid=%d\n",
|
||||
dev->address, dev->config, dev->depth, dev->speed,
|
||||
dev->self_powered, dev->power, dev->langid);
|
||||
USBHIST_LOG(usbdebug, " bus = %p default_pipe = %p",
|
||||
dev->bus, dev->default_pipe, 0, 0);
|
||||
USBHIST_LOG(usbdebug, " address = %d config = %d depth = %d ",
|
||||
dev->address, dev->config, dev->depth, 0);
|
||||
USBHIST_LOG(usbdebug, " speed = %d self_powered = %d "
|
||||
"power = %d langid = %d",
|
||||
dev->speed, dev->self_powered, dev->power, dev->langid);
|
||||
}
|
||||
|
||||
void
|
||||
usbd_dump_endpoint(struct usbd_endpoint *endp)
|
||||
{
|
||||
printf("usbd_dump_endpoint: endp=%p\n", endp);
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "endp = %p", endp, 0, 0, 0);
|
||||
if (endp == NULL)
|
||||
return;
|
||||
printf(" edesc=%p refcnt=%d\n", endp->edesc, endp->refcnt);
|
||||
USBHIST_LOG(usbdebug, " edesc = %p refcnt = %d",
|
||||
endp->edesc, endp->refcnt, 0, 0);
|
||||
if (endp->edesc)
|
||||
printf(" bEndpointAddress=0x%02x\n",
|
||||
endp->edesc->bEndpointAddress);
|
||||
USBHIST_LOG(usbdebug, " bEndpointAddress=0x%02x",
|
||||
endp->edesc->bEndpointAddress, 0, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -122,25 +127,30 @@ usbd_dump_queue(usbd_pipe_handle pipe)
|
||||
{
|
||||
usbd_xfer_handle xfer;
|
||||
|
||||
printf("usbd_dump_queue: pipe=%p\n", pipe);
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "pipe = %p", pipe, 0, 0, 0);
|
||||
SIMPLEQ_FOREACH(xfer, &pipe->queue, next) {
|
||||
printf(" xfer=%p\n", xfer);
|
||||
USBHIST_LOG(usbdebug, " xfer = %p", xfer, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
usbd_dump_pipe(usbd_pipe_handle pipe)
|
||||
{
|
||||
printf("usbd_dump_pipe: pipe=%p\n", pipe);
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "pipe = %p", pipe, 0, 0, 0);
|
||||
if (pipe == NULL)
|
||||
return;
|
||||
usbd_dump_iface(pipe->iface);
|
||||
usbd_dump_device(pipe->device);
|
||||
usbd_dump_endpoint(pipe->endpoint);
|
||||
printf(" (usbd_dump_pipe:)\n refcnt=%d running=%d aborting=%d\n",
|
||||
pipe->refcnt, pipe->running, pipe->aborting);
|
||||
printf(" intrxfer=%p, repeat=%d, interval=%d\n",
|
||||
pipe->intrxfer, pipe->repeat, pipe->interval);
|
||||
USBHIST_LOG(usbdebug, "(usbd_dump_pipe)", 0, 0, 0, 0);
|
||||
USBHIST_LOG(usbdebug, " refcnt = %d running = %d aborting = %d",
|
||||
pipe->refcnt, pipe->running, pipe->aborting, 0);
|
||||
USBHIST_LOG(usbdebug, " intrxfer = %p, repeat = %d, interval = %d",
|
||||
pipe->intrxfer, pipe->repeat, pipe->interval, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -161,8 +171,10 @@ usbd_open_pipe_ival(usbd_interface_handle iface, u_int8_t address,
|
||||
usbd_status err;
|
||||
int i;
|
||||
|
||||
DPRINTFN(3,("usbd_open_pipe: iface=%p address=0x%x flags=0x%x\n",
|
||||
iface, address, flags));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "iface = %p address = 0x%x flags = 0x%x",
|
||||
iface, address, flags, 0);
|
||||
|
||||
for (i = 0; i < iface->idesc->bNumEndpoints; i++) {
|
||||
ep = &iface->endpoints[i];
|
||||
@ -193,8 +205,10 @@ usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address,
|
||||
usbd_xfer_handle xfer;
|
||||
usbd_pipe_handle ipipe;
|
||||
|
||||
DPRINTFN(3,("usbd_open_pipe_intr: address=0x%x flags=0x%x len=%d\n",
|
||||
address, flags, len));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "address = 0x%x flags = 0x%x len = %d",
|
||||
address, flags, len, 0);
|
||||
|
||||
err = usbd_open_pipe_ival(iface, address,
|
||||
USBD_EXCLUSIVE_USE | (flags & USBD_MPSAFE),
|
||||
@ -229,9 +243,11 @@ usbd_status
|
||||
usbd_close_pipe(usbd_pipe_handle pipe)
|
||||
{
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (pipe == NULL) {
|
||||
printf("usbd_close_pipe: pipe==NULL\n");
|
||||
USBHIST_LOG(usbdebug, "pipe == NULL", 0, 0, 0, 0);
|
||||
return (USBD_NORMAL_COMPLETION);
|
||||
}
|
||||
#endif
|
||||
@ -263,8 +279,11 @@ usbd_transfer(usbd_xfer_handle xfer)
|
||||
usbd_status err;
|
||||
unsigned int size, flags;
|
||||
|
||||
DPRINTFN(5,("usbd_transfer: xfer=%p, flags=%#x, pipe=%p, running=%d\n",
|
||||
xfer, xfer->flags, pipe, pipe->running));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug,
|
||||
"xfer = %p, flags = %#x, pipe = %p, running = %d",
|
||||
xfer, xfer->flags, pipe, pipe->running);
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
if (usbdebug > 5)
|
||||
@ -272,8 +291,11 @@ usbd_transfer(usbd_xfer_handle xfer)
|
||||
#endif
|
||||
xfer->done = 0;
|
||||
|
||||
if (pipe->aborting)
|
||||
if (pipe->aborting) {
|
||||
USBHIST_LOG(usbdebug, "<- done xfer %p, aborting", xfer, 0, 0,
|
||||
0);
|
||||
return (USBD_CANCELLED);
|
||||
}
|
||||
|
||||
size = xfer->length;
|
||||
/* If there is no buffer, allocate one. */
|
||||
@ -285,8 +307,11 @@ usbd_transfer(usbd_xfer_handle xfer)
|
||||
printf("usbd_transfer: has old buffer!\n");
|
||||
#endif
|
||||
err = bus->methods->allocm(bus, dmap, size);
|
||||
if (err)
|
||||
if (err) {
|
||||
USBHIST_LOG(usbdebug,
|
||||
"<- done xfer %p, no mem", xfer, 0, 0, 0);
|
||||
return (err);
|
||||
}
|
||||
xfer->rqflags |= URQ_AUTO_DMABUF;
|
||||
}
|
||||
|
||||
@ -298,6 +323,7 @@ usbd_transfer(usbd_xfer_handle xfer)
|
||||
|
||||
/* xfer is not valid after the transfer method unless synchronous */
|
||||
err = pipe->methods->transfer(xfer);
|
||||
USBHIST_LOG(usbdebug, "<- done transfer %p, err = %d", xfer, err, 0, 0);
|
||||
|
||||
if (err != USBD_IN_PROGRESS && err) {
|
||||
/* The transfer has not been queued, so free buffer. */
|
||||
@ -309,16 +335,23 @@ usbd_transfer(usbd_xfer_handle xfer)
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & USBD_SYNCHRONOUS))
|
||||
if (!(flags & USBD_SYNCHRONOUS)) {
|
||||
USBHIST_LOG(usbdebug, "<- done xfer %p, not sync", xfer, 0, 0,
|
||||
0);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* Sync transfer, wait for completion. */
|
||||
if (err != USBD_IN_PROGRESS)
|
||||
if (err != USBD_IN_PROGRESS) {
|
||||
USBHIST_LOG(usbdebug, "<- done xfer %p, not in progress", xfer,
|
||||
0, 0, 0);
|
||||
return (err);
|
||||
}
|
||||
usbd_lock_pipe(pipe);
|
||||
while (!xfer->done) {
|
||||
if (pipe->device->bus->use_polling)
|
||||
panic("usbd_transfer: not done");
|
||||
USBHIST_LOG(usbdebug, "<- sleeping on xfer %p", xfer, 0, 0, 0);
|
||||
|
||||
err = 0;
|
||||
if ((flags & USBD_SYNCHRONOUS_SIG) != 0) {
|
||||
@ -395,6 +428,8 @@ usbd_alloc_xfer(usbd_device_handle dev)
|
||||
{
|
||||
usbd_xfer_handle xfer;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
xfer = dev->bus->methods->allocx(dev->bus);
|
||||
if (xfer == NULL)
|
||||
return (NULL);
|
||||
@ -402,14 +437,18 @@ usbd_alloc_xfer(usbd_device_handle dev)
|
||||
callout_init(&xfer->timeout_handle, CALLOUT_MPSAFE);
|
||||
cv_init(&xfer->cv, "usbxfer");
|
||||
cv_init(&xfer->hccv, "usbhcxfer");
|
||||
DPRINTFN(5,("usbd_alloc_xfer() = %p\n", xfer));
|
||||
|
||||
USBHIST_LOG(usbdebug, "returns %p", xfer, 0, 0, 0);
|
||||
|
||||
return (xfer);
|
||||
}
|
||||
|
||||
usbd_status
|
||||
usbd_free_xfer(usbd_xfer_handle xfer)
|
||||
{
|
||||
DPRINTFN(5,("usbd_free_xfer: %p\n", xfer));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "%p", xfer, 0, 0, 0);
|
||||
if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))
|
||||
usbd_free_buffer(xfer);
|
||||
#if defined(DIAGNOSTIC)
|
||||
@ -568,7 +607,7 @@ usbd_clear_endpoint_stall(usbd_pipe_handle pipe)
|
||||
usb_device_request_t req;
|
||||
usbd_status err;
|
||||
|
||||
DPRINTFN(8, ("usbd_clear_endpoint_stall\n"));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
/*
|
||||
* Clearing en endpoint stall resets the endpoint toggle, so
|
||||
@ -749,9 +788,11 @@ usbd_ar_pipe(usbd_pipe_handle pipe)
|
||||
{
|
||||
usbd_xfer_handle xfer;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
KASSERT(mutex_owned(pipe->device->bus->lock));
|
||||
|
||||
DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe));
|
||||
USBHIST_LOG(usbdebug, "pipe = %p", pipe, 0, 0, 0);
|
||||
#ifdef USB_DEBUG
|
||||
if (usbdebug > 5)
|
||||
usbd_dump_queue(pipe);
|
||||
@ -759,8 +800,8 @@ usbd_ar_pipe(usbd_pipe_handle pipe)
|
||||
pipe->repeat = 0;
|
||||
pipe->aborting = 1;
|
||||
while ((xfer = SIMPLEQ_FIRST(&pipe->queue)) != NULL) {
|
||||
DPRINTFN(2,("usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n",
|
||||
pipe, xfer, pipe->methods));
|
||||
USBHIST_LOG(usbdebug, "pipe = %p xfer = %p (methods = %p)",
|
||||
pipe, xfer, pipe->methods, 0);
|
||||
/* Make the HC abort it (and invoke the callback). */
|
||||
pipe->methods->abort(xfer);
|
||||
/* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
|
||||
@ -781,8 +822,10 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
int polling = pipe->device->bus->use_polling;
|
||||
int repeat;
|
||||
|
||||
DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
|
||||
"actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "pipe = %p xfer = %p status = %d actlen = %d",
|
||||
pipe, xfer, xfer->status, xfer->actlen);
|
||||
|
||||
KASSERT(polling || mutex_owned(pipe->device->bus->lock));
|
||||
|
||||
@ -839,8 +882,8 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
#endif
|
||||
SIMPLEQ_REMOVE_HEAD(&pipe->queue, next);
|
||||
}
|
||||
DPRINTFN(5,("usb_transfer_complete: repeat=%d new head=%p\n",
|
||||
repeat, SIMPLEQ_FIRST(&pipe->queue)));
|
||||
USBHIST_LOG(usbdebug, "xfer %p: repeat %d new head = %p",
|
||||
xfer, repeat, SIMPLEQ_FIRST(&pipe->queue), 0);
|
||||
|
||||
/* Count completed transfers. */
|
||||
++pipe->device->bus->stats.uds_requests
|
||||
@ -849,12 +892,14 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
xfer->done = 1;
|
||||
if (!xfer->status && xfer->actlen < xfer->length &&
|
||||
!(xfer->flags & USBD_SHORT_XFER_OK)) {
|
||||
DPRINTFN(-1,("usb_transfer_complete: short transfer %d<%d\n",
|
||||
xfer->actlen, xfer->length));
|
||||
USBHIST_LOG(usbdebug, "short transfer %d < %d",
|
||||
xfer->actlen, xfer->length, 0, 0);
|
||||
xfer->status = USBD_SHORT_XFER;
|
||||
}
|
||||
|
||||
if (repeat) {
|
||||
USBHIST_LOG(usbdebug, "xfer %p doing callback %p status %x",
|
||||
xfer, xfer->callback, xfer->status, 0);
|
||||
if (xfer->callback) {
|
||||
if (!polling)
|
||||
mutex_exit(pipe->device->bus->lock);
|
||||
@ -862,6 +907,8 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
if (!(pipe->flags & USBD_MPSAFE))
|
||||
KERNEL_LOCK(1, curlwp);
|
||||
xfer->callback(xfer, xfer->priv, xfer->status);
|
||||
USBHIST_LOG(usbdebug, "xfer %p doing done %p", xfer,
|
||||
pipe->methods->done, 0, 0);
|
||||
if (!(pipe->flags & USBD_MPSAFE))
|
||||
KERNEL_UNLOCK_ONE(curlwp);
|
||||
|
||||
@ -870,7 +917,11 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
}
|
||||
pipe->methods->done(xfer);
|
||||
} else {
|
||||
USBHIST_LOG(usbdebug, "xfer %p doing done %p", xfer,
|
||||
pipe->methods->done, 0, 0);
|
||||
pipe->methods->done(xfer);
|
||||
USBHIST_LOG(usbdebug, "xfer %p doing callback %p status %x",
|
||||
xfer, xfer->callback, xfer->status, 0);
|
||||
if (xfer->callback) {
|
||||
if (!polling)
|
||||
mutex_exit(pipe->device->bus->lock);
|
||||
@ -887,6 +938,7 @@ usb_transfer_complete(usbd_xfer_handle xfer)
|
||||
}
|
||||
|
||||
if (sync && !polling) {
|
||||
USBHIST_LOG(usbdebug, "<- done xfer %p, wakeup", xfer, 0, 0, 0);
|
||||
cv_broadcast(&xfer->cv);
|
||||
}
|
||||
|
||||
@ -906,13 +958,17 @@ usb_insert_transfer(usbd_xfer_handle xfer)
|
||||
usbd_pipe_handle pipe = xfer->pipe;
|
||||
usbd_status err;
|
||||
|
||||
DPRINTFN(5,("usb_insert_transfer: pipe=%p running=%d timeout=%d\n",
|
||||
pipe, pipe->running, xfer->timeout));
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
USBHIST_LOG(usbdebug, "pipe = %p running = %d timeout = %d",
|
||||
pipe, pipe->running, xfer->timeout, 0);
|
||||
|
||||
KASSERT(mutex_owned(pipe->device->bus->lock));
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (xfer->busy_free != XFER_BUSY) {
|
||||
USBHIST_LOG(usbdebug, "<- done, xfer %p not busy", xfer, 0, 0,
|
||||
0);
|
||||
printf("usb_insert_transfer: xfer=%p not busy 0x%08x\n",
|
||||
xfer, xfer->busy_free);
|
||||
return (USBD_INVAL);
|
||||
@ -926,6 +982,7 @@ usb_insert_transfer(usbd_xfer_handle xfer)
|
||||
pipe->running = 1;
|
||||
err = USBD_NORMAL_COMPLETION;
|
||||
}
|
||||
USBHIST_LOG(usbdebug, "<- done xfer %p, err %d", xfer, err, 0, 0);
|
||||
return (err);
|
||||
}
|
||||
|
||||
@ -936,6 +993,8 @@ usbd_start_next(usbd_pipe_handle pipe)
|
||||
usbd_xfer_handle xfer;
|
||||
usbd_status err;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (pipe == NULL) {
|
||||
printf("usbd_start_next: pipe == NULL\n");
|
||||
@ -951,7 +1010,7 @@ usbd_start_next(usbd_pipe_handle pipe)
|
||||
|
||||
/* Get next request in queue. */
|
||||
xfer = SIMPLEQ_FIRST(&pipe->queue);
|
||||
DPRINTFN(5, ("usbd_start_next: pipe=%p, xfer=%p\n", pipe, xfer));
|
||||
USBHIST_LOG(usbdebug, "pipe = %p, xfer = %p", pipe, xfer, 0, 0);
|
||||
if (xfer == NULL) {
|
||||
pipe->running = 0;
|
||||
} else {
|
||||
@ -960,7 +1019,7 @@ usbd_start_next(usbd_pipe_handle pipe)
|
||||
mutex_enter(pipe->device->bus->lock);
|
||||
|
||||
if (err != USBD_IN_PROGRESS) {
|
||||
printf("usbd_start_next: error=%d\n", err);
|
||||
USBHIST_LOG(usbdebug, "error = %d", err, 0, 0, 0);
|
||||
pipe->running = 0;
|
||||
/* XXX do what? */
|
||||
}
|
||||
@ -992,9 +1051,11 @@ usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
|
||||
usbd_xfer_handle xfer;
|
||||
usbd_status err;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (cpu_intr_p() || cpu_softintr_p()) {
|
||||
printf("usbd_do_request: not in process context\n");
|
||||
USBHIST_LOG(usbdebug, "not in process context", 0, 0, 0, 0);
|
||||
return (USBD_INVAL);
|
||||
}
|
||||
#endif
|
||||
@ -1008,13 +1069,14 @@ usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
|
||||
err = usbd_sync_transfer(xfer);
|
||||
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
|
||||
if (xfer->actlen > xfer->length) {
|
||||
DPRINTF(("%s: overrun addr=%d type=0x%02x req=0x"
|
||||
"%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
|
||||
__func__, dev->address, xfer->request.bmRequestType,
|
||||
xfer->request.bRequest, UGETW(xfer->request.wValue),
|
||||
UGETW(xfer->request.wIndex),
|
||||
UGETW(xfer->request.wLength),
|
||||
xfer->length, xfer->actlen));
|
||||
USBHIST_LOG(usbdebug, "overrun addr = %d type = 0x%02x",
|
||||
dev->address, xfer->request.bmRequestType, 0, 0);
|
||||
USBHIST_LOG(usbdebug, " req = 0x%02x val = %d index = %d",
|
||||
xfer->request.bRequest, UGETW(xfer->request.wValue),
|
||||
UGETW(xfer->request.wIndex), 0);
|
||||
USBHIST_LOG(usbdebug, " rlen = %d length = %d actlen = %d",
|
||||
UGETW(xfer->request.wLength),
|
||||
xfer->length, xfer->actlen, 0);
|
||||
}
|
||||
#endif
|
||||
if (actlen != NULL)
|
||||
@ -1042,7 +1104,7 @@ usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
|
||||
if (nerr)
|
||||
goto bad;
|
||||
s = UGETW(status.wStatus);
|
||||
DPRINTF(("usbd_do_request: status = 0x%04x\n", s));
|
||||
USBHIST_LOG(usbdebug, "status = 0x%04x", s, 0, 0, 0);
|
||||
if (!(s & UES_HALT))
|
||||
goto bad;
|
||||
treq.bmRequestType = UT_WRITE_ENDPOINT;
|
||||
@ -1059,7 +1121,8 @@ usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
|
||||
|
||||
bad:
|
||||
if (err) {
|
||||
DPRINTF(("%s: returning err=%s\n", __func__, usbd_errstr(err)));
|
||||
USBHIST_LOG(usbdebug, "returning err = %s",
|
||||
usbd_errstr(err), 0, 0, 0);
|
||||
}
|
||||
usbd_free_xfer(xfer);
|
||||
return (err);
|
||||
@ -1202,6 +1265,8 @@ usbd_get_string0(usbd_device_handle dev, int si, char *buf, int unicode)
|
||||
usbd_status err;
|
||||
int size;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
buf[0] = '\0';
|
||||
if (si == 0)
|
||||
return (USBD_INVAL);
|
||||
@ -1212,7 +1277,8 @@ usbd_get_string0(usbd_device_handle dev, int si, char *buf, int unicode)
|
||||
err = usbd_get_string_desc(dev, USB_LANGUAGE_TABLE, 0, &us,
|
||||
&size);
|
||||
if (err || size < 4) {
|
||||
DPRINTFN(-1,("usbd_get_string: getting lang failed, using 0\n"));
|
||||
USBHIST_LOG(usbdebug, "getting lang failed, using 0",
|
||||
0, 0, 0, 0);
|
||||
dev->langid = 0; /* Well, just pick something then */
|
||||
} else {
|
||||
/* Pick the first language as the default. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll Exp $ */
|
||||
/* $NetBSD: usbdi_util.c,v 1.63 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
|
||||
@ -31,7 +31,11 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.63 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -43,10 +47,10 @@ __KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll Exp $"
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbhid.h>
|
||||
|
||||
#include <dev/usb/usbdi.h>
|
||||
#include <dev/usb/usbdivar.h>
|
||||
#include <dev/usb/usbdi_util.h>
|
||||
#include <dev/usb/usbhist.h>
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
#define DPRINTF(x) if (usbdebug) printf x
|
||||
@ -402,8 +406,9 @@ usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
|
||||
{
|
||||
usbd_status err;
|
||||
|
||||
usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, NULL);
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, NULL);
|
||||
DPRINTFN(1, ("usbd_bulk_transfer: start transfer %d bytes\n", *size));
|
||||
err = usbd_sync_transfer_sig(xfer);
|
||||
|
||||
@ -413,6 +418,7 @@ usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
|
||||
DPRINTF(("usbd_bulk_transfer: error=%d\n", err));
|
||||
usbd_clear_endpoint_stall(pipe);
|
||||
}
|
||||
USBHIST_LOG(usbdebug, "<- done err %d", xfer, err, 0, 0);
|
||||
|
||||
return (err);
|
||||
}
|
||||
@ -424,6 +430,8 @@ usbd_intr_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
|
||||
{
|
||||
usbd_status err;
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, NULL);
|
||||
|
||||
DPRINTFN(1, ("usbd_intr_transfer: start transfer %d bytes\n", *size));
|
||||
@ -436,6 +444,8 @@ usbd_intr_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
|
||||
DPRINTF(("usbd_intr_transfer: error=%d\n", err));
|
||||
usbd_clear_endpoint_stall(pipe);
|
||||
}
|
||||
USBHIST_LOG(usbdebug, "<- done err %d", xfer, err, 0, 0);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
83
sys/dev/usb/usbhist.h
Normal file
83
sys/dev/usb/usbhist.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* $NetBSD: usbhist.h,v 1.1 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 Matthew R. Green
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _DEV_USB_USBHIST_H_
|
||||
#define _DEV_USB_USBHIST_H_
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make USBHIST_PRINT force on KERNHIST_PRINT for at least USBHIST_* usage.
|
||||
*/
|
||||
#if defined(USBHIST_PRINT) && !defined(KERNHIST_PRINT)
|
||||
#define KERNHIST_PRINT 1
|
||||
#endif
|
||||
|
||||
#include <sys/kernhist.h>
|
||||
|
||||
#ifdef USBHIST
|
||||
|
||||
extern int usbdebug;
|
||||
|
||||
#define USBHIST_DECL(NAME) KERNHIST_DECL(NAME)
|
||||
#define USBHIST_DEFINE(NAME) KERNHIST_DEFINE(NAME)
|
||||
#define USBHIST_INIT(NAME,N) KERNHIST_INIT(NAME,N)
|
||||
#define USBHIST_INIT_STATIC(NAME,BUF) KERNHIST_INIT_STATIC(NAME,BUF)
|
||||
#define USBHIST_LOGN(NAME,N,FMT,A,B,C,D) do { \
|
||||
if ((NAME) >= (N)) { \
|
||||
KERNHIST_LOG(usbhist,FMT,A,B,C,D); \
|
||||
} \
|
||||
} while (0)
|
||||
#define USBHIST_LOG(NAME,FMT,A,B,C,D) USBHIST_LOGN(NAME,1,FMT,A,B,C,D)
|
||||
#define USBHIST_CALLED(NAME) do { \
|
||||
if ((NAME) != 0) { \
|
||||
KERNHIST_CALLED(usbhist); \
|
||||
} \
|
||||
} while (0)
|
||||
#define USBHIST_FUNC() KERNHIST_FUNC(__func__)
|
||||
|
||||
USBHIST_DECL(usbhist);
|
||||
|
||||
#else
|
||||
|
||||
#define USBHIST_DECL(NAME)
|
||||
#define USBHIST_DEFINE(NAME)
|
||||
#define USBHIST_INIT(NAME,N)
|
||||
#define USBHIST_INIT_STATIC(NAME,BUF)
|
||||
#define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0)
|
||||
#define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0)
|
||||
#define USBHIST_CALLED(NAME)
|
||||
#define USBHIST_FUNC()
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _DEV_USBUSB_HIST_H_ */
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uvideo.c,v 1.40 2014/01/28 13:43:33 martin Exp $ */
|
||||
/* $NetBSD: uvideo.c,v 1.41 2014/09/12 16:40:38 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Patrick Mahoney
|
||||
@ -42,10 +42,10 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.40 2014/01/28 13:43:33 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.41 2014/09/12 16:40:38 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_uvideo.h"
|
||||
#include "opt_usb.h"
|
||||
#endif
|
||||
|
||||
#ifdef _MODULE
|
||||
|
4
sys/external/bsd/dwc2/conf/files.dwc2
vendored
4
sys/external/bsd/dwc2/conf/files.dwc2
vendored
@ -1,12 +1,10 @@
|
||||
# $NetBSD: files.dwc2,v 1.1 2013/09/05 20:25:27 skrll Exp $
|
||||
# $NetBSD: files.dwc2,v 1.2 2014/09/12 16:40:38 skrll Exp $
|
||||
|
||||
# DesignWare HS OTG Controller
|
||||
#
|
||||
device dwctwo: usbus, usbroothub, usb_dma
|
||||
file external/bsd/dwc2/dwc2.c dwctwo needs-flag
|
||||
|
||||
defflag opt_usb.h DWC2_DEBUG
|
||||
|
||||
makeoptions dwctwo CPPFLAGS+=" -I$S/external/bsd/common/include -I$S/external/bsd -I$S/external/bsd/dwc2/dist"
|
||||
|
||||
file external/bsd/dwc2/dist/dwc2_core.c dwctwo
|
||||
|
Loading…
x
Reference in New Issue
Block a user