aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-07-27 15:03:46 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-07-28 17:31:12 -0400
commit66e49d8774fa03539713e8f91169c37c05df1e94 (patch)
treee513ccdc346d7ff2d3e4c838c3023e6d73a49d53 /drivers/usb/host
parent2d83109be62edd9647c45d7ed2b916b03974a7ec (diff)
USB: xhci: Make debugging more verbose.
Add more debugging to the irq handler, slot context initialization, ring operations, URB cancellation, and MMIO writes. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/xhci-hcd.c47
-rw-r--r--drivers/usb/host/xhci-ring.c35
-rw-r--r--drivers/usb/host/xhci.h14
3 files changed, 72 insertions, 24 deletions
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 2e8e5bf6b6ca..764995fd59ef 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -267,8 +267,10 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
267{ 267{
268 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 268 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
269 u32 temp, temp2; 269 u32 temp, temp2;
270 union xhci_trb *trb;
270 271
271 spin_lock(&xhci->lock); 272 spin_lock(&xhci->lock);
273 trb = xhci->event_ring->dequeue;
272 /* Check if the xHC generated the interrupt, or the irq is shared */ 274 /* Check if the xHC generated the interrupt, or the irq is shared */
273 temp = xhci_readl(xhci, &xhci->op_regs->status); 275 temp = xhci_readl(xhci, &xhci->op_regs->status);
274 temp2 = xhci_readl(xhci, &xhci->ir_set->irq_pending); 276 temp2 = xhci_readl(xhci, &xhci->ir_set->irq_pending);
@@ -276,6 +278,15 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
276 spin_unlock(&xhci->lock); 278 spin_unlock(&xhci->lock);
277 return IRQ_NONE; 279 return IRQ_NONE;
278 } 280 }
281 xhci_dbg(xhci, "op reg status = %08x\n", temp);
282 xhci_dbg(xhci, "ir set irq_pending = %08x\n", temp2);
283 xhci_dbg(xhci, "Event ring dequeue ptr:\n");
284 xhci_dbg(xhci, "@%llx %08x %08x %08x %08x\n",
285 (unsigned long long)xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, trb),
286 lower_32_bits(trb->link.segment_ptr),
287 upper_32_bits(trb->link.segment_ptr),
288 (unsigned int) trb->link.intr_target,
289 (unsigned int) trb->link.control);
279 290
280 if (temp & STS_FATAL) { 291 if (temp & STS_FATAL) {
281 xhci_warn(xhci, "WARNING: Host System Error\n"); 292 xhci_warn(xhci, "WARNING: Host System Error\n");
@@ -385,6 +396,20 @@ int xhci_run(struct usb_hcd *hcd)
385 add_timer(&xhci->event_ring_timer); 396 add_timer(&xhci->event_ring_timer);
386#endif 397#endif
387 398
399 xhci_dbg(xhci, "Command ring memory map follows:\n");
400 xhci_debug_ring(xhci, xhci->cmd_ring);
401 xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
402 xhci_dbg_cmd_ptrs(xhci);
403
404 xhci_dbg(xhci, "ERST memory map follows:\n");
405 xhci_dbg_erst(xhci, &xhci->erst);
406 xhci_dbg(xhci, "Event ring:\n");
407 xhci_debug_ring(xhci, xhci->event_ring);
408 xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
409 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
410 temp_64 &= ~ERST_PTR_MASK;
411 xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
412
388 xhci_dbg(xhci, "// Set the interrupt modulation register\n"); 413 xhci_dbg(xhci, "// Set the interrupt modulation register\n");
389 temp = xhci_readl(xhci, &xhci->ir_set->irq_control); 414 temp = xhci_readl(xhci, &xhci->ir_set->irq_control);
390 temp &= ~ER_IRQ_INTERVAL_MASK; 415 temp &= ~ER_IRQ_INTERVAL_MASK;
@@ -409,20 +434,6 @@ int xhci_run(struct usb_hcd *hcd)
409 if (NUM_TEST_NOOPS > 0) 434 if (NUM_TEST_NOOPS > 0)
410 doorbell = xhci_setup_one_noop(xhci); 435 doorbell = xhci_setup_one_noop(xhci);
411 436
412 xhci_dbg(xhci, "Command ring memory map follows:\n");
413 xhci_debug_ring(xhci, xhci->cmd_ring);
414 xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
415 xhci_dbg_cmd_ptrs(xhci);
416
417 xhci_dbg(xhci, "ERST memory map follows:\n");
418 xhci_dbg_erst(xhci, &xhci->erst);
419 xhci_dbg(xhci, "Event ring:\n");
420 xhci_debug_ring(xhci, xhci->event_ring);
421 xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
422 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
423 temp_64 &= ~ERST_PTR_MASK;
424 xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
425
426 temp = xhci_readl(xhci, &xhci->op_regs->command); 437 temp = xhci_readl(xhci, &xhci->op_regs->command);
427 temp |= (CMD_RUN); 438 temp |= (CMD_RUN);
428 xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n", 439 xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n",
@@ -665,8 +676,12 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
665 goto done; 676 goto done;
666 677
667 xhci_dbg(xhci, "Cancel URB %p\n", urb); 678 xhci_dbg(xhci, "Cancel URB %p\n", urb);
679 xhci_dbg(xhci, "Event ring:\n");
680 xhci_debug_ring(xhci, xhci->event_ring);
668 ep_index = xhci_get_endpoint_index(&urb->ep->desc); 681 ep_index = xhci_get_endpoint_index(&urb->ep->desc);
669 ep_ring = xhci->devs[urb->dev->slot_id]->ep_rings[ep_index]; 682 ep_ring = xhci->devs[urb->dev->slot_id]->ep_rings[ep_index];
683 xhci_dbg(xhci, "Endpoint ring:\n");
684 xhci_debug_ring(xhci, ep_ring);
670 td = (struct xhci_td *) urb->hcpriv; 685 td = (struct xhci_td *) urb->hcpriv;
671 686
672 ep_ring->cancels_pending++; 687 ep_ring->cancels_pending++;
@@ -1178,6 +1193,8 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
1178 if (!udev->config) 1193 if (!udev->config)
1179 xhci_setup_addressable_virt_dev(xhci, udev); 1194 xhci_setup_addressable_virt_dev(xhci, udev);
1180 /* Otherwise, assume the core has the device configured how it wants */ 1195 /* Otherwise, assume the core has the device configured how it wants */
1196 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
1197 xhci_dbg_ctx(xhci, virt_dev->in_ctx, virt_dev->in_ctx_dma, 2);
1181 1198
1182 spin_lock_irqsave(&xhci->lock, flags); 1199 spin_lock_irqsave(&xhci->lock, flags);
1183 ret = xhci_queue_address_device(xhci, virt_dev->in_ctx_dma, 1200 ret = xhci_queue_address_device(xhci, virt_dev->in_ctx_dma,
@@ -1221,6 +1238,8 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
1221 default: 1238 default:
1222 xhci_err(xhci, "ERROR: unexpected command completion " 1239 xhci_err(xhci, "ERROR: unexpected command completion "
1223 "code 0x%x.\n", virt_dev->cmd_status); 1240 "code 0x%x.\n", virt_dev->cmd_status);
1241 xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
1242 xhci_dbg_ctx(xhci, virt_dev->out_ctx, virt_dev->out_ctx_dma, 2);
1224 ret = -EINVAL; 1243 ret = -EINVAL;
1225 break; 1244 break;
1226 } 1245 }
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index fe9541a89a3d..1fc0decfa0ac 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -135,6 +135,7 @@ static void next_trb(struct xhci_hcd *xhci,
135static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) 135static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer)
136{ 136{
137 union xhci_trb *next = ++(ring->dequeue); 137 union xhci_trb *next = ++(ring->dequeue);
138 unsigned long long addr;
138 139
139 ring->deq_updates++; 140 ring->deq_updates++;
140 /* Update the dequeue pointer further if that was a link TRB or we're at 141 /* Update the dequeue pointer further if that was a link TRB or we're at
@@ -152,6 +153,13 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer
152 ring->dequeue = ring->deq_seg->trbs; 153 ring->dequeue = ring->deq_seg->trbs;
153 next = ring->dequeue; 154 next = ring->dequeue;
154 } 155 }
156 addr = (unsigned long long) xhci_trb_virt_to_dma(ring->deq_seg, ring->dequeue);
157 if (ring == xhci->event_ring)
158 xhci_dbg(xhci, "Event ring deq = 0x%llx (DMA)\n", addr);
159 else if (ring == xhci->cmd_ring)
160 xhci_dbg(xhci, "Command ring deq = 0x%llx (DMA)\n", addr);
161 else
162 xhci_dbg(xhci, "Ring deq = 0x%llx (DMA)\n", addr);
155} 163}
156 164
157/* 165/*
@@ -171,6 +179,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer
171{ 179{
172 u32 chain; 180 u32 chain;
173 union xhci_trb *next; 181 union xhci_trb *next;
182 unsigned long long addr;
174 183
175 chain = ring->enqueue->generic.field[3] & TRB_CHAIN; 184 chain = ring->enqueue->generic.field[3] & TRB_CHAIN;
176 next = ++(ring->enqueue); 185 next = ++(ring->enqueue);
@@ -204,6 +213,13 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer
204 ring->enqueue = ring->enq_seg->trbs; 213 ring->enqueue = ring->enq_seg->trbs;
205 next = ring->enqueue; 214 next = ring->enqueue;
206 } 215 }
216 addr = (unsigned long long) xhci_trb_virt_to_dma(ring->enq_seg, ring->enqueue);
217 if (ring == xhci->event_ring)
218 xhci_dbg(xhci, "Event ring enq = 0x%llx (DMA)\n", addr);
219 else if (ring == xhci->cmd_ring)
220 xhci_dbg(xhci, "Command ring enq = 0x%llx (DMA)\n", addr);
221 else
222 xhci_dbg(xhci, "Ring enq = 0x%llx (DMA)\n", addr);
207} 223}
208 224
209/* 225/*
@@ -252,8 +268,7 @@ void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
252 * there might be more events to service. 268 * there might be more events to service.
253 */ 269 */
254 temp &= ~ERST_EHB; 270 temp &= ~ERST_EHB;
255 if (!in_interrupt()) 271 xhci_dbg(xhci, "// Write event ring dequeue pointer, preserving EHB bit\n");
256 xhci_dbg(xhci, "// Write event ring dequeue pointer, preserving EHB bit\n");
257 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, 272 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp,
258 &xhci->ir_set->erst_dequeue); 273 &xhci->ir_set->erst_dequeue);
259} 274}
@@ -781,6 +796,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
781 struct urb *urb = 0; 796 struct urb *urb = 0;
782 int status = -EINPROGRESS; 797 int status = -EINPROGRESS;
783 798
799 xhci_dbg(xhci, "In %s\n", __func__);
784 xdev = xhci->devs[TRB_TO_SLOT_ID(event->flags)]; 800 xdev = xhci->devs[TRB_TO_SLOT_ID(event->flags)];
785 if (!xdev) { 801 if (!xdev) {
786 xhci_err(xhci, "ERROR Transfer event pointed to bad slot\n"); 802 xhci_err(xhci, "ERROR Transfer event pointed to bad slot\n");
@@ -789,6 +805,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
789 805
790 /* Endpoint ID is 1 based, our index is zero based */ 806 /* Endpoint ID is 1 based, our index is zero based */
791 ep_index = TRB_TO_EP_ID(event->flags) - 1; 807 ep_index = TRB_TO_EP_ID(event->flags) - 1;
808 xhci_dbg(xhci, "%s - ep index = %d\n", __func__, ep_index);
792 ep_ring = xdev->ep_rings[ep_index]; 809 ep_ring = xdev->ep_rings[ep_index];
793 if (!ep_ring || (xdev->out_ctx->ep[ep_index].ep_info & EP_STATE_MASK) == EP_STATE_DISABLED) { 810 if (!ep_ring || (xdev->out_ctx->ep[ep_index].ep_info & EP_STATE_MASK) == EP_STATE_DISABLED) {
794 xhci_err(xhci, "ERROR Transfer event pointed to disabled endpoint\n"); 811 xhci_err(xhci, "ERROR Transfer event pointed to disabled endpoint\n");
@@ -797,6 +814,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
797 814
798 event_dma = event->buffer; 815 event_dma = event->buffer;
799 /* This TRB should be in the TD at the head of this ring's TD list */ 816 /* This TRB should be in the TD at the head of this ring's TD list */
817 xhci_dbg(xhci, "%s - checking for list empty\n", __func__);
800 if (list_empty(&ep_ring->td_list)) { 818 if (list_empty(&ep_ring->td_list)) {
801 xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n", 819 xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n",
802 TRB_TO_SLOT_ID(event->flags), ep_index); 820 TRB_TO_SLOT_ID(event->flags), ep_index);
@@ -806,11 +824,14 @@ static int handle_tx_event(struct xhci_hcd *xhci,
806 urb = NULL; 824 urb = NULL;
807 goto cleanup; 825 goto cleanup;
808 } 826 }
827 xhci_dbg(xhci, "%s - getting list entry\n", __func__);
809 td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); 828 td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list);
810 829
811 /* Is this a TRB in the currently executing TD? */ 830 /* Is this a TRB in the currently executing TD? */
831 xhci_dbg(xhci, "%s - looking for TD\n", __func__);
812 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, 832 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue,
813 td->last_trb, event_dma); 833 td->last_trb, event_dma);
834 xhci_dbg(xhci, "%s - found event_seg = %p\n", __func__, event_seg);
814 if (!event_seg) { 835 if (!event_seg) {
815 /* HC is busted, give up! */ 836 /* HC is busted, give up! */
816 xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not part of current TD\n"); 837 xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not part of current TD\n");
@@ -1027,6 +1048,8 @@ cleanup:
1027 /* FIXME for multi-TD URBs (who have buffers bigger than 64MB) */ 1048 /* FIXME for multi-TD URBs (who have buffers bigger than 64MB) */
1028 if (urb) { 1049 if (urb) {
1029 usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), urb); 1050 usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), urb);
1051 xhci_dbg(xhci, "Giveback URB %p, len = %d, status = %d\n",
1052 urb, td->urb->actual_length, status);
1030 spin_unlock(&xhci->lock); 1053 spin_unlock(&xhci->lock);
1031 usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, status); 1054 usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, status);
1032 spin_lock(&xhci->lock); 1055 spin_lock(&xhci->lock);
@@ -1044,6 +1067,7 @@ void xhci_handle_event(struct xhci_hcd *xhci)
1044 int update_ptrs = 1; 1067 int update_ptrs = 1;
1045 int ret; 1068 int ret;
1046 1069
1070 xhci_dbg(xhci, "In %s\n", __func__);
1047 if (!xhci->event_ring || !xhci->event_ring->dequeue) { 1071 if (!xhci->event_ring || !xhci->event_ring->dequeue) {
1048 xhci->error_bitmask |= 1 << 1; 1072 xhci->error_bitmask |= 1 << 1;
1049 return; 1073 return;
@@ -1056,18 +1080,25 @@ void xhci_handle_event(struct xhci_hcd *xhci)
1056 xhci->error_bitmask |= 1 << 2; 1080 xhci->error_bitmask |= 1 << 2;
1057 return; 1081 return;
1058 } 1082 }
1083 xhci_dbg(xhci, "%s - OS owns TRB\n", __func__);
1059 1084
1060 /* FIXME: Handle more event types. */ 1085 /* FIXME: Handle more event types. */
1061 switch ((event->event_cmd.flags & TRB_TYPE_BITMASK)) { 1086 switch ((event->event_cmd.flags & TRB_TYPE_BITMASK)) {
1062 case TRB_TYPE(TRB_COMPLETION): 1087 case TRB_TYPE(TRB_COMPLETION):
1088 xhci_dbg(xhci, "%s - calling handle_cmd_completion\n", __func__);
1063 handle_cmd_completion(xhci, &event->event_cmd); 1089 handle_cmd_completion(xhci, &event->event_cmd);
1090 xhci_dbg(xhci, "%s - returned from handle_cmd_completion\n", __func__);
1064 break; 1091 break;
1065 case TRB_TYPE(TRB_PORT_STATUS): 1092 case TRB_TYPE(TRB_PORT_STATUS):
1093 xhci_dbg(xhci, "%s - calling handle_port_status\n", __func__);
1066 handle_port_status(xhci, event); 1094 handle_port_status(xhci, event);
1095 xhci_dbg(xhci, "%s - returned from handle_port_status\n", __func__);
1067 update_ptrs = 0; 1096 update_ptrs = 0;
1068 break; 1097 break;
1069 case TRB_TYPE(TRB_TRANSFER): 1098 case TRB_TYPE(TRB_TRANSFER):
1099 xhci_dbg(xhci, "%s - calling handle_tx_event\n", __func__);
1070 ret = handle_tx_event(xhci, &event->trans_event); 1100 ret = handle_tx_event(xhci, &event->trans_event);
1101 xhci_dbg(xhci, "%s - returned from handle_tx_event\n", __func__);
1071 if (ret < 0) 1102 if (ret < 0)
1072 xhci->error_bitmask |= 1 << 9; 1103 xhci->error_bitmask |= 1 << 9;
1073 else 1104 else
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 60770c89132b..074728e10225 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1065,10 +1065,9 @@ static inline unsigned int xhci_readl(const struct xhci_hcd *xhci,
1065static inline void xhci_writel(struct xhci_hcd *xhci, 1065static inline void xhci_writel(struct xhci_hcd *xhci,
1066 const unsigned int val, __u32 __iomem *regs) 1066 const unsigned int val, __u32 __iomem *regs)
1067{ 1067{
1068 if (!in_interrupt()) 1068 xhci_dbg(xhci,
1069 xhci_dbg(xhci, 1069 "`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n",
1070 "`MEM_WRITE_DWORD(3'b000, 32'h%p, 32'h%0x, 4'hf);\n", 1070 regs, val);
1071 regs, val);
1072 writel(val, regs); 1071 writel(val, regs);
1073} 1072}
1074 1073
@@ -1096,10 +1095,9 @@ static inline void xhci_write_64(struct xhci_hcd *xhci,
1096 u32 val_lo = lower_32_bits(val); 1095 u32 val_lo = lower_32_bits(val);
1097 u32 val_hi = upper_32_bits(val); 1096 u32 val_hi = upper_32_bits(val);
1098 1097
1099 if (!in_interrupt()) 1098 xhci_dbg(xhci,
1100 xhci_dbg(xhci, 1099 "`MEM_WRITE_DWORD(3'b000, 64'h%p, 64'h%0lx, 4'hf);\n",
1101 "`MEM_WRITE_DWORD(3'b000, 64'h%p, 64'h%0lx, 4'hf);\n", 1100 regs, (long unsigned int) val);
1102 regs, (long unsigned int) val);
1103 writel(val_lo, ptr); 1101 writel(val_lo, ptr);
1104 writel(val_hi, ptr + 1); 1102 writel(val_hi, ptr + 1);
1105} 1103}