By passing a level parameter to xhci_debug_ring(), we can print out the ring in different debug levels. Signed-off-by: Andiry Xu <andiry.xu@xxxxxxx> --- drivers/usb/host/xhci-dbg.c | 33 +++++++++++++++++++++++++++++---- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/host/xhci.h | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c index e9b0f04..04c9457 100644 --- a/drivers/usb/host/xhci-dbg.c +++ b/drivers/usb/host/xhci-dbg.c @@ -326,6 +326,24 @@ void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg) } } +/* The xhci_warn() version of xhci_debug_segment() */ +void xhci_warn_segment(struct xhci_hcd *xhci, struct xhci_segment *seg) +{ + int i; + u64 addr = seg->dma; + union xhci_trb *trb = seg->trbs; + + for (i = 0; i < TRBS_PER_SEGMENT; ++i) { + trb = &seg->trbs[i]; + xhci_warn(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), + le32_to_cpu(trb->link.control)); + addr += sizeof(*trb); + } +} + void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring) { xhci_dbg(xhci, "Ring deq = %p (virt), 0x%llx (dma)\n", @@ -351,19 +369,26 @@ void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring) * Check that the dequeue and enqueue pointers point to real data in this ring * (not some other ring). */ -void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring) +void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, int level) { /* FIXME: Throw an error if any segment doesn't have a Link TRB */ struct xhci_segment *seg; struct xhci_segment *first_seg = ring->first_seg; - xhci_debug_segment(xhci, first_seg); + if (level) + xhci_warn_segment(xhci, first_seg); + else + xhci_debug_segment(xhci, first_seg); if (!ring->enq_updates && !ring->deq_updates) { xhci_dbg(xhci, " Ring has not been updated\n"); return; } - for (seg = first_seg->next; seg != first_seg; seg = seg->next) - xhci_debug_segment(xhci, seg); + for (seg = first_seg->next; seg != first_seg; seg = seg->next) { + if (level) + xhci_warn_segment(xhci, seg); + else + xhci_debug_segment(xhci, seg); + } } void xhci_dbg_ep_rings(struct xhci_hcd *xhci, diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index eb2787b..4a0d922 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -526,14 +526,14 @@ int xhci_run(struct usb_hcd *hcd) #endif xhci_dbg(xhci, "Command ring memory map follows:\n"); - xhci_debug_ring(xhci, xhci->cmd_ring); + xhci_debug_ring(xhci, xhci->cmd_ring, 0); 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, 0); xhci_dbg_ring_ptrs(xhci, xhci->event_ring); temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); temp_64 &= ~ERST_PTR_MASK; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6755143..1555bbb 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1576,7 +1576,7 @@ void xhci_print_run_regs(struct xhci_hcd *xhci); void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb); void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb); void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg); -void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring); +void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, int level); void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst); void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci); void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring); -- 1.7.4.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