Skip to content

xhci: Sort out the TD skipping business

Michal Pecio linux-usb lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyIn review
  2. v15 patches 9 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2usb: xhci: Shorten the TD skipping loopdrivers/usb/host/xhci-ring.c+33 -350 replies
2/2usb: xhci: Rework and improve the TD matching and skipping logicdrivers/usb/host/xhci-ring.c+61 -760 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] xhci: Sort out the TD skipping business

Hi Mathias,

I see that you have picked this series for 7.4:
https://lore.kernel.org/linux-usb/[email protected]/

There is unfortunately a small bug in "Shorten the TD skipping loop":
old_trb_comp_code is assigned before being used by the !trb_in_td() block, which means that we use the *current* trb_comp_code instead.

ep_ring->old_trb_comp_code = trb_comp_code;

if (ring_xrun_event)
return 0;

+ /* Handle events not referencing the current TD */
+ if (!trb_in_td(td, ep_trb_dma)) {
[...]
+ if (xhci_spurious_success_tx_event(xhci, ep_ring))

			// ^-- uses old_trb_comp_code

This causes false warnings when running UVC with non-power-of-2 alt setting on HCs like VIA, which generate Success after a mid-TD Short Packet. So this will surely bother users with such workloads.

It happened because I tried to resuse existing ring_xrun_event check and remove an identical check from the !trb_in_td() block, so I placed the block after this check.

Revised patch places it before the old_trb_comp_code assignment and retains a duplicate ring_xrun_event check in the moved code, I'm not trying to be clever anymore. Patch 2/2 is a necessary rebase.

It is also a pre-existing bug that in some cases the function bails out without updating old_trb_comp_code, even though we know that the prior TD cannot generate more events (e.g. we are handling ring underrun). But that's a separate issue that causes missing warnings in rare cases rather than false warnings in common cases.

Regards,
Michal