Skip to content

Commit d55d925

Browse files
Faisal Hassangregkh
authored andcommitted
xhci: Fix Link TRB DMA in command ring stopped completion event
commit 075919f upstream. During the aborting of a command, the software receives a command completion event for the command ring stopped, with the TRB pointing to the next TRB after the aborted command. If the command we abort is located just before the Link TRB in the command ring, then during the 'command ring stopped' completion event, the xHC gives the Link TRB in the event's cmd DMA, which causes a mismatch in handling command completion event. To address this situation, move the 'command ring stopped' completion event check slightly earlier, since the specific command it stopped on isn't of significant concern. Fixes: 7f84eef ("USB: xhci: No-op command queueing and irq handler.") Cc: [email protected] Signed-off-by: Faisal Hassan <[email protected]> Acked-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3a5693b commit d55d925

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,14 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
14311431

14321432
trace_xhci_handle_command(xhci->cmd_ring, &cmd_trb->generic);
14331433

1434+
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
1435+
1436+
/* If CMD ring stopped we own the trbs between enqueue and dequeue */
1437+
if (cmd_comp_code == COMP_COMMAND_RING_STOPPED) {
1438+
complete_all(&xhci->cmd_ring_stop_completion);
1439+
return;
1440+
}
1441+
14341442
cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
14351443
cmd_trb);
14361444
/*
@@ -1447,14 +1455,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
14471455

14481456
cancel_delayed_work(&xhci->cmd_timer);
14491457

1450-
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
1451-
1452-
/* If CMD ring stopped we own the trbs between enqueue and dequeue */
1453-
if (cmd_comp_code == COMP_COMMAND_RING_STOPPED) {
1454-
complete_all(&xhci->cmd_ring_stop_completion);
1455-
return;
1456-
}
1457-
14581458
if (cmd->command_trb != xhci->cmd_ring->dequeue) {
14591459
xhci_err(xhci,
14601460
"Command completion event does not match command\n");

0 commit comments

Comments
 (0)