Skip to content

Commit 075919f

Browse files
Faisal Hassangregkh
authored andcommitted
xhci: Fix Link TRB DMA in command ring stopped completion event
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 3100474 commit 075919f

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
@@ -1718,6 +1718,14 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
17181718

17191719
trace_xhci_handle_command(xhci->cmd_ring, &cmd_trb->generic);
17201720

1721+
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
1722+
1723+
/* If CMD ring stopped we own the trbs between enqueue and dequeue */
1724+
if (cmd_comp_code == COMP_COMMAND_RING_STOPPED) {
1725+
complete_all(&xhci->cmd_ring_stop_completion);
1726+
return;
1727+
}
1728+
17211729
cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
17221730
cmd_trb);
17231731
/*
@@ -1734,14 +1742,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
17341742

17351743
cancel_delayed_work(&xhci->cmd_timer);
17361744

1737-
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
1738-
1739-
/* If CMD ring stopped we own the trbs between enqueue and dequeue */
1740-
if (cmd_comp_code == COMP_COMMAND_RING_STOPPED) {
1741-
complete_all(&xhci->cmd_ring_stop_completion);
1742-
return;
1743-
}
1744-
17451745
if (cmd->command_trb != xhci->cmd_ring->dequeue) {
17461746
xhci_err(xhci,
17471747
"Command completion event does not match command\n");

0 commit comments

Comments
 (0)