Skip to content

Commit 08fa726

Browse files
Michal Peciogregkh
authored andcommitted
Revert "usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running"
This reverts commit 28a76fc. No actual HW bugs are known where Endpoint Context shows Running state but Stop Endpoint fails repeatedly with Context State Error and leaves the endpoint state unchanged. Stop Endpoint retries on Running EPs have been performed since early 2021 with no such issues reported so far. Trying to handle this hypothetical case brings a more realistic danger: if Stop Endpoint fails on an endpoint which hasn't yet started after a doorbell ring and enough latency occurs before this completion event is handled, the driver may time out and begin removing cancelled TDs from a running endpoint, even though one more retry would stop it reliably. Such high latency is rare but not impossible, and removing TDs from a running endpoint can cause more damage than not giving back a cancelled URB (which wasn't happening anyway). So err on the side of caution and revert to the old policy of always retrying if the EP appears running. [Remove stable tag as we are dealing with theoretical cases -Mathias] Fixes: 28a76fc ("usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running") 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/20250917210726.97100-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 41f71de commit 08fa726

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

drivers/usb/host/xhci-ring.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,19 +1262,16 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,
12621262
* Stopped state, but it will soon change to Running.
12631263
*
12641264
* Assume this bug on unexpected Stop Endpoint failures.
1265-
* Keep retrying until the EP starts and stops again.
1265+
* Keep retrying until the EP starts and stops again, on
1266+
* chips where this is known to help. Wait for 100ms.
12661267
*/
1268+
if (time_is_before_jiffies(ep->stop_time + msecs_to_jiffies(100)))
1269+
break;
12671270
fallthrough;
12681271
case EP_STATE_RUNNING:
12691272
/* Race, HW handled stop ep cmd before ep was running */
12701273
xhci_dbg(xhci, "Stop ep completion ctx error, ctx_state %d\n",
12711274
GET_EP_CTX_STATE(ep_ctx));
1272-
/*
1273-
* Don't retry forever if we guessed wrong or a defective HC never starts
1274-
* the EP or says 'Running' but fails the command. We must give back TDs.
1275-
*/
1276-
if (time_is_before_jiffies(ep->stop_time + msecs_to_jiffies(100)))
1277-
break;
12781275

12791276
command = xhci_alloc_command(xhci, false, GFP_ATOMIC);
12801277
if (!command) {

0 commit comments

Comments
 (0)