9ae3a8
From 808711fd7cfcd6daca455db6dbd9d0f1f17a8b96 Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Fri, 11 Jul 2014 14:20:39 +0200
9ae3a8
Subject: [PATCH 06/43] xhci: add tracepoint for endpoint state changes
9ae3a8
9ae3a8
Message-id: <1405088470-24115-7-git-send-email-kraxel@redhat.com>
9ae3a8
Patchwork-id: 59843
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH 06/37] xhci: add tracepoint for endpoint state changes
9ae3a8
Bugzilla: 980833
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit 1c82392a158471355aa6d1922df2d1545bb16b95)
9ae3a8
---
9ae3a8
 hw/usb/hcd-xhci.c | 19 +++++++++++++++++++
9ae3a8
 trace-events      |  1 +
9ae3a8
 2 files changed, 20 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/usb/hcd-xhci.c | 19 +++++++++++++++++++
9ae3a8
 trace-events      |  1 +
9ae3a8
 2 files changed, 20 insertions(+)
9ae3a8
9ae3a8
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
9ae3a8
index 00623f9..e8fa26c 100644
9ae3a8
--- a/hw/usb/hcd-xhci.c
9ae3a8
+++ b/hw/usb/hcd-xhci.c
9ae3a8
@@ -589,6 +589,14 @@ static const char *TRBCCode_names[] = {
9ae3a8
     [CC_SPLIT_TRANSACTION_ERROR]       = "CC_SPLIT_TRANSACTION_ERROR",
9ae3a8
 };
9ae3a8
 
9ae3a8
+static const char *ep_state_names[] = {
9ae3a8
+    [EP_DISABLED] = "disabled",
9ae3a8
+    [EP_RUNNING]  = "running",
9ae3a8
+    [EP_HALTED]   = "halted",
9ae3a8
+    [EP_STOPPED]  = "stopped",
9ae3a8
+    [EP_ERROR]    = "error",
9ae3a8
+};
9ae3a8
+
9ae3a8
 static const char *lookup_name(uint32_t index, const char **list, uint32_t llen)
9ae3a8
 {
9ae3a8
     if (index >= llen || list[index] == NULL) {
9ae3a8
@@ -609,6 +617,12 @@ static const char *event_name(XHCIEvent *event)
9ae3a8
                        ARRAY_SIZE(TRBCCode_names));
9ae3a8
 }
9ae3a8
 
9ae3a8
+static const char *ep_state_name(uint32_t state)
9ae3a8
+{
9ae3a8
+    return lookup_name(state, ep_state_names,
9ae3a8
+                       ARRAY_SIZE(ep_state_names));
9ae3a8
+}
9ae3a8
+
9ae3a8
 static uint64_t xhci_mfindex_get(XHCIState *xhci)
9ae3a8
 {
9ae3a8
     int64_t now = qemu_get_clock_ns(vm_clock);
9ae3a8
@@ -1206,6 +1220,11 @@ static void xhci_set_ep_state(XHCIState *xhci, XHCIEPContext *epctx,
9ae3a8
     }
9ae3a8
 
9ae3a8
     xhci_dma_write_u32s(xhci, epctx->pctx, ctx, sizeof(ctx));
9ae3a8
+    if (epctx->state != state) {
9ae3a8
+        trace_usb_xhci_ep_state(epctx->slotid, epctx->epid,
9ae3a8
+                                ep_state_name(epctx->state),
9ae3a8
+                                ep_state_name(state));
9ae3a8
+    }
9ae3a8
     epctx->state = state;
9ae3a8
 }
9ae3a8
 
9ae3a8
diff --git a/trace-events b/trace-events
9ae3a8
index b9144b2..4058dd5 100644
9ae3a8
--- a/trace-events
9ae3a8
+++ b/trace-events
9ae3a8
@@ -378,6 +378,7 @@ usb_xhci_ep_set_dequeue(uint32_t slotid, uint32_t epid, uint32_t streamid, uint6
9ae3a8
 usb_xhci_ep_kick(uint32_t slotid, uint32_t epid, uint32_t streamid) "slotid %d, epid %d, streamid %d"
9ae3a8
 usb_xhci_ep_stop(uint32_t slotid, uint32_t epid) "slotid %d, epid %d"
9ae3a8
 usb_xhci_ep_reset(uint32_t slotid, uint32_t epid) "slotid %d, epid %d"
9ae3a8
+usb_xhci_ep_state(uint32_t slotid, uint32_t epid, const char *os, const char *ns) "slotid %d, epid %d, %s -> %s"
9ae3a8
 usb_xhci_xfer_start(void *xfer, uint32_t slotid, uint32_t epid, uint32_t streamid) "%p: slotid %d, epid %d, streamid %d"
9ae3a8
 usb_xhci_xfer_async(void *xfer) "%p"
9ae3a8
 usb_xhci_xfer_nak(void *xfer) "%p"
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8