在 2021/3/26 下午4:28, LeoLiu-oc 写道:
On some Zhaoxin platforms, xHCI will prefetch TRB for
performance
improvement. However this TRB prefetch mechanism may cross page boundary,
which may access memory not belong to xHCI. In order to fix this issue,
using two pages for TRB allocate and only the first page will be used.
The patch is scheduled to be submitted to the kernel mainline in 2021.
v1->v2:
- Use quirks instead of vendor id.
Signed-off-by: LeoLiu-oc <LeoLiu-oc(a)zhaoxin.com>
---
drivers/usb/host/xhci-mem.c | 9 +++++++--
drivers/usb/host/xhci-pci.c | 5 +++++
drivers/usb/host/xhci.h | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 82ce6d8b708d..b2fb044befb6 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2429,8 +2429,13 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t
flags)
* and our use of dma addresses in the trb_address_map radix tree
needs
* TRB_SEGMENT_SIZE alignment, so we pick the greater alignment
need.
*/
- xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
- TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size);
+ /*With xHCI TRB prefetch patch:To fix cross page boundry access
issue in IOV environment*/
A blank space is needed between asterisk and comments.
Artie
+ if (xhci->quirks & XHCI_ZHAOXIN_TRB_FETCH)
{
+ xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
+ TRB_SEGMENT_SIZE*2, TRB_SEGMENT_SIZE*2, xhci->page_size*2);
TRB_SEGMENT_SIZE * 2, please keep a blank space on both side of asterisk
as multiply
Artie
+ } else
+ xhci->segment_pool = dma_pool_create("xHCI ring segments", dev,
+ TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size);
/* See Table 46 and Note on Figure 55 */
xhci->device_pool = dma_pool_create("xHCI input/output contexts",
dev,
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 712bcb2eab76..c88402cb09ef 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -226,6 +226,11 @@ static void xhci_pci_quirks(struct device *dev,
struct xhci_hcd *xhci)
pdev->device == 0x3432)
xhci->quirks |= XHCI_BROKEN_STREAMS;
+ if (pdev->vendor == PCI_VENDOR_ID_ZHAOXIN &&
+ (pdev->device == 0x9202 ||
+ pdev->device == 0x9203))
+ xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH;
+
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
pdev->device == 0x1042)
xhci->quirks |= XHCI_BROKEN_STREAMS;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 76b872dcb0d9..f285e3cc6aa1 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1866,6 +1866,7 @@ struct xhci_hcd {
#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)
#define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35)
#define XHCI_ZHAOXIN_HOST BIT_ULL(36)
+#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(37)
unsigned int num_active_eps;
unsigned int limit_active_eps;