bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0601-xhci-correct-room_on_ring-for-cases-where-there-is-a.patch
1 From f759fff2c1bf5d1506a3994c6e2d92d6fbb3f000 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Fri, 3 Dec 2021 14:32:05 +0000
4 Subject: [PATCH] xhci: correct room_on_ring() for cases where there is
5 a single segment
6
7 Don't calculate space based on the number of TRBs in the current segment,
8 as it's OK to wrap to the start (and flip the cycle state bit).
9
10 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
11 ---
12 drivers/usb/host/xhci-ring.c | 6 ++++++
13 1 file changed, 6 insertions(+)
14
15 --- a/drivers/usb/host/xhci-ring.c
16 +++ b/drivers/usb/host/xhci-ring.c
17 @@ -289,6 +289,12 @@ static inline int room_on_ring(struct xh
18 return 0;
19
20 if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) {
21 + /*
22 + * If the ring has a single segment the dequeue segment
23 + * never changes, so don't use it as measure of free space.
24 + */
25 + if (ring->num_segs == 1)
26 + return ring->num_trbs_free >= num_trbs;
27 num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs;
28 if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg)
29 return 0;