mbox series

[v2,0/3] xhci: ring queuing cleanups plus a quirk

Message ID 20250225125750.1b345e2c@foxbook (mailing list archive)
Headers show
Series xhci: ring queuing cleanups plus a quirk | expand

Message

MichaƂ Pecio Feb. 25, 2025, 11:57 a.m. UTC
I was looking at all uses of enqueue/dequeue pointers and I found two
rather complex loops which appear to be doing really simple things.

I don't understand why they were written this way, it seems wasteful
and I see nothing that should go wrong if they are replaced with much
simpler code.

I rewrote them and the driver still works. I exercised Set TR Dequeue
code by starting/stopping isoc streams, using usb-storage with crappy
cable (transaction errors, halts) and also the smartctl -x trick that
results in URB unlinks (both on usb-storage and uas) with some disks.

The third patch is a dedupe. BTW, that comment there about section
6.4.4.1 of the 0.95 spec seems to be wrong, I suspect it should say
that the chain bit cannot be *cleared* because that's how the code
works and what some commit messages say. But I don't have 0.95 spec.

New in v2:
- dropped the patch for obsolete update_ring_for_set_deq_completion()
- added a patch to enable the link chain quirk on one more HC
- don't touch the chain bit in inc_enq_past_link() on quirky HCs
- don't call inc_enq_past_link() unnecessarily

Michal Pecio (3):
  usb: xhci: Apply the link chain quirk on NEC isoc endpoints
  usb: xhci: Simplify moving HW Dequeue Pointer past cancelled TDs
  usb: xhci: Unify duplicate inc_enq() code

 drivers/usb/host/xhci-ring.c | 198 +++++++++++++----------------------
 drivers/usb/host/xhci.h      |  13 ++-
 2 files changed, 86 insertions(+), 125 deletions(-)

Comments

Mathias Nyman Feb. 26, 2025, 12:39 p.m. UTC | #1
On 25.2.2025 13.57, Michal Pecio wrote:
> I was looking at all uses of enqueue/dequeue pointers and I found two
> rather complex loops which appear to be doing really simple things.
> 
> I don't understand why they were written this way, it seems wasteful
> and I see nothing that should go wrong if they are replaced with much
> simpler code.
> 
> I rewrote them and the driver still works. I exercised Set TR Dequeue
> code by starting/stopping isoc streams, using usb-storage with crappy
> cable (transaction errors, halts) and also the smartctl -x trick that
> results in URB unlinks (both on usb-storage and uas) with some disks.
> 
> The third patch is a dedupe. BTW, that comment there about section
> 6.4.4.1 of the 0.95 spec seems to be wrong, I suspect it should say
> that the chain bit cannot be *cleared* because that's how the code
> works and what some commit messages say. But I don't have 0.95 spec.
> 
> New in v2:
> - dropped the patch for obsolete update_ring_for_set_deq_completion()
> - added a patch to enable the link chain quirk on one more HC
> - don't touch the chain bit in inc_enq_past_link() on quirky HCs
> - don't call inc_enq_past_link() unnecessarily
> 
> Michal Pecio (3):
>    usb: xhci: Apply the link chain quirk on NEC isoc endpoints
>    usb: xhci: Simplify moving HW Dequeue Pointer past cancelled TDs
>    usb: xhci: Unify duplicate inc_enq() code
> 

Thanks, adding Patch 1/3 and 3/3, skipping 2/3 for now.

-Mathias