xhci printfery

Change-Id: I90e28d64b23fcd29420a24093a98a7f65cbceb0e
diff --git a/system/dev/usb/xhci/xhci-device-manager.c b/system/dev/usb/xhci/xhci-device-manager.c
index d856418..634663f 100644
--- a/system/dev/usb/xhci/xhci-device-manager.c
+++ b/system/dev/usb/xhci/xhci-device-manager.c
@@ -85,7 +85,7 @@
     uint8_t* device_context = (uint8_t *)io_buffer_virt(&slot->buffer);
 
     xhci_endpoint_t* ep = &slot->eps[0];
-    status = xhci_transfer_ring_init(&ep->transfer_ring, TRANSFER_RING_SIZE);
+    status = xhci_transfer_ring_init(&ep->transfer_ring, TRANSFER_RING_SIZE, 0);
     if (status < 0) return status;
     ep->transfer_state = calloc(1, sizeof(xhci_transfer_state_t));
     if (!ep->transfer_state) {
@@ -609,7 +609,7 @@
                 (xhci_endpoint_context_t*)&xhci->input_context[(index + 2) * xhci->context_size];
         memset((void*)epc, 0, xhci->context_size);
         // allocate a transfer ring for the endpoint
-        zx_status_t status = xhci_transfer_ring_init(&ep->transfer_ring, TRANSFER_RING_SIZE);
+        zx_status_t status = xhci_transfer_ring_init(&ep->transfer_ring, TRANSFER_RING_SIZE, index);
         if (status < 0) {
             mtx_unlock(&xhci->input_context_lock);
             mtx_unlock(&ep->lock);
diff --git a/system/dev/usb/xhci/xhci-transfer.c b/system/dev/usb/xhci/xhci-transfer.c
index 06fb2bf..fbfe848 100644
--- a/system/dev/usb/xhci/xhci-transfer.c
+++ b/system/dev/usb/xhci/xhci-transfer.c
@@ -107,6 +107,7 @@
     // so move them all to the queued list so they will be requeued
     // Completed these with ZX_ERR_CANCELED out of the lock.
     // Remove from tail and add to head to preserve the ordering
+printf("xhci_reset_endpoint stuff happening\n");
     while ((req = list_remove_tail_type(&ep->pending_reqs, usb_request_t, node)) != NULL) {
         list_add_head(&ep->queued_reqs, &req->node);
     }
@@ -415,6 +416,8 @@
                                              list_node_t* completed_reqs) {
     xhci_endpoint_t* ep = &slot->eps[ep_index];
 
+printf("xhci_process_transactions_locked %u\n", ep_index);
+
     // loop until we fill our transfer ring or run out of requests to process
     while (1) {
         if (xhci_transfer_ring_free_trbs(&ep->transfer_ring) == 0) {
diff --git a/system/dev/usb/xhci/xhci-trb.c b/system/dev/usb/xhci/xhci-trb.c
index fd2f14a..783384a 100644
--- a/system/dev/usb/xhci/xhci-trb.c
+++ b/system/dev/usb/xhci/xhci-trb.c
@@ -5,7 +5,7 @@
 #include "xhci.h"
 #include <stdio.h>
 
-zx_status_t xhci_transfer_ring_init(xhci_transfer_ring_t* ring, int count) {
+zx_status_t xhci_transfer_ring_init(xhci_transfer_ring_t* ring, int count, int id) {
     zx_status_t status = io_buffer_init(&ring->buffer, count * sizeof(xhci_trb_t),
                                         IO_BUFFER_RW | IO_BUFFER_CONTIG);
     if (status != ZX_OK) return status;
@@ -15,6 +15,7 @@
     ring->dequeue_ptr = ring->start;
     ring->size = count - 1;    // subtract 1 for LINK TRB at the end
     ring->pcs = TRB_C;
+    ring->id = id;
 
     // set link TRB at end to point back to the beginning
     trb_set_ptr(&ring->start[count - 1], (void *)io_buffer_phys(&ring->buffer));
@@ -101,7 +102,7 @@
     // check for LINK TRB
     control = XHCI_READ32(&trb->control);
     if ((control & TRB_TYPE_MASK) == (TRB_LINK << TRB_TYPE_START)) {
-printf("got TRB_LINK\n");
+printf("got TRB_LINK for %d\n", ring->id);
         control = (control & ~(TRB_CHAIN | TRB_C)) | chain | ring->pcs;
         XHCI_WRITE32(&trb->control, control);
 #if XHCI_USE_CACHE_OPS
diff --git a/system/dev/usb/xhci/xhci-trb.h b/system/dev/usb/xhci/xhci-trb.h
index 82b3d58..52caf1c 100644
--- a/system/dev/usb/xhci/xhci-trb.h
+++ b/system/dev/usb/xhci/xhci-trb.h
@@ -18,6 +18,7 @@
     xhci_trb_t* dequeue_ptr;    // next to be processed by consumer
                                 // (not used for command ring)
     size_t size;                // number of TRBs in ring
+    int id;
 } xhci_transfer_ring_t;
 
 typedef struct xhci_event_ring {
@@ -30,7 +31,7 @@
 
 typedef struct xhci xhci_t;
 
-zx_status_t xhci_transfer_ring_init(xhci_transfer_ring_t* tr, int count);
+zx_status_t xhci_transfer_ring_init(xhci_transfer_ring_t* tr, int count, int id);
 void xhci_transfer_ring_free(xhci_transfer_ring_t* ring);
 size_t xhci_transfer_ring_free_trbs(xhci_transfer_ring_t* ring);
 zx_status_t xhci_event_ring_init(xhci_t* xhci, int interrupter, int count);
diff --git a/system/dev/usb/xhci/xhci.c b/system/dev/usb/xhci/xhci.c
index 0bd725d..1cd42a5 100644
--- a/system/dev/usb/xhci/xhci.c
+++ b/system/dev/usb/xhci/xhci.c
@@ -300,7 +300,7 @@
         xhci->dcbaa[0] = 0;
     }
 
-    result = xhci_transfer_ring_init(&xhci->command_ring, COMMAND_RING_SIZE);
+    result = xhci_transfer_ring_init(&xhci->command_ring, COMMAND_RING_SIZE, -1);
     if (result != ZX_OK) {
         dprintf(ERROR, "xhci_command_ring_init failed\n");
         goto fail;