Commit f75cacc4 authored by Felipe Balbi's avatar Felipe Balbi

usb: dwc3: trace: fully decode IRQ events

This will make it more human-friendly to read trace
output from dwc3.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 7ab373aa
...@@ -128,56 +128,112 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state) ...@@ -128,56 +128,112 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state)
* dwc3_gadget_event_string - returns event name * dwc3_gadget_event_string - returns event name
* @event: the event code * @event: the event code
*/ */
static inline const char *dwc3_gadget_event_string(u8 event) static inline const char *
dwc3_gadget_event_string(const struct dwc3_event_devt *event)
{ {
switch (event) { static char str[256];
enum dwc3_link_state state = event->event_info & DWC3_LINK_STATE_MASK;
switch (event->type) {
case DWC3_DEVICE_EVENT_DISCONNECT: case DWC3_DEVICE_EVENT_DISCONNECT:
return "Disconnect"; sprintf(str, "Disconnect: [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_RESET: case DWC3_DEVICE_EVENT_RESET:
return "Reset"; sprintf(str, "Reset [%s]", dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_CONNECT_DONE: case DWC3_DEVICE_EVENT_CONNECT_DONE:
return "Connection Done"; sprintf(str, "Connection Done [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
return "Link Status Change"; sprintf(str, "Link Change [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_WAKEUP: case DWC3_DEVICE_EVENT_WAKEUP:
return "WakeUp"; sprintf(str, "WakeUp [%s]", dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_EOPF: case DWC3_DEVICE_EVENT_EOPF:
return "End-Of-Frame"; sprintf(str, "End-Of-Frame [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_SOF: case DWC3_DEVICE_EVENT_SOF:
return "Start-Of-Frame"; sprintf(str, "Start-Of-Frame [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_ERRATIC_ERROR: case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
return "Erratic Error"; sprintf(str, "Erratic Error [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_CMD_CMPL: case DWC3_DEVICE_EVENT_CMD_CMPL:
return "Command Complete"; sprintf(str, "Command Complete [%s]",
dwc3_gadget_link_string(state));
break;
case DWC3_DEVICE_EVENT_OVERFLOW: case DWC3_DEVICE_EVENT_OVERFLOW:
return "Overflow"; sprintf(str, "Overflow [%s]", dwc3_gadget_link_string(state));
break;
default:
sprintf(str, "UNKNOWN");
} }
return "UNKNOWN"; return str;
} }
/** /**
* dwc3_ep_event_string - returns event name * dwc3_ep_event_string - returns event name
* @event: then event code * @event: then event code
*/ */
static inline const char *dwc3_ep_event_string(u8 event) static inline const char *
dwc3_ep_event_string(const struct dwc3_event_depevt *event)
{ {
switch (event) { u8 epnum = event->endpoint_number;
static char str[256];
int status;
int ret;
ret = sprintf(str, "ep%d%s: ", epnum >> 1,
(epnum & 1) ? "in" : "in");
if (ret < 0)
return "UNKNOWN";
switch (event->endpoint_event) {
case DWC3_DEPEVT_XFERCOMPLETE: case DWC3_DEPEVT_XFERCOMPLETE:
return "Transfer Complete"; strcat(str, "Transfer Complete");
break;
case DWC3_DEPEVT_XFERINPROGRESS: case DWC3_DEPEVT_XFERINPROGRESS:
return "Transfer In-Progress"; strcat(str, "Transfer In-Progress");
break;
case DWC3_DEPEVT_XFERNOTREADY: case DWC3_DEPEVT_XFERNOTREADY:
return "Transfer Not Ready"; strcat(str, "Transfer Not Ready");
status = event->status & DEPEVT_STATUS_TRANSFER_ACTIVE;
strcat(str, status ? " (Active)" : " (Not Active)");
break;
case DWC3_DEPEVT_RXTXFIFOEVT: case DWC3_DEPEVT_RXTXFIFOEVT:
return "FIFO"; strcat(str, "FIFO");
break;
case DWC3_DEPEVT_STREAMEVT: case DWC3_DEPEVT_STREAMEVT:
return "Stream"; status = event->status;
switch (status) {
case DEPEVT_STREAMEVT_FOUND:
sprintf(str + ret, " Stream %d Found",
event->parameters);
break;
case DEPEVT_STREAMEVT_NOTFOUND:
default:
strcat(str, " Stream Not Found");
break;
}
break;
case DWC3_DEPEVT_EPCMDCMPLT: case DWC3_DEPEVT_EPCMDCMPLT:
return "Endpoint Command Complete"; strcat(str, "Endpoint Command Complete");
break;
default:
sprintf(str, "UNKNOWN");
} }
return "UNKNOWN"; return str;
} }
/** /**
...@@ -214,6 +270,16 @@ static inline const char *dwc3_gadget_event_type_string(u8 event) ...@@ -214,6 +270,16 @@ static inline const char *dwc3_gadget_event_type_string(u8 event)
} }
} }
static inline const char *dwc3_decode_event(u32 event)
{
const union dwc3_event evt = (union dwc3_event) event;
if (evt.type.is_devspec)
return dwc3_gadget_event_string(&evt.devt);
else
return dwc3_ep_event_string(&evt.depevt);
}
void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...); void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
......
...@@ -1109,11 +1109,8 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc, ...@@ -1109,11 +1109,8 @@ static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
void dwc3_ep0_interrupt(struct dwc3 *dwc, void dwc3_ep0_interrupt(struct dwc3 *dwc,
const struct dwc3_event_depevt *event) const struct dwc3_event_depevt *event)
{ {
u8 epnum = event->endpoint_number; dwc3_trace(trace_dwc3_ep0, "%s: state '%s'",
dwc3_ep_event_string(event),
dwc3_trace(trace_dwc3_ep0, "%s while ep%d%s in state '%s'",
dwc3_ep_event_string(event->endpoint_event),
epnum >> 1, (epnum & 1) ? "in" : "out",
dwc3_ep0_state_string(dwc->ep0state)); dwc3_ep0_state_string(dwc->ep0state));
switch (event->endpoint_event) { switch (event->endpoint_event) {
......
...@@ -71,7 +71,8 @@ DECLARE_EVENT_CLASS(dwc3_log_event, ...@@ -71,7 +71,8 @@ DECLARE_EVENT_CLASS(dwc3_log_event,
TP_fast_assign( TP_fast_assign(
__entry->event = event; __entry->event = event;
), ),
TP_printk("event %08x", __entry->event) TP_printk("event (%08x): %s", __entry->event,
dwc3_decode_event(__entry->event))
); );
DEFINE_EVENT(dwc3_log_event, dwc3_event, DEFINE_EVENT(dwc3_log_event, dwc3_event,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment