RE: [PATCH v2] usb: dwc3: add tracepoints to aid debugging

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

 



> From: Felipe Balbi [mailto:balbi@xxxxxx]
> Sent: Tuesday, August 19, 2014 3:02 PM
> 
> I didn't have time to test this yet (other than build testing), but how
> does this one look ? Now we will print cute little strings for all
> events and we still have proper link state tracking.
> 
> 8<---------------------------------------------------------------------
> 
> From 513ba489d66ff81eca056b41fda0cc965e6fe3ed Mon Sep 17 00:00:00 2001
> From: Felipe Balbi <balbi@xxxxxx>
> Date: Wed, 30 Apr 2014 17:45:10 -0500
> Subject: [PATCH] usb: dwc3: add tracepoints to aid debugging
> 
> When we're debugging hard-to-reproduce and time-sensitive
> use cases, printk() poses too much overhead. That's when
> the kernel's tracing infrastructure comes into play.
> 
> This patch implements a few initial tracepoints for the
> dwc3 driver. More traces can be added as necessary in order
> to ease the task of debugging dwc3.
> 
> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
>  drivers/usb/dwc3/Makefile |   5 +-
>  drivers/usb/dwc3/core.h   |   2 +
>  drivers/usb/dwc3/debug.c  |  73 ++++++++++++++++++++++++++
>  drivers/usb/dwc3/debug.h  |   5 ++
>  drivers/usb/dwc3/ep0.c    |   2 +
>  drivers/usb/dwc3/gadget.c |  27 +++++-----
>  drivers/usb/dwc3/io.h     |  30 +++++++++--
>  drivers/usb/dwc3/trace.c  |  19 +++++++
>  drivers/usb/dwc3/trace.h  | 128 ++++++++++++++++++++++++++++++++++++++++++++++
>  9 files changed, 272 insertions(+), 19 deletions(-)
>  create mode 100644 drivers/usb/dwc3/debug.c
>  create mode 100644 drivers/usb/dwc3/trace.c
>  create mode 100644 drivers/usb/dwc3/trace.h
> 
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index 10ac3e7..7793e6c 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -1,9 +1,12 @@
> +# define_trace.h needs to know how to find our header
> +CFLAGS_trace.o				:= -I$(src)
> +
>  ccflags-$(CONFIG_USB_DWC3_DEBUG)	:= -DDEBUG
>  ccflags-$(CONFIG_USB_DWC3_VERBOSE)	+= -DVERBOSE_DEBUG
> 
>  obj-$(CONFIG_USB_DWC3)			+= dwc3.o
> 
> -dwc3-y					:= core.o
> +dwc3-y					:= core.o debug.o trace.o
> 
>  ifneq ($(filter y,$(CONFIG_USB_DWC3_HOST) $(CONFIG_USB_DWC3_DUAL_ROLE)),)
>  	dwc3-y				+= host.o
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 48fb264..dbdad87 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -33,6 +33,8 @@
> 
>  #include <linux/phy/phy.h>
> 
> +#define DWC3_MSG_MAX	500
> +
>  /* Global constants */
>  #define DWC3_EP0_BOUNCE_SIZE	512
>  #define DWC3_ENDPOINTS_NUM	32
> diff --git a/drivers/usb/dwc3/debug.c b/drivers/usb/dwc3/debug.c
> new file mode 100644
> index 0000000..6e109ce
> --- /dev/null
> +++ b/drivers/usb/dwc3/debug.c
> @@ -0,0 +1,73 @@
> +/**
> + * debug.c - DesignWare USB3 DRD Controller Debug/Trace Support
> + *
> + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
> + *
> + * Author: Felipe Balbi <balbi@xxxxxx>
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2  of
> + * the License as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include "core.h"
> +#include "debug.h"
> +
> +static char event_str[DWC3_MSG_MAX];
> +
> +static void dwc3_endpoint_event_str(struct dwc3 *dwc,
> +		const struct dwc3_event_depevt *event)
> +{
> +	struct dwc3_ep *dep = dwc->eps[event->endpoint_number];
> +
> +	snprintf(event_str, DWC3_MSG_MAX, "%s %s", dep->name,
> +			dwc3_ep_event_string(event->endpoint_event));

Maybe you should also include the raw event data in the trace? Some
of the other bits in the event besides the event number can tell you
useful things while debugging.

> +}
> +
> +static void dwc3_gadget_event_str(struct dwc3 *dwc,
> +	const struct dwc3_event_devt *devt)
> +{
> +	snprintf(event_str, DWC3_MSG_MAX, "%s",
> +			dwc3_gadget_event_type_string(devt->type));

Ditto here.

-- 
Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux