Commit a37c3f76 authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

usb: host: xhci: make a generic TRB tracer

instead of having a tracer that can only trace command completions,
let's promote this tracer so it can trace and decode any TRB.

With that, it will be easier to extrapolate the lifetime of any TRB
which might help debugging certain issues.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ed6d643b
...@@ -1319,6 +1319,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, ...@@ -1319,6 +1319,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
cmd_dma = le64_to_cpu(event->cmd_trb); cmd_dma = le64_to_cpu(event->cmd_trb);
cmd_trb = xhci->cmd_ring->dequeue; cmd_trb = xhci->cmd_ring->dequeue;
trace_xhci_handle_command(xhci->cmd_ring, &cmd_trb->generic);
cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
cmd_trb); cmd_trb);
/* /*
...@@ -1335,8 +1338,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, ...@@ -1335,8 +1338,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
cancel_delayed_work(&xhci->cmd_timer); cancel_delayed_work(&xhci->cmd_timer);
trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status)); cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
/* If CMD ring stopped we own the trbs between enqueue and dequeue */ /* If CMD ring stopped we own the trbs between enqueue and dequeue */
...@@ -2479,6 +2480,10 @@ static int handle_tx_event(struct xhci_hcd *xhci, ...@@ -2479,6 +2480,10 @@ static int handle_tx_event(struct xhci_hcd *xhci,
ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) /
sizeof(*ep_trb)]; sizeof(*ep_trb)];
trace_xhci_handle_transfer(ep_ring,
(struct xhci_generic_trb *) ep_trb);
/* /*
* No-op TRB should not trigger interrupts. * No-op TRB should not trigger interrupts.
* If ep_trb is a no-op TRB, it means the * If ep_trb is a no-op TRB, it means the
...@@ -2545,6 +2550,8 @@ static int xhci_handle_event(struct xhci_hcd *xhci) ...@@ -2545,6 +2550,8 @@ static int xhci_handle_event(struct xhci_hcd *xhci)
xhci->event_ring->cycle_state) xhci->event_ring->cycle_state)
return 0; return 0;
trace_xhci_handle_event(xhci->event_ring, &event->generic);
/* /*
* Barrier between reading the TRB_CYCLE (valid) flag above and any * Barrier between reading the TRB_CYCLE (valid) flag above and any
* speculative reads of the event's flags/data below. * speculative reads of the event's flags/data below.
...@@ -2714,6 +2721,9 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, ...@@ -2714,6 +2721,9 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
trb->field[1] = cpu_to_le32(field2); trb->field[1] = cpu_to_le32(field2);
trb->field[2] = cpu_to_le32(field3); trb->field[2] = cpu_to_le32(field3);
trb->field[3] = cpu_to_le32(field4); trb->field[3] = cpu_to_le32(field4);
trace_xhci_queue_trb(ring, trb);
inc_enq(xhci, ring, more_trbs_coming); inc_enq(xhci, ring, more_trbs_coming);
} }
......
...@@ -115,34 +115,47 @@ DEFINE_EVENT(xhci_log_ctx, xhci_address_ctx, ...@@ -115,34 +115,47 @@ DEFINE_EVENT(xhci_log_ctx, xhci_address_ctx,
TP_ARGS(xhci, ctx, ep_num) TP_ARGS(xhci, ctx, ep_num)
); );
DECLARE_EVENT_CLASS(xhci_log_event, DECLARE_EVENT_CLASS(xhci_log_trb,
TP_PROTO(void *trb_va, struct xhci_generic_trb *ev), TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
TP_ARGS(trb_va, ev), TP_ARGS(ring, trb),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(void *, va) __field(u32, type)
__field(u64, dma) __field(u32, field0)
__field(u32, status) __field(u32, field1)
__field(u32, flags) __field(u32, field2)
__dynamic_array(u8, trb, sizeof(struct xhci_generic_trb)) __field(u32, field3)
), ),
TP_fast_assign( TP_fast_assign(
__entry->va = trb_va; __entry->type = ring->type;
__entry->dma = ((u64)le32_to_cpu(ev->field[1])) << 32 | __entry->field0 = le32_to_cpu(trb->field[0]);
le32_to_cpu(ev->field[0]); __entry->field1 = le32_to_cpu(trb->field[1]);
__entry->status = le32_to_cpu(ev->field[2]); __entry->field2 = le32_to_cpu(trb->field[2]);
__entry->flags = le32_to_cpu(ev->field[3]); __entry->field3 = le32_to_cpu(trb->field[3]);
memcpy(__get_dynamic_array(trb), trb_va,
sizeof(struct xhci_generic_trb));
), ),
TP_printk("\ntrb_dma=@%llx, trb_va=@%p, status=%08x, flags=%08x", TP_printk("%s: %s", xhci_ring_type_string(__entry->type),
(unsigned long long) __entry->dma, __entry->va, xhci_decode_trb(__entry->field0, __entry->field1,
__entry->status, __entry->flags __entry->field2, __entry->field3)
) )
); );
DEFINE_EVENT(xhci_log_event, xhci_cmd_completion, DEFINE_EVENT(xhci_log_trb, xhci_handle_event,
TP_PROTO(void *trb_va, struct xhci_generic_trb *ev), TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
TP_ARGS(trb_va, ev) TP_ARGS(ring, trb)
);
DEFINE_EVENT(xhci_log_trb, xhci_handle_command,
TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
TP_ARGS(ring, trb)
);
DEFINE_EVENT(xhci_log_trb, xhci_handle_transfer,
TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
TP_ARGS(ring, trb)
);
DEFINE_EVENT(xhci_log_trb, xhci_queue_trb,
TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
TP_ARGS(ring, trb)
); );
#endif /* __XHCI_TRACE_H */ #endif /* __XHCI_TRACE_H */
......
This diff is collapsed.
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