[TESTPATCH] xhci: custom debug patch for command mismatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add extra command ring, event ring and command queue debugging
to get more info on command mismatch error triggered by
Vincent Pelletier on BayTrail

will blurt out around 500 lines when hitting a command mismatch

Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
---
 drivers/usb/host/xhci-dbg.c  |  6 +++---
 drivers/usb/host/xhci-ring.c | 16 ++++++++++++++++
 drivers/usb/host/xhci.c      |  4 ++--
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index a915031..f4ec5db 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -330,7 +330,7 @@ void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg)
 
 	for (i = 0; i < TRBS_PER_SEGMENT; ++i) {
 		trb = &seg->trbs[i];
-		xhci_dbg(xhci, "@%016llx %08x %08x %08x %08x\n", addr,
+		xhci_err(xhci, "@%016llx %08x %08x %08x %08x\n", addr,
 			 lower_32_bits(le64_to_cpu(trb->link.segment_ptr)),
 			 upper_32_bits(le64_to_cpu(trb->link.segment_ptr)),
 			 le32_to_cpu(trb->link.intr_target),
@@ -426,9 +426,9 @@ void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci)
 	u64 val;
 
 	val = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
-	xhci_dbg(xhci, "// xHC command ring deq ptr low bits + flags = @%08x\n",
+	xhci_err(xhci, "// xHC command ring deq ptr low bits + flags = @%08x\n",
 			lower_32_bits(val));
-	xhci_dbg(xhci, "// xHC command ring deq ptr high bits = @%08x\n",
+	xhci_err(xhci, "// xHC command ring deq ptr high bits = @%08x\n",
 			upper_32_bits(val));
 }
 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 32f4d56..4db77a6 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1295,19 +1295,35 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
 	/* Is the command ring deq ptr out of sync with the deq seg ptr? */
 	if (cmd_dequeue_dma == 0) {
 		xhci->error_bitmask |= 1 << 4;
+		xhci_err(xhci, "Cmd ring deq ptr and seg out of sync\n");
 		return;
 	}
 	/* Does the DMA address match our internal dequeue pointer address? */
 	if (cmd_dma != (u64) cmd_dequeue_dma) {
 		xhci->error_bitmask |= 1 << 5;
+		xhci_err(xhci, "Cmd DMA address mismatch %llx, %llx\n",
+			 cmd_dma, (u64)cmd_dequeue_dma);
 		return;
 	}
 
 	cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
 
 	if (cmd->command_trb != xhci->cmd_ring->dequeue) {
+		struct xhci_command *cur_cmd, *tmp_cmd;
 		xhci_err(xhci,
 			 "Command completion event does not match command\n");
+		xhci_err(xhci, "cmd->command_trb: %p, cmd_ring_dequeue: %p\n",
+			 cmd->command_trb, xhci->cmd_ring->dequeue);
+
+		xhci_err(xhci, "* Command list *  (Current cmd trb= %p)\n",
+			 xhci->current_cmd->command_trb);
+		list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list)
+			xhci_err(xhci, "list cmd trb: %p\n", cur_cmd->command_trb);
+
+		xhci_err(xhci, "* Command ring *  (dq= %p)\n", xhci->cmd_ring->dequeue);
+		xhci_debug_ring(xhci, xhci->cmd_ring);
+		xhci_err(xhci, "* Event ring *  (dq= %p\n)\n", xhci->event_ring->dequeue);
+		xhci_debug_ring(xhci, xhci->event_ring);
 		return;
 	}
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a9a96b8..8192d14 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -605,14 +605,14 @@ int xhci_run(struct usb_hcd *hcd)
 		return ret;
 
 	xhci_dbg(xhci, "Command ring memory map follows:\n");
-	xhci_debug_ring(xhci, xhci->cmd_ring);
+/*	xhci_debug_ring(xhci, xhci->cmd_ring); */
 	xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
 	xhci_dbg_cmd_ptrs(xhci);
 
 	xhci_dbg(xhci, "ERST memory map follows:\n");
 	xhci_dbg_erst(xhci, &xhci->erst);
 	xhci_dbg(xhci, "Event ring:\n");
-	xhci_debug_ring(xhci, xhci->event_ring);
+/*	xhci_debug_ring(xhci, xhci->event_ring); */
 	xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
 	temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
 	temp_64 &= ~ERST_PTR_MASK;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux