]> git.ipfire.org Git - thirdparty/openwrt.git/blob
5b146761f33d2e1b2cf4fd6c2bd9cae181cc9fc5
[thirdparty/openwrt.git] /
1 From a956051a926b0a9e0bc587303ce1a2e153707e80 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Mon, 31 Jul 2023 13:47:10 +0100
4 Subject: [PATCH 0061/1085] Revert "Revert "xhci: add quirk for host
5 controllers that don't update endpoint DCS""
6
7 This reverts commit 5bef4b3cb95a5b883dfec8b3ffc0d671323d55bb.
8
9 We don't agree with upstream revert so undo it.
10 ---
11 drivers/usb/host/xhci-pci.c | 4 +++-
12 drivers/usb/host/xhci-ring.c | 25 ++++++++++++++++++++++++-
13 2 files changed, 27 insertions(+), 2 deletions(-)
14
15 --- a/drivers/usb/host/xhci-pci.c
16 +++ b/drivers/usb/host/xhci-pci.c
17 @@ -476,6 +476,7 @@ static void xhci_pci_quirks(struct devic
18 if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == PCI_DEVICE_ID_VIA_VL805) {
19 xhci->quirks |= XHCI_LPM_SUPPORT;
20 xhci->quirks |= XHCI_TRB_OVERFETCH;
21 + xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS;
22 }
23
24 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
25 --- a/drivers/usb/host/xhci-ring.c
26 +++ b/drivers/usb/host/xhci-ring.c
27 @@ -635,8 +635,11 @@ static int xhci_move_dequeue_past_td(str
28 struct xhci_ring *ep_ring;
29 struct xhci_command *cmd;
30 struct xhci_segment *new_seg;
31 + struct xhci_segment *halted_seg = NULL;
32 union xhci_trb *new_deq;
33 int new_cycle;
34 + union xhci_trb *halted_trb;
35 + int index = 0;
36 dma_addr_t addr;
37 u64 hw_dequeue;
38 bool cycle_found = false;
39 @@ -674,7 +677,27 @@ static int xhci_move_dequeue_past_td(str
40 hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id);
41 new_seg = ep_ring->deq_seg;
42 new_deq = ep_ring->dequeue;
43 - new_cycle = hw_dequeue & 0x1;
44 +
45 + /*
46 + * Quirk: xHC write-back of the DCS field in the hardware dequeue
47 + * pointer is wrong - use the cycle state of the TRB pointed to by
48 + * the dequeue pointer.
49 + */
50 + if (xhci->quirks & XHCI_EP_CTX_BROKEN_DCS &&
51 + !(ep->ep_state & EP_HAS_STREAMS))
52 + halted_seg = trb_in_td(xhci, td->start_seg,
53 + td->first_trb, td->last_trb,
54 + hw_dequeue & ~0xf, false);
55 + if (halted_seg) {
56 + index = ((dma_addr_t)(hw_dequeue & ~0xf) - halted_seg->dma) /
57 + sizeof(*halted_trb);
58 + halted_trb = &halted_seg->trbs[index];
59 + new_cycle = halted_trb->generic.field[3] & 0x1;
60 + xhci_dbg(xhci, "Endpoint DCS = %d TRB index = %d cycle = %d\n",
61 + (u8)(hw_dequeue & 0x1), index, new_cycle);
62 + } else {
63 + new_cycle = hw_dequeue & 0x1;
64 + }
65
66 /*
67 * We want to find the pointer, segment and cycle state of the new trb