[RFC 4/4] xhci: add xhci_cmd_completion trace event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch creates a new event class, called xhci_log_cmd,
for tracing the commands issued to xHC that generate a
completion event in the event ring by placing into the
ring buffer the completion event's status and flags as
well as the command TRB's data, dma and virtual address.

This info can be used, later, to print, in a human readable
way, the completion status and flags as well as the command's
type and fields using the trace-cmd tool and the appropriate
plugin.

Also, this patch defines the xhci_cmd_completion trace event,
part of the class xhci_log_cmd, and adds a tracepoint in
handle_cmd_completion().

Signed-off-by: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
---
 drivers/usb/host/xhci-ring.c  |  2 ++
 drivers/usb/host/xhci-trace.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a0a492c..50bbb87 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1380,6 +1380,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
 		return;
 	}
 
+	trace_xhci_cmd_completion(&xhci->cmd_ring->dequeue->generic, event);
+
 	if ((GET_COMP_CODE(le32_to_cpu(event->status)) == COMP_CMD_ABORT) ||
 		(GET_COMP_CODE(le32_to_cpu(event->status)) == COMP_CMD_STOP)) {
 		/* If the return value is 0, we think the trb pointed by
diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index 4d4687e..c7eb065 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -93,6 +93,34 @@ DEFINE_EVENT(xhci_log_ctx, xhci_address_ctx,
 	TP_ARGS(xhci, ctx, ep_num)
 );
 
+DECLARE_EVENT_CLASS(xhci_log_cmd,
+	TP_PROTO(void *cmd_trb_va, struct xhci_event_cmd *compl_event),
+	TP_ARGS(cmd_trb_va, compl_event),
+	TP_STRUCT__entry(
+		__field(void *, va)
+		__field(u64, dma)
+		__field(u32, status)
+		__field(u32, flags)
+		__dynamic_array(__le32, cmd_trb, 4)
+	),
+	TP_fast_assign(
+		__entry->va = cmd_trb_va;
+		__entry->dma = le64_to_cpu(compl_event->cmd_trb);
+		__entry->status = le32_to_cpu(compl_event->status);
+		__entry->flags = le32_to_cpu(compl_event->flags);
+		memcpy(__get_dynamic_array(cmd_trb), cmd_trb_va,
+		       sizeof(struct xhci_generic_trb));
+	),
+	TP_printk("\ncmd_dma=@%08llx, cmd_va=@%p, status=%08x, flags=%08x",
+		  __entry->dma, __entry->va, __entry->status, __entry->flags
+	)
+);
+
+DEFINE_EVENT(xhci_log_cmd, xhci_cmd_completion,
+	TP_PROTO(void *cmd_trb_va, struct xhci_event_cmd *compl_event),
+	TP_ARGS(cmd_trb_va, compl_event)
+);
+
 #endif /* __XHCI_TRACE_H */
 
 /* this part must be outside header guard */
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-trace-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux