xhci: expand next_trb() helper to support more ring types
authorMathias Nyman <mathias.nyman@linux.intel.com>
Thu, 19 Oct 2023 10:29:08 +0000 (13:29 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Oct 2023 10:38:53 +0000 (12:38 +0200)
The next_trb() helper relies on a link TRB at the end of a ring segment
to know a segment ends. This works well with transfer rings that use
link trbs, but not with event rings.

Event rings segments are always filled by host to segment size
before moving to next segment. It does not use link TRBs

Check for both link trb and full segment in next_trb() helper to
support event rings.

Useful if several interrupters with several event rings are supported.

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

index 48daeb4b4a46e249e574a9d473b8ac6d46e843a9..17e37c2a14aa0cecebabf257a7d2d18e36f014b4 100644 (file)
@@ -144,7 +144,7 @@ static void next_trb(struct xhci_hcd *xhci,
                struct xhci_segment **seg,
                union xhci_trb **trb)
 {
-       if (trb_is_link(*trb)) {
+       if (trb_is_link(*trb) || last_trb_on_seg(*seg, *trb)) {
                *seg = (*seg)->next;
                *trb = ((*seg)->trbs);
        } else {