Skip to content

Commit ccf4175

Browse files
matnymansamueldr
authored andcommitted
xhci: always handle "Command Ring Stopped" events
[ Upstream commit 33be126 ] Fix "Command completion event does not match command" errors by always handling the command ring stopped events. The command ring stopped event is generated as a result of aborting or stopping the command ring with a register write. It is not caused by a command in the command queue, and thus won't have a matching command in the comman list. Solve it by handling the command ring stopped event before checking for a matching command. In most command time out cases we abort the command ring, and get a command ring stopped event. The events command pointer will point at the current command ring dequeue, which in most cases matches the timed out command in the command list, and no error messages are seen. If we instead get a command aborted event before the command ring stopped event, the abort event will increse the command ring dequeue pointer, and the following command ring stopped events command pointer will point at the next, not yet queued command. This case triggered the error message Signed-off-by: Mathias Nyman <[email protected]> CC: <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3a0e20b commit ccf4175

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,12 +1336,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
13361336

13371337
cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
13381338

1339-
if (cmd->command_trb != xhci->cmd_ring->dequeue) {
1340-
xhci_err(xhci,
1341-
"Command completion event does not match command\n");
1342-
return;
1343-
}
1344-
13451339
del_timer(&xhci->cmd_timer);
13461340

13471341
trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
@@ -1353,6 +1347,13 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
13531347
xhci_handle_stopped_cmd_ring(xhci, cmd);
13541348
return;
13551349
}
1350+
1351+
if (cmd->command_trb != xhci->cmd_ring->dequeue) {
1352+
xhci_err(xhci,
1353+
"Command completion event does not match command\n");
1354+
return;
1355+
}
1356+
13561357
/*
13571358
* Host aborted the command ring, check if the current command was
13581359
* supposed to be aborted, otherwise continue normally.

0 commit comments

Comments
 (0)