usb: xhci: ensure skipped isoc TDs are returned when isoc ring is stopped
authorNiklas Neronin <niklas.neronin@linux.intel.com>
Wed, 26 Jun 2024 12:48:29 +0000 (15:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jun 2024 14:08:06 +0000 (16:08 +0200)
Missed service event tells the driver that the hardware wasn't able to
process some queued isoc TDs in their right time slots, and some TDs will
be skipped. The driver sets a 'skip' flag to indicate that the next
transfer event after this event will point to some future TD instead of
the next queued TD. Once the driver receives the next event, it will skip
and give back all those hardware skipped TDs.

However, should this subsequent event be a stop endpoint which does not
point to the next pending TD, the driver fails to return the skipped TDs.
Instead, it loops for a period before outputting an erroneous message.

Fix this by repositioning the 'stop endpoint' check to follow the isoc
skip check, ensuring the skipped TDs are properly returned.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20240626124835.1023046-16-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-ring.c

index 3479c9cb5d332d0aa1eea1ce4d47eb755d0be698..14898335d193b18f1a7d4460d4d50c3a39fd46c6 100644 (file)
@@ -2819,19 +2819,6 @@ static int handle_tx_event(struct xhci_hcd *xhci,
                /* Is this a TRB in the currently executing TD? */
                ep_seg = trb_in_td(xhci, td, ep_trb_dma, false);
 
-               /*
-                * Skip the Force Stopped Event. The event_trb(event_dma) of FSE
-                * is not in the current TD pointed by ep_ring->dequeue because
-                * that the hardware dequeue pointer still at the previous TRB
-                * of the current TD. The previous TRB maybe a Link TD or the
-                * last TRB of the previous TD. The command completion handle
-                * will take care the rest.
-                */
-               if (!ep_seg && (trb_comp_code == COMP_STOPPED ||
-                          trb_comp_code == COMP_STOPPED_LENGTH_INVALID)) {
-                       continue;
-               }
-
                if (!ep_seg) {
 
                        if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
@@ -2839,6 +2826,18 @@ static int handle_tx_event(struct xhci_hcd *xhci,
                                continue;
                        }
 
+                       /*
+                        * Skip the Force Stopped Event. The 'ep_trb' of FSE is not in the current
+                        * TD pointed by 'ep_ring->dequeue' because that the hardware dequeue
+                        * pointer still at the previous TRB of the current TD. The previous TRB
+                        * maybe a Link TD or the last TRB of the previous TD. The command
+                        * completion handle will take care the rest.
+                        */
+                       if (trb_comp_code == COMP_STOPPED ||
+                           trb_comp_code == COMP_STOPPED_LENGTH_INVALID) {
+                               return 0;
+                       }
+
                        /*
                         * Some hosts give a spurious success event after a short
                         * transfer. Ignore it.