Re: [PATCH 2/4] usb: xhci: move debug capabilities from trb_in_td() to handle_tx_event()

Michał Pecio
2025-03-05T08:46:05Z

> +debug_finding_td:
> + xhci_err(xhci, "Transfer event %u ep %d dma %016llx not part of current TD start %016llx end %016llx\n",
> + trb_comp_code, ep_index, (unsigned long long)ep_trb_dma,
> + (unsigned long long)xhci_trb_virt_to_dma(td->start_seg, td->start_trb),
> + (unsigned long long)xhci_trb_virt_to_dma(td->end_seg, td->end_trb)); +
> + xhci_for_each_ring_seg(ep_ring->first_seg, ep_seg) {
> + xhci_warn(xhci, "Ring seg %u trb start %016llx end %016llx\n", ep_seg->num,
> + (unsigned long long)ep_seg->dma,
> + (unsigned long long)(ep_seg->dma + TRB_SEGMENT_SIZE));
> + }
> + return -ESHUTDOWN;

Cleaning up trb_in_td() is obviously the right thing to do, but one
thing I always disliked about this message is how long and verbose it
is. Not sure if dumping all ring segments is useful here, seg->dma can
generally be deduced by looking at the DMA pointers involved.

As far as improvements go, IMO it would be much more useful to decode
those pointers into seg-number/trb-index pairs. I wrote a PoC and the
result is quite encouraging, I may submit it if there is interest.

Regards,
Michal