ImmortalWrt/target/linux/bcm27xx/patches-5.15/950-0601-xhci-correct-room_on_ring-for-cases-where-there-is-a.patch
Álvaro Fernández Rojas 20ea6adbf1 bcm27xx: add support for linux v5.15
Build system: x86_64
Build-tested: bcm2708, bcm2709, bcm2710, bcm2711
Run-tested: bcm2708/RPiB+, bcm2709/RPi3B, bcm2710/RPi3B, bcm2711/RPi4B

Signed-off-by: Marty Jones <mj8263788@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2022-05-17 15:11:22 +02:00

30 lines
1.0 KiB
Diff

From f759fff2c1bf5d1506a3994c6e2d92d6fbb3f000 Mon Sep 17 00:00:00 2001
From: Jonathan Bell <jonathan@raspberrypi.com>
Date: Fri, 3 Dec 2021 14:32:05 +0000
Subject: [PATCH] xhci: correct room_on_ring() for cases where there is
a single segment
Don't calculate space based on the number of TRBs in the current segment,
as it's OK to wrap to the start (and flip the cycle state bit).
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
---
drivers/usb/host/xhci-ring.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -289,6 +289,12 @@ static inline int room_on_ring(struct xh
return 0;
if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) {
+ /*
+ * If the ring has a single segment the dequeue segment
+ * never changes, so don't use it as measure of free space.
+ */
+ if (ring->num_segs == 1)
+ return ring->num_trbs_free >= num_trbs;
num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs;
if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg)
return 0;