This patch add a few tracepoints to the DWC3 driver in order to aid debugging. NYET-Signed-off-by: Felipe Balbi <balbi@xxxxxx> --- This is far from ready, but I wanted to see how the rest of the community feels about adding a few tracepoints to the dwc3 driver. Any suggestions of where to add more interesting tracepoints ? I was thinking of adding a few right before we kick a transfer which would dump our TRB contents. That's likely to be useful in most cases. Any other idea of how to use traces on this driver ? BTW Gerard/Boyan, this is (in part) what you were looking for to be able to poke into the running driver/IP. You could add your own debugging traces and use them to poke into the device's registers for your tests, though that's a bit of an abuse of the interface, I guess ;-) If all you need, is to print some stuff, we could, instead use TRACE_EVENT() insteac of DECLARE_TRACE(). It would become something like: TRACE_EVENT(dwc3_readl, TP_PROTO(void __iomem *base, u32 offset, u32 value), TP_ARGS(base, offset, value), TP_STRUCT__entry( __field(void __iomem *, base) __field(u32, offset) __field(u32, value) ), TP_fast_assign( __entry->base = base; __entry->offset = offset; __entry->value = value; ), TP_printk("read: base %p offset %08x value %08x", __entry->base, __entry->offset, __entry->value), ); drivers/usb/dwc3/Makefile | 4 ++ drivers/usb/dwc3/core.c | 33 ++++++++++++++++ drivers/usb/dwc3/io.h | 23 ++---------- drivers/usb/dwc3/trace.c | 91 +++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/trace.h | 52 ++++++++++++++++++++++++++ 5 files changed, 184 insertions(+), 19 deletions(-) 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 4502648..7d757bf 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -7,6 +7,10 @@ dwc3-y := core.o dwc3-y += host.o dwc3-y += gadget.o ep0.o +ifneq ($(CONFIG_TRACEPOINTS),) + dwc3-y += trace.o +endif + ifneq ($(CONFIG_DEBUG_FS),) dwc3-y += debugfs.o endif diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 49c0602..5539a12 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -65,6 +65,39 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); /* -------------------------------------------------------------------------- */ +DEFINE_TRACE(dwc3_readl); +DEFINE_TRACE(dwc3_writel); + +__always_inline u32 dwc3_readl(void __iomem *base, u32 offset) +{ + u32 value; + + /* + * We requested the mem region starting from the Globals address + * space, see dwc3_probe in core.c. + * However, the offsets are given starting from xHCI address space. + */ + value = readl(base + (offset - DWC3_GLOBALS_REGS_START)); + + trace_dwc3_readl(base, offset, value); + + return value; +} + +__always_inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) +{ + trace_dwc3_writel(base, offset, value); + + /* + * We requested the mem region starting from the Globals address + * space, see dwc3_probe in core.c. + * However, the offsets are given starting from xHCI address space. + */ + writel(value, base + (offset - DWC3_GLOBALS_REGS_START)); +} + +/* -------------------------------------------------------------------------- */ + #define DWC3_DEVS_POSSIBLE 32 static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE); diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index a50f76b..12db9a3 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h @@ -39,28 +39,13 @@ #ifndef __DRIVERS_USB_DWC3_IO_H #define __DRIVERS_USB_DWC3_IO_H +#include <linux/types.h> #include <linux/io.h> #include "core.h" +#include "trace.h" -static inline u32 dwc3_readl(void __iomem *base, u32 offset) -{ - /* - * We requested the mem region starting from the Globals address - * space, see dwc3_probe in core.c. - * However, the offsets are given starting from xHCI address space. - */ - return readl(base + (offset - DWC3_GLOBALS_REGS_START)); -} - -static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) -{ - /* - * We requested the mem region starting from the Globals address - * space, see dwc3_probe in core.c. - * However, the offsets are given starting from xHCI address space. - */ - writel(value, base + (offset - DWC3_GLOBALS_REGS_START)); -} +u32 dwc3_readl(void __iomem *base, u32 offset); +void dwc3_writel(void __iomem *base, u32 offset, u32 value); #endif /* __DRIVERS_USB_DWC3_IO_H */ diff --git a/drivers/usb/dwc3/trace.c b/drivers/usb/dwc3/trace.c new file mode 100644 index 0000000..65dffcb --- /dev/null +++ b/drivers/usb/dwc3/trace.c @@ -0,0 +1,91 @@ +/** + * debugfs.c - DesignWare USB3 DRD Controller DebugFS file + * + * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * + * Authors: Felipe Balbi <balbi@xxxxxx>, + * Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> + * + * 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, + * without modification. + * 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 names of the above-listed copyright holders may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2, as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR + * CONTRIBUTORS 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. + */ + +#include <linux/kernel.h> + +#include "trace.h" +#include "core.h" +#include "io.h" + +static void probe_dwc3_readl(void *_dwc, void __iomem *base, + u32 offset, u32 value) +{ + struct dwc3 *dwc = _dwc; + + dev_info(dwc->dev, "READ: base %p offset %08x value %08x\n", + base, offset, value); +} + +static void probe_dwc3_writel(void *_dwc, void __iomem *base, + u32 offset, u32 value) +{ + struct dwc3 *dwc = _dwc; + + dev_info(dwc->dev, "WRITE: base %p offset %08x value %08x\n", + base, offset, value); +} + +int __devinit dwc3_trace_init(struct dwc3 *dwc) +{ + int ret; + + ret = register_trace_dwc3_writel(probe_dwc3_writel, dwc); + if (ret) + goto err0; + + ret = register_trace_dwc3_readl(probe_dwc3_readl, dwc); + if (ret) + goto err1; + + return 0; + +err1: + unregister_trace_dwc3_writel(probe_dwc3_writel, dwc); + +err0: + tracepoint_synchronize_unregister(); + + return ret; +} + +void __devexit dwc3_trace_exit(struct dwc3 *dwc) +{ + unregister_trace_dwc3_readl(probe_dwc3_readl, dwc); + unregister_trace_dwc3_writel(probe_dwc3_writel, dwc); + tracepoint_synchronize_unregister(); +} diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h new file mode 100644 index 0000000..86367e4 --- /dev/null +++ b/drivers/usb/dwc3/trace.h @@ -0,0 +1,52 @@ +/** + * trace.h - DesignWare USB3 DRD Controller TracePoints file + * + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com + * + * Author: Felipe Balbi <balbi@xxxxxx> + * + * 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, + * without modification. + * 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 names of the above-listed copyright holders may not be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2, as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR + * CONTRIBUTORS 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 __DWC3_TRACE_H +#define __DWC3_TRACE_H + +#include <linux/compiler.h> /* for __iomem */ +#include <linux/tracepoint.h> + +DECLARE_TRACE(dwc3_readl, + TP_PROTO(void __iomem *base, u32 offset, u32 value), + TP_ARGS(base, offset, value)); + +DECLARE_TRACE(dwc3_writel, + TP_PROTO(void __iomem *base, u32 offset, u32 value), + TP_ARGS(base, offset, value)); + +#endif /* __DWC3_TRACE_H */ -- 1.7.10.2 -- 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