Skip to content

Commit 4a12b6c

Browse files
Michal Peciogregkh
authored andcommitted
usb: xhci: Enable the TRB overfetch quirk on VIA VL805
commit c133ec0e5717868c9967fa3df92a55e537b1aead upstream. Raspberry Pi is a major user of those chips and they discovered a bug - when the end of a transfer ring segment is reached, up to four TRBs can be prefetched from the next page even if the segment ends with link TRB and on page boundary (the chip claims to support standard 4KB pages). It also appears that if the prefetched TRBs belong to a different ring whose doorbell is later rung, they may be used without refreshing from system RAM and the endpoint will stay idle if their cycle bit is stale. Other users complain about IOMMU faults on x86 systems, unsurprisingly. Deal with it by using existing quirk which allocates a dummy page after each transfer ring segment. This was seen to resolve both problems. RPi came up with a more efficient solution, shortening each segment by four TRBs, but it complicated the driver and they ditched it for this quirk. Also rename the quirk and add VL805 device ID macro. Signed-off-by: Michal Pecio <[email protected]> Link: raspberrypi/linux#4685 Closes: https://bugzilla.kernel.org/show_bug.cgi?id=215906 CC: [email protected] Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9692a67 commit 4a12b6c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
23882388
* and our use of dma addresses in the trb_address_map radix tree needs
23892389
* TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need.
23902390
*/
2391-
if (xhci->quirks & XHCI_ZHAOXIN_TRB_FETCH)
2391+
if (xhci->quirks & XHCI_TRB_OVERFETCH)
2392+
/* Buggy HC prefetches beyond segment bounds - allocate dummy space at the end */
23922393
xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
23932394
TRB_SEGMENT_SIZE * 2, TRB_SEGMENT_SIZE * 2, xhci->page_size * 2);
23942395
else

drivers/usb/host/xhci-pci.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define PCI_DEVICE_ID_EJ168 0x7023
3939
#define PCI_DEVICE_ID_EJ188 0x7052
4040

41+
#define PCI_DEVICE_ID_VIA_VL805 0x3483
42+
4143
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31
4244
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
4345
#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
@@ -304,8 +306,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
304306
pdev->device == 0x3432)
305307
xhci->quirks |= XHCI_BROKEN_STREAMS;
306308

307-
if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)
309+
if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == PCI_DEVICE_ID_VIA_VL805) {
308310
xhci->quirks |= XHCI_LPM_SUPPORT;
311+
xhci->quirks |= XHCI_TRB_OVERFETCH;
312+
}
309313

310314
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
311315
pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI) {
@@ -353,11 +357,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
353357

354358
if (pdev->device == 0x9202) {
355359
xhci->quirks |= XHCI_RESET_ON_RESUME;
356-
xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH;
360+
xhci->quirks |= XHCI_TRB_OVERFETCH;
357361
}
358362

359363
if (pdev->device == 0x9203)
360-
xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH;
364+
xhci->quirks |= XHCI_TRB_OVERFETCH;
361365
}
362366

363367
if (pdev->vendor == PCI_DEVICE_ID_CADENCE &&

drivers/usb/host/xhci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ struct xhci_hcd {
16591659
#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)
16601660
#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)
16611661
#define XHCI_RESET_TO_DEFAULT BIT_ULL(44)
1662-
#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45)
1662+
#define XHCI_TRB_OVERFETCH BIT_ULL(45)
16631663
#define XHCI_ZHAOXIN_HOST BIT_ULL(46)
16641664
#define XHCI_WRITE_64_HI_LO BIT_ULL(47)
16651665
#define XHCI_CDNS_SCTX_QUIRK BIT_ULL(48)

0 commit comments

Comments
 (0)