]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: xhci-dbg: Display endpoint number and direction in context dump
authorJulius Werner <jwerner@chromium.org>
Mon, 15 Apr 2013 22:55:04 +0000 (15:55 -0700)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Wed, 5 Jun 2013 23:41:47 +0000 (16:41 -0700)
When CONFIG_XHCI_HCD_DEBUGGING is activated, the XHCI driver can dump
device and input contexts to the console. The endpoint contexts in that
dump are labeled "Endpoint N Context", where N is the XHCI endpoint
index (DCI - 1). This can be very confusing, especially for people who
are not that familiar with the XHCI specification. This patch introduces
an xhci_get_endpoint_address function (as a counterpart to the reverse
xhci_get_endpoint_index), and uses it to additionally display the
endpoint number and direction when dumping contexts, which are much more
commonly used concepts in USB.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
drivers/usb/host/xhci-dbg.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h

index 5f3a7c74aa8d39404212d342f6236fe1ea48d514..f2e7689e11a3fa416b6e3ce0115a736911855601 100644 (file)
@@ -503,11 +503,14 @@ static void xhci_dbg_ep_ctx(struct xhci_hcd *xhci,
        if (last_ep < 31)
                last_ep_ctx = last_ep + 1;
        for (i = 0; i < last_ep_ctx; ++i) {
+               unsigned int epaddr = xhci_get_endpoint_address(i);
                struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, ctx, i);
                dma_addr_t dma = ctx->dma +
                        ((unsigned long)ep_ctx - (unsigned long)ctx->bytes);
 
-               xhci_dbg(xhci, "Endpoint %02d Context:\n", i);
+               xhci_dbg(xhci, "%s Endpoint %02d Context (ep_index %02d):\n",
+                               usb_endpoint_out(epaddr) ? "OUT" : "IN",
+                               epaddr & USB_ENDPOINT_NUMBER_MASK, i);
                xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info\n",
                                &ep_ctx->ep_info,
                                (unsigned long long)dma, ep_ctx->ep_info);
index b4aa79d154b28b29db4b2a6509e974b74fdd4192..9e72caf2570a21a7b079e5c2fa07f827233db423 100644 (file)
@@ -1111,6 +1111,16 @@ unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc)
        return index;
 }
 
+/* The reverse operation to xhci_get_endpoint_index. Calculate the USB endpoint
+ * address from the XHCI endpoint index.
+ */
+unsigned int xhci_get_endpoint_address(unsigned int ep_index)
+{
+       unsigned int number = DIV_ROUND_UP(ep_index, 2);
+       unsigned int direction = ep_index % 2 ? USB_DIR_OUT : USB_DIR_IN;
+       return direction | number;
+}
+
 /* Find the flag for this endpoint (for use in the control context).  Use the
  * endpoint index to create a bitmask.  The slot context is bit 0, endpoint 0 is
  * bit 1, etc.
index 29c978e37135a9c836808407907803f4770fadae..3ee79d6fddae5bf8c7618db07c47a7bf6489fc10 100644 (file)
@@ -1641,6 +1641,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
 void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci,
                struct usb_device *udev);
 unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc);
+unsigned int xhci_get_endpoint_address(unsigned int ep_index);
 unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc);
 unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index);
 unsigned int xhci_last_valid_endpoint(u32 added_ctxs);