kernel: bump 5.15 to 5.15.124
[openwrt/staging/hauke.git] / target / linux / bcm27xx / patches-5.15 / 950-0600-xhci-quirks-add-link-TRB-quirk-for-VL805.patch
1 From 4dccc6e881f1e8d93c895a4b89e266d79e2746df Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.org>
3 Date: Mon, 26 Oct 2020 14:03:35 +0000
4 Subject: [PATCH] xhci: quirks: add link TRB quirk for VL805
5
6 The VL805 controller can't cope with the TR Dequeue Pointer for an endpoint
7 being set to a Link TRB. The hardware-maintained endpoint context ends up
8 stuck at the address of the Link TRB, leading to erroneous ring expansion
9 events whenever the enqueue pointer wraps to the dequeue position.
10
11 If the search for the end of the current TD and ring cycle state lands on
12 a Link TRB, move to the next segment.
13
14 See: https://github.com/raspberrypi/linux/issues/3919
15
16 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
17 ---
18 drivers/usb/host/xhci-pci.c | 1 +
19 drivers/usb/host/xhci-ring.c | 9 +++++++++
20 drivers/usb/host/xhci.h | 1 +
21 3 files changed, 11 insertions(+)
22
23 --- a/drivers/usb/host/xhci-pci.c
24 +++ b/drivers/usb/host/xhci-pci.c
25 @@ -294,8 +294,10 @@ static void xhci_pci_quirks(struct devic
26 pdev->device == 0x3432)
27 xhci->quirks |= XHCI_BROKEN_STREAMS;
28
29 - if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)
30 + if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483) {
31 xhci->quirks |= XHCI_LPM_SUPPORT;
32 + xhci->quirks |= XHCI_AVOID_DQ_ON_LINK;
33 + }
34
35 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
36 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI) {
37 --- a/drivers/usb/host/xhci-ring.c
38 +++ b/drivers/usb/host/xhci-ring.c
39 @@ -664,6 +664,15 @@ static int xhci_move_dequeue_past_td(str
40 } while (!cycle_found || !td_last_trb_found);
41
42 deq_found:
43 + /*
44 + * Quirk: the xHC does not correctly parse link TRBs if the HW Dequeue
45 + * pointer is set to one. Advance to the next TRB (and next segment).
46 + */
47 + if (xhci->quirks & XHCI_AVOID_DQ_ON_LINK && trb_is_link(new_deq)) {
48 + if (link_trb_toggles_cycle(new_deq))
49 + new_cycle ^= 0x1;
50 + next_trb(xhci, ep_ring, &new_seg, &new_deq);
51 + }
52
53 /* Don't update the ring cycle state for the producer (us). */
54 addr = xhci_trb_virt_to_dma(new_seg, new_deq);
55 --- a/drivers/usb/host/xhci.h
56 +++ b/drivers/usb/host/xhci.h
57 @@ -1908,6 +1908,7 @@ struct xhci_hcd {
58 #define XHCI_RESET_TO_DEFAULT BIT_ULL(44)
59 #define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45)
60 #define XHCI_ZHAOXIN_HOST BIT_ULL(46)
61 +#define XHCI_AVOID_DQ_ON_LINK BIT_ULL(47)
62
63 unsigned int num_active_eps;
64 unsigned int limit_active_eps;