Skip to content

Commit fd9d55d

Browse files
Michal Peciogregkh
authored andcommitted
xhci: retry Stop Endpoint on buggy NEC controllers
Two NEC uPD720200 adapters have been observed to randomly misbehave: a Stop Endpoint command fails with Context Error, the Output Context indicates Stopped state, and the endpoint keeps running. Very often, Set TR Dequeue Pointer is seen to fail next with Context Error too, in addition to problems from unexpectedly completed cancelled work. The pathology is common on fast running isoc endpoints like uvcvideo, but has also been reproduced on a full-speed bulk endpoint of pl2303. It seems all EPs are affected, with risk proportional to their load. Reproduction involves receiving any kind of stream and closing it to make the device driver cancel URBs already queued in advance. Deal with it by retrying the command like in the Running state. Signed-off-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20240229141438.619372-8-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 91edf5a commit fd9d55d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,15 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,
11541154
break;
11551155
ep->ep_state &= ~EP_STOP_CMD_PENDING;
11561156
return;
1157+
case EP_STATE_STOPPED:
1158+
/*
1159+
* NEC uPD720200 sometimes sets this state and fails with
1160+
* Context Error while continuing to process TRBs.
1161+
* Be conservative and trust EP_CTX_STATE on other chips.
1162+
*/
1163+
if (!(xhci->quirks & XHCI_NEC_HOST))
1164+
break;
1165+
fallthrough;
11571166
case EP_STATE_RUNNING:
11581167
/* Race, HW handled stop ep cmd before ep was running */
11591168
xhci_dbg(xhci, "Stop ep completion ctx error, ep is running\n");

0 commit comments

Comments
 (0)