Skip to content

Commit a7f2e92

Browse files
matnymangregkh
authored andcommitted
xhci: Fix 5.12 regression of missing xHC cache clearing command after a Stall
If endpoints halts due to a stall then the dequeue pointer read from hardware may already be set ahead of the stalled TRB. After commit 674f843 ("xhci: split handling halted endpoints into two steps") in 5.12 xhci driver won't issue a Set TR Dequeue if hardware dequeue pointer is already in the right place. Turns out the "Set TR Dequeue pointer" command is anyway needed as it in addition to moving the dequeue pointer also clears endpoint state and cache. Fixes: 674f843 ("xhci: split handling halted endpoints into two steps") Cc: <[email protected]> # 5.12 Reported-by: Peter Ganzhorn <[email protected]> Tested-by: Peter Ganzhorn <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a80c203 commit a7f2e92

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,14 +933,18 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)
933933
continue;
934934
}
935935
/*
936-
* If ring stopped on the TD we need to cancel, then we have to
936+
* If a ring stopped on the TD we need to cancel then we have to
937937
* move the xHC endpoint ring dequeue pointer past this TD.
938+
* Rings halted due to STALL may show hw_deq is past the stalled
939+
* TD, but still require a set TR Deq command to flush xHC cache.
938940
*/
939941
hw_deq = xhci_get_hw_deq(xhci, ep->vdev, ep->ep_index,
940942
td->urb->stream_id);
941943
hw_deq &= ~0xf;
942944

943-
if (trb_in_td(xhci, td->start_seg, td->first_trb,
945+
if (td->cancel_status == TD_HALTED) {
946+
cached_td = td;
947+
} else if (trb_in_td(xhci, td->start_seg, td->first_trb,
944948
td->last_trb, hw_deq, false)) {
945949
switch (td->cancel_status) {
946950
case TD_CLEARED: /* TD is already no-op */

0 commit comments

Comments
 (0)