Skip to content

Commit c43e43e

Browse files
Epicuriusgregkh
authored andcommitted
usb: xhci: move process TD code out of the while loop
This part is and should only performed once, so it's moved out of the while loop to improve code readability. Signed-off-by: Niklas Neronin <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 132dcf6 commit c43e43e

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,10 +2868,6 @@ static int handle_tx_event(struct xhci_hcd *xhci,
28682868
return -ESHUTDOWN;
28692869
}
28702870
}
2871-
if (trb_comp_code == COMP_SHORT_PACKET)
2872-
ep_ring->last_td_was_short = true;
2873-
else
2874-
ep_ring->last_td_was_short = false;
28752871

28762872
if (ep->skip) {
28772873
xhci_dbg(xhci,
@@ -2880,34 +2876,6 @@ static int handle_tx_event(struct xhci_hcd *xhci,
28802876
ep->skip = false;
28812877
}
28822878

2883-
ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) /
2884-
sizeof(*ep_trb)];
2885-
2886-
trace_xhci_handle_transfer(ep_ring,
2887-
(struct xhci_generic_trb *) ep_trb);
2888-
2889-
/*
2890-
* No-op TRB could trigger interrupts in a case where
2891-
* a URB was killed and a STALL_ERROR happens right
2892-
* after the endpoint ring stopped. Reset the halted
2893-
* endpoint. Otherwise, the endpoint remains stalled
2894-
* indefinitely.
2895-
*/
2896-
2897-
if (trb_is_noop(ep_trb)) {
2898-
if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code))
2899-
xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET);
2900-
} else {
2901-
td->status = status;
2902-
2903-
/* update the urb's actual_length and give back to the core */
2904-
if (usb_endpoint_xfer_control(&td->urb->ep->desc))
2905-
process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event);
2906-
else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc))
2907-
process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event);
2908-
else
2909-
process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event);
2910-
}
29112879
/*
29122880
* If ep->skip is set, it means there are missed tds on the
29132881
* endpoint ring need to take care of.
@@ -2916,6 +2884,36 @@ static int handle_tx_event(struct xhci_hcd *xhci,
29162884
*/
29172885
} while (ep->skip);
29182886

2887+
if (trb_comp_code == COMP_SHORT_PACKET)
2888+
ep_ring->last_td_was_short = true;
2889+
else
2890+
ep_ring->last_td_was_short = false;
2891+
2892+
ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / sizeof(*ep_trb)];
2893+
trace_xhci_handle_transfer(ep_ring, (struct xhci_generic_trb *) ep_trb);
2894+
2895+
/*
2896+
* No-op TRB could trigger interrupts in a case where a URB was killed
2897+
* and a STALL_ERROR happens right after the endpoint ring stopped.
2898+
* Reset the halted endpoint. Otherwise, the endpoint remains stalled
2899+
* indefinitely.
2900+
*/
2901+
2902+
if (trb_is_noop(ep_trb)) {
2903+
if (xhci_halted_host_endpoint(ep_ctx, trb_comp_code))
2904+
xhci_handle_halted_endpoint(xhci, ep, td, EP_HARD_RESET);
2905+
} else {
2906+
td->status = status;
2907+
2908+
/* update the urb's actual_length and give back to the core */
2909+
if (usb_endpoint_xfer_control(&td->urb->ep->desc))
2910+
process_ctrl_td(xhci, ep, ep_ring, td, ep_trb, event);
2911+
else if (usb_endpoint_xfer_isoc(&td->urb->ep->desc))
2912+
process_isoc_td(xhci, ep, ep_ring, td, ep_trb, event);
2913+
else
2914+
process_bulk_intr_td(xhci, ep, ep_ring, td, ep_trb, event);
2915+
}
2916+
29192917
return 0;
29202918

29212919
err_out:

0 commit comments

Comments
 (0)