> On Nov 22, 2019, at 20:17, Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx> wrote: [snipped] > > The event ring is already overwritten with new events when dumped. > > Could you apply the code below, it will dump both the endpoint transfer ring > and the event ring at the right moment: The log is quite large so I pasted it here: https://pastebin.ubuntu.com/p/wWpS8ctNrb/ Kai-Heng > > Attached as a patch as well. > > diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c > index 620846f30b4f..a1a9a408c479 100644 > --- a/drivers/usb/host/xhci-ring.c > +++ b/drivers/usb/host/xhci-ring.c > @@ -201,6 +201,31 @@ void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring) > * @more_trbs_coming: Will you enqueue more TRBs before calling > * prepare_transfer()? > */ > + > +static int xhci_dump_ring(struct xhci_hcd *xhci, struct xhci_ring *ring) > +{ > + struct xhci_segment *seg; > + dma_addr_t dma; > + union xhci_trb *trb; > + int i, j; > + > + seg = ring->first_seg; > + > + for (i = 0; i < ring->num_segs; i++) { > + for (j = 0; j < TRBS_PER_SEGMENT; j++) { > + trb = &seg->trbs[j]; > + dma = seg->dma + j * sizeof(*trb); > + xhci_err(xhci, "%pad: %s\n", &dma, > + xhci_decode_trb(le32_to_cpu(trb->generic.field[0]), > + le32_to_cpu(trb->generic.field[1]), > + le32_to_cpu(trb->generic.field[2]), > + le32_to_cpu(trb->generic.field[3]))); > + } > + seg = seg->next; > + } > + return 0; > +} > + > static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, > bool more_trbs_coming) > { > @@ -2318,6 +2343,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, > u32 trb_comp_code; > int td_num = 0; > bool handling_skipped_tds = false; > + static unsigned int err_cnt; > slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); > ep_index = TRB_TO_EP_ID(le32_to_cpu(event->flags)) - 1; > @@ -2579,6 +2605,12 @@ static int handle_tx_event(struct xhci_hcd *xhci, > trb_in_td(xhci, ep_ring->deq_seg, > ep_ring->dequeue, td->last_trb, > ep_trb_dma, true); > + if (err_cnt++ == 5) { > + xhci_err(xhci, "EVENT RING:\n"); > + xhci_dump_ring(xhci, xhci->event_ring); > + xhci_err(xhci, "ENDPOINT RING:\n"); > + xhci_dump_ring(xhci, ep_ring); > + } > return -ESHUTDOWN; > } > <0001-xhci-dump-event-ring-and-endpoint-ring-if-TRB-not-fo.patch>