A bunch of miscellaneous debug messages to aid in working out USB
issues.

Signed-off-by: Hector Martin <mar...@marcan.st>
---
 drivers/usb/host/xhci-ring.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b60661fe05e7..dabe6cf86af2 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -214,6 +214,9 @@ static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct 
xhci_ring *ring,
 
        addr = xhci_trb_virt_to_dma(ring->enq_seg, (union xhci_trb *)trb);
 
+       debug("trb @ %llx: %08x %08x %08x %08x\n", addr,
+             trb_fields[0], trb_fields[1], trb_fields[2], trb_fields[3]);
+
        inc_enq(ctrl, ring, more_trbs_coming);
 
        return addr;
@@ -296,6 +299,8 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, dma_addr_t 
addr, u32 slot_id,
 {
        u32 fields[4];
 
+       debug("CMD: %llx 0x%x 0x%x %d\n", addr, slot_id, ep_index, cmd);
+
        BUG_ON(prepare_ring(ctrl, ctrl->cmd_ring, EP_STATE_RUNNING));
 
        fields[0] = lower_32_bits(addr);
@@ -471,8 +476,14 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl 
*ctrl, trb_type expected)
 
                type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->event_cmd.flags));
                if (type == expected ||
-                   (expected == TRB_NONE && type != TRB_PORT_STATUS))
+                   (expected == TRB_NONE && type != TRB_PORT_STATUS)) {
+                       debug("Event: %08x %08x %08x %08x\n",
+                             le32_to_cpu(event->generic.field[0]),
+                             le32_to_cpu(event->generic.field[1]),
+                             le32_to_cpu(event->generic.field[2]),
+                             le32_to_cpu(event->generic.field[3]));
                        return event;
+               }
 
                if (type == TRB_PORT_STATUS)
                /* TODO: remove this once enumeration has been reworked */
@@ -484,8 +495,9 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, 
trb_type expected)
                                le32_to_cpu(event->generic.field[2])) !=
                                                                COMP_SUCCESS);
                else
-                       printf("Unexpected XHCI event TRB, skipping... "
+                       printf("Unexpected XHCI event TRB, expected %d... "
                                "(%08x %08x %08x %08x)\n",
+                               expected,
                                le32_to_cpu(event->generic.field[0]),
                                le32_to_cpu(event->generic.field[1]),
                                le32_to_cpu(event->generic.field[2]),
@@ -602,10 +614,13 @@ static void abort_td(struct usb_device *udev, int 
ep_index)
 static void record_transfer_result(struct usb_device *udev,
                                   union xhci_trb *event, int length)
 {
+       xhci_comp_code code = GET_COMP_CODE(
+               le32_to_cpu(event->trans_event.transfer_len));
+
        udev->act_len = min(length, length -
                
(int)EVENT_TRB_LEN(le32_to_cpu(event->trans_event.transfer_len)));
 
-       switch (GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len))) {
+       switch (code) {
        case COMP_SUCCESS:
                BUG_ON(udev->act_len != length);
                /* fallthrough */
@@ -613,16 +628,23 @@ static void record_transfer_result(struct usb_device 
*udev,
                udev->status = 0;
                break;
        case COMP_STALL:
+               debug("Xfer STALL\n");
                udev->status = USB_ST_STALLED;
                break;
        case COMP_DB_ERR:
+               debug("Xfer DB_ERR\n");
+               udev->status = USB_ST_BUF_ERR;
+               break;
        case COMP_TRB_ERR:
+               debug("Xfer TRB_ERR\n");
                udev->status = USB_ST_BUF_ERR;
                break;
        case COMP_BABBLE:
+               debug("Xfer BABBLE\n");
                udev->status = USB_ST_BABBLE_DET;
                break;
        default:
+               debug("Xfer error: %d\n", code);
                udev->status = 0x80;  /* USB_ST_TOO_LAZY_TO_MAKE_A_NEW_MACRO */
        }
 }
@@ -1016,6 +1038,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
        record_transfer_result(udev, event, length);
        xhci_acknowledge_event(ctrl);
        if (udev->status == USB_ST_STALLED) {
+               debug("EP %d stalled\n", ep_index);
                reset_ep(udev, ep_index);
                return -EPIPE;
        }

-- 
2.41.0

Reply via email to