xhci fixes for usb-linus
Subsystems (3)
cover xhci fixes for usb-linus
Hi Greg
two patches for usb-linus and 5.12 stable
xhci changes in 5.12 caused a regression in stall handling. Due to this some usb card readers failed to work with 5.12
These two patches fix that regression.
Thanks
-Mathias
Mathias Nyman (2):
xhci: fix giving back URB with incorrect status regression in 5.12
xhci: Fix 5.12 regression of missing xHC cache clearing command after
a Stall
drivers/usb/host/xhci-ring.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 xhci: fix giving back URB with incorrect status regression in 5.12
5.12 kernel changes how xhci handles cancelled URBs and halted endpoints. Among these changes cancelled and stalled URBs are no longer given back before they are cleared from xHC hardware cache.
These changes unfortunately cleared the -EPIPE status of a stalled transfer in one case before giving bak the URB, causing a USB card reader to fail from working.
--- drivers/usb/host/xhci-ring.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/host/xhci-ring.c +1 -5
@@ -828,14 +828,10 @@ static void xhci_giveback_invalidated_tds(struct xhci_virt_ep *ep)list_for_each_entry_safe (td, tmp_td, &ep->cancelled_td_list, cancelled_td_list) { -/* -* Doesn't matter what we pass for status, since the core will -* just overwrite it (because the URB has been unlinked). -*/ ring =xhci_urb_to_transfer_ring (ep->xhci, td->urb);if (td->cancel_status ==TD_CLEARED ) -xhci_td_cleanup (ep->xhci, td, ring,0 ); +xhci_td_cleanup (ep->xhci, td, ring, td->status);if (ep->xhci->xhc_state &XHCI_STATE_DYING )return ;
Signature · 1 line
2.25.1
PATCH 2/2 xhci: Fix 5.12 regression of missing xHC cache clearing command after a Stall
In reply to Mathias NymanIf endpoints halts due to a stall then the dequeue pointer read from hardware may already be set ahead of the stalled TRB.
After commit 674f8438c121 ("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.
--- drivers/usb/host/xhci-ring.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-ring.c +6 -2
@@ -933,14 +933,18 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)continue ; }/* -* If ring stopped on the TD we need to cancel, then we have to +* If a ring stopped on the TD we need to cancel then we have to * move the xHC endpoint ring dequeue pointer past this TD. +* Rings halted due to STALL may show hw_deq is past the stalled +* TD, but still require a set TR Deq command to flush xHC cache. */ hw_deq =xhci_get_hw_deq (xhci, ep->vdev, ep->ep_index, td->urb->stream_id); hw_deq &= ~0xf ; -if (trb_in_td (xhci, td->start_seg, td->first_trb, +if (td->cancel_status ==TD_HALTED ) { + cached_td = td; + }else if (trb_in_td (xhci, td->start_seg, td->first_trb, td->last_trb, hw_deq, false)) {switch (td->cancel_status) {case TD_CLEARED :/* TD is already no-op */
Signature · 1 line
2.25.1