usb: dwc3: trace: add a tracepoint for ep enable/disable
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 3 Nov 2016 11:53:29 +0000 (13:53 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 8 Nov 2016 10:52:12 +0000 (12:52 +0200)
instead of using a simple trace_printk() wrapper,
let's add an actual tracepoint and print further
details about the endpoint being operated upon.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/gadget.c
drivers/usb/dwc3/trace.h

index a9c1d75..7e39f0c 100644 (file)
@@ -587,8 +587,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
        u32                     reg;
        int                     ret;
 
-       dwc3_trace(trace_dwc3_gadget, "Enabling %s", dep->name);
-
        if (!(dep->flags & DWC3_EP_ENABLED)) {
                ret = dwc3_gadget_start_config(dwc, dep);
                if (ret)
@@ -617,7 +615,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
                init_waitqueue_head(&dep->wait_end_transfer);
 
                if (usb_endpoint_xfer_control(desc))
-                       return 0;
+                       goto out;
 
                /* Initialize the TRB ring */
                dep->trb_dequeue = 0;
@@ -664,6 +662,10 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
                WARN_ON_ONCE(!dep->resource_index);
        }
 
+
+out:
+       trace_dwc3_gadget_ep_enable(dep);
+
        return 0;
 }
 
@@ -701,7 +703,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
        struct dwc3             *dwc = dep->dwc;
        u32                     reg;
 
-       dwc3_trace(trace_dwc3_gadget, "Disabling %s", dep->name);
+       trace_dwc3_gadget_ep_disable(dep);
 
        dwc3_remove_requests(dwc, dep);
 
index b2153f2..2b124f9 100644 (file)
@@ -341,6 +341,57 @@ DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
        TP_ARGS(dep, trb)
 );
 
+DECLARE_EVENT_CLASS(dwc3_log_ep,
+       TP_PROTO(struct dwc3_ep *dep),
+       TP_ARGS(dep),
+       TP_STRUCT__entry(
+               __dynamic_array(char, name, DWC3_MSG_MAX)
+               __field(unsigned, maxpacket)
+               __field(unsigned, maxpacket_limit)
+               __field(unsigned, max_streams)
+               __field(unsigned, maxburst)
+               __field(unsigned, flags)
+               __field(unsigned, direction)
+               __field(u8, trb_enqueue)
+               __field(u8, trb_dequeue)
+       ),
+       TP_fast_assign(
+               snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
+               __entry->maxpacket = dep->endpoint.maxpacket;
+               __entry->maxpacket_limit = dep->endpoint.maxpacket_limit;
+               __entry->max_streams = dep->endpoint.max_streams;
+               __entry->maxburst = dep->endpoint.maxburst;
+               __entry->flags = dep->flags;
+               __entry->direction = dep->direction;
+               __entry->trb_enqueue = dep->trb_enqueue;
+               __entry->trb_dequeue = dep->trb_dequeue;
+       ),
+       TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c%c:%c:%c",
+               __get_str(name), __entry->maxpacket,
+               __entry->maxpacket_limit, __entry->max_streams,
+               __entry->maxburst, __entry->trb_enqueue,
+               __entry->trb_dequeue,
+               __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',
+               __entry->flags & DWC3_EP_STALL ? 'S' : 's',
+               __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',
+               __entry->flags & DWC3_EP_BUSY ? 'B' : 'b',
+               __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
+               __entry->flags & DWC3_EP_MISSED_ISOC ? 'M' : 'm',
+               __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e',
+               __entry->direction ? '<' : '>'
+       )
+);
+
+DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable,
+       TP_PROTO(struct dwc3_ep *dep),
+       TP_ARGS(dep)
+);
+
+DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable,
+       TP_PROTO(struct dwc3_ep *dep),
+       TP_ARGS(dep)
+);
+
 #endif /* __DWC3_TRACE_H */
 
 /* this part has to be here */