6c2840d6338438c4619bae3f4539f4a0bc5bd07b
[openwrt/openwrt.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 @@ -304,6 +304,7 @@ static void xhci_pci_quirks(struct devic
26 if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483) {
27 xhci->quirks |= XHCI_LPM_SUPPORT;
28 xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS;
29 + xhci->quirks |= XHCI_AVOID_DQ_ON_LINK;
30 }
31
32 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
33 --- a/drivers/usb/host/xhci-ring.c
34 +++ b/drivers/usb/host/xhci-ring.c
35 @@ -667,6 +667,15 @@ static int xhci_move_dequeue_past_td(str
36 } while (!cycle_found || !td_last_trb_found);
37
38 deq_found:
39 + /*
40 + * Quirk: the xHC does not correctly parse link TRBs if the HW Dequeue
41 + * pointer is set to one. Advance to the next TRB (and next segment).
42 + */
43 + if (xhci->quirks & XHCI_AVOID_DQ_ON_LINK && trb_is_link(new_deq)) {
44 + if (link_trb_toggles_cycle(new_deq))
45 + new_cycle ^= 0x1;
46 + next_trb(xhci, ep_ring, &new_seg, &new_deq);
47 + }
48
49 /* Don't update the ring cycle state for the producer (us). */
50 addr = xhci_trb_virt_to_dma(new_seg, new_deq);
51 --- a/drivers/usb/host/xhci.h
52 +++ b/drivers/usb/host/xhci.h
53 @@ -1904,6 +1904,7 @@ struct xhci_hcd {
54 #define XHCI_BROKEN_D3COLD BIT_ULL(41)
55 #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)
56 #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)
57 +#define XHCI_AVOID_DQ_ON_LINK BIT_ULL(44)
58
59 unsigned int num_active_eps;
60 unsigned int limit_active_eps;