Skip to content

Commit 28a76fc

Browse files
Michal Peciogregkh
authored andcommitted
usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running
Nothing prevents a broken HC from claiming that an endpoint is Running and repeatedly rejecting Stop Endpoint with Context State Error. Avoid infinite retries and give back cancelled TDs. No such cases known so far, but HCs have bugs. 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/20250311154551.4035726-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dfc8835 commit 28a76fc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/usb/host/xhci-ring.c

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

12781281
command = xhci_alloc_command(xhci, false, GFP_ATOMIC);
12791282
if (!command) {

0 commit comments

Comments
 (0)