diff options
author | Bin Liu <b-liu@ti.com> | 2016-06-30 13:12:21 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-07-16 19:23:57 -0400 |
commit | f89252ad19a1a93095bdee58a4d857023f069280 (patch) | |
tree | 33b73ccbea6380093c8b0983fa17c87f9dcdafcc | |
parent | ca2b6faeb96d6d71ebc0627d6679f7b6667cfb00 (diff) |
usb: musb: add tracepoints support for debugging
To avoid printk() overhead while debugging, this patch implements the
foundation of tracepoints logging for musb driver to make debug
easier.
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/musb/Makefile | 5 | ||||
-rw-r--r-- | drivers/usb/musb/musb_debug.h | 2 | ||||
-rw-r--r-- | drivers/usb/musb/musb_trace.c | 33 | ||||
-rw-r--r-- | drivers/usb/musb/musb_trace.h | 54 |
4 files changed, 93 insertions, 1 deletions
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index f95befe18cc1..689d42aba8a9 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile | |||
@@ -2,9 +2,12 @@ | |||
2 | # for USB OTG silicon based on Mentor Graphics INVENTRA designs | 2 | # for USB OTG silicon based on Mentor Graphics INVENTRA designs |
3 | # | 3 | # |
4 | 4 | ||
5 | # define_trace.h needs to know how to find our header | ||
6 | CFLAGS_musb_trace.o := -I$(src) | ||
7 | |||
5 | obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o | 8 | obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o |
6 | 9 | ||
7 | musb_hdrc-y := musb_core.o | 10 | musb_hdrc-y := musb_core.o musb_trace.o |
8 | 11 | ||
9 | musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o musb_host.o | 12 | musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o musb_host.o |
10 | musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_gadget_ep0.o musb_gadget.o | 13 | musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_gadget_ep0.o musb_gadget.o |
diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h index 27ba8f799462..9a78877a8afe 100644 --- a/drivers/usb/musb/musb_debug.h +++ b/drivers/usb/musb/musb_debug.h | |||
@@ -42,6 +42,8 @@ | |||
42 | #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args) | 42 | #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args) |
43 | #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) | 43 | #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) |
44 | 44 | ||
45 | void musb_dbg(struct musb *musb, const char *fmt, ...); | ||
46 | |||
45 | #ifdef CONFIG_DEBUG_FS | 47 | #ifdef CONFIG_DEBUG_FS |
46 | int musb_init_debugfs(struct musb *musb); | 48 | int musb_init_debugfs(struct musb *musb); |
47 | void musb_exit_debugfs(struct musb *musb); | 49 | void musb_exit_debugfs(struct musb *musb); |
diff --git a/drivers/usb/musb/musb_trace.c b/drivers/usb/musb/musb_trace.c new file mode 100644 index 000000000000..70973d901a21 --- /dev/null +++ b/drivers/usb/musb/musb_trace.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * musb_trace.c - MUSB Controller Trace Support | ||
3 | * | ||
4 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * | ||
6 | * Author: Bin Liu <b-liu@ti.com> | ||
7 | * | ||
8 | * This program is free software: you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 of | ||
10 | * the License as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #define CREATE_TRACE_POINTS | ||
19 | #include "musb_trace.h" | ||
20 | |||
21 | void musb_dbg(struct musb *musb, const char *fmt, ...) | ||
22 | { | ||
23 | struct va_format vaf; | ||
24 | va_list args; | ||
25 | |||
26 | va_start(args, fmt); | ||
27 | vaf.fmt = fmt; | ||
28 | vaf.va = &args; | ||
29 | |||
30 | trace_musb_log(musb, &vaf); | ||
31 | |||
32 | va_end(args); | ||
33 | } | ||
diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h new file mode 100644 index 000000000000..c6c593ec3aa7 --- /dev/null +++ b/drivers/usb/musb/musb_trace.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * musb_trace.h - MUSB Controller Trace Support | ||
3 | * | ||
4 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * | ||
6 | * Author: Bin Liu <b-liu@ti.com> | ||
7 | * | ||
8 | * This program is free software: you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 of | ||
10 | * the License as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #undef TRACE_SYSTEM | ||
19 | #define TRACE_SYSTEM musb | ||
20 | |||
21 | #if !defined(__MUSB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) | ||
22 | #define __MUSB_TRACE_H | ||
23 | |||
24 | #include <linux/types.h> | ||
25 | #include <linux/tracepoint.h> | ||
26 | #include "musb_core.h" | ||
27 | |||
28 | #define MUSB_MSG_MAX 500 | ||
29 | |||
30 | TRACE_EVENT(musb_log, | ||
31 | TP_PROTO(struct musb *musb, struct va_format *vaf), | ||
32 | TP_ARGS(musb, vaf), | ||
33 | TP_STRUCT__entry( | ||
34 | __string(name, dev_name(musb->controller)) | ||
35 | __dynamic_array(char, msg, MUSB_MSG_MAX) | ||
36 | ), | ||
37 | TP_fast_assign( | ||
38 | __assign_str(name, dev_name(musb->controller)); | ||
39 | vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va); | ||
40 | ), | ||
41 | TP_printk("%s: %s", __get_str(name), __get_str(msg)) | ||
42 | ); | ||
43 | |||
44 | #endif /* __MUSB_TRACE_H */ | ||
45 | |||
46 | /* this part has to be here */ | ||
47 | |||
48 | #undef TRACE_INCLUDE_PATH | ||
49 | #define TRACE_INCLUDE_PATH . | ||
50 | |||
51 | #undef TRACE_INCLUDE_FILE | ||
52 | #define TRACE_INCLUDE_FILE musb_trace | ||
53 | |||
54 | #include <trace/define_trace.h> | ||