Skip to content

Commit da6a6dc

Browse files
Epicuriusgregkh
authored andcommitted
usb: xhci: adjust empty TD list handling in handle_tx_event()
Introduce an initial check for an empty list prior to entering the while loop. Which enables, the implementation of distinct warnings to differentiate between scenarios where the list is initially empty and when it has been emptied during processing skipped isoc TDs. These adjustments not only simplifies the large while loop, but also facilitates future enhancements to the handle_tx_event() function. 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 dbb2c92 commit da6a6dc

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,35 +2761,25 @@ static int handle_tx_event(struct xhci_hcd *xhci,
27612761
return 0;
27622762
}
27632763

2764-
do {
2765-
/* This TRB should be in the TD at the head of this ring's
2766-
* TD list.
2764+
if (list_empty(&ep_ring->td_list)) {
2765+
/*
2766+
* Don't print wanings if ring is empty due to a stopped endpoint generating an
2767+
* extra completion event if the device was suspended. Or, a event for the last TRB
2768+
* of a short TD we already got a short event for. The short TD is already removed
2769+
* from the TD list.
27672770
*/
2768-
if (list_empty(&ep_ring->td_list)) {
2769-
/*
2770-
* Don't print wanings if it's due to a stopped endpoint
2771-
* generating an extra completion event if the device
2772-
* was suspended. Or, a event for the last TRB of a
2773-
* short TD we already got a short event for.
2774-
* The short TD is already removed from the TD list.
2775-
*/
2776-
2777-
if (!(trb_comp_code == COMP_STOPPED ||
2778-
trb_comp_code == COMP_STOPPED_LENGTH_INVALID ||
2779-
ep_ring->last_td_was_short)) {
2780-
xhci_warn(xhci, "WARN Event TRB for slot %u ep %d with no TDs queued?\n",
2781-
slot_id, ep_index);
2782-
}
2783-
if (ep->skip) {
2784-
ep->skip = false;
2785-
xhci_dbg(xhci, "td_list is empty while skip flag set. Clear skip flag for slot %u ep %u.\n",
2786-
slot_id, ep_index);
2787-
}
2788-
2789-
td = NULL;
2790-
goto check_endpoint_halted;
2771+
if (trb_comp_code != COMP_STOPPED &&
2772+
trb_comp_code != COMP_STOPPED_LENGTH_INVALID &&
2773+
!ep_ring->last_td_was_short) {
2774+
xhci_warn(xhci, "Event TRB for slot %u ep %u with no TDs queued\n",
2775+
slot_id, ep_index);
27912776
}
27922777

2778+
ep->skip = false;
2779+
goto check_endpoint_halted;
2780+
}
2781+
2782+
do {
27932783
td = list_first_entry(&ep_ring->td_list, struct xhci_td,
27942784
td_list);
27952785

@@ -2800,7 +2790,14 @@ static int handle_tx_event(struct xhci_hcd *xhci,
28002790

28012791
if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
28022792
skip_isoc_td(xhci, td, ep, status);
2803-
continue;
2793+
if (!list_empty(&ep_ring->td_list))
2794+
continue;
2795+
2796+
xhci_dbg(xhci, "All TDs skipped for slot %u ep %u. Clear skip flag.\n",
2797+
slot_id, ep_index);
2798+
ep->skip = false;
2799+
td = NULL;
2800+
goto check_endpoint_halted;
28042801
}
28052802

28062803
/*

0 commit comments

Comments
 (0)