mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
usb: xhci-pci: Limit VIA VL805 DMA addressing to 36 bits
commit 1fc50f1ecd upstream.
The VIA VL805/806 xHCI controller advertises AC64, but fails to handle
DMA addresses at or above 0x1000000000. On systems with large amounts of
RAM, this can cause USB device failures when the controller is given DMA
addresses beyond its usable address width.
Do not use XHCI_NO_64BIT_SUPPORT for this controller. That quirk clears
the cached AC64 capability and limits DMA to 32 bits, causing unnecessary
bouncing for addresses between 4GiB and 64GiB and hiding the controller's
real AC64 capability from code that may need to distinguish register
access width from usable DMA address width.
Track the usable DMA address width separately from the AC64 capability.
Initialize the generic xhci->dma_mask_bits field to 64 and let PCI quirks
reduce it for controllers with narrower DMA support. Set VIA VL805/806 to
36 bits so the DMA API only hands it addresses in the range it can handle
while keeping HCCPARAMS1.AC64 visible.
Cc: stable@kernel.org
Signed-off-by: Xincheng Zhang <zhangxincheng@ultrarisc.com>
Link: https://patch.msgid.link/20260630-xhci-via-dma-fix-v3-1-690dcb8cf75a@ultrarisc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f2ac9e3236
commit
6192a3f77c
@@ -510,6 +510,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
|
||||
if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == PCI_DEVICE_ID_VIA_VL805) {
|
||||
xhci->quirks |= XHCI_LPM_SUPPORT;
|
||||
xhci->quirks |= XHCI_TRB_OVERFETCH;
|
||||
xhci->dma_mask_bits = 36;
|
||||
}
|
||||
|
||||
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
|
||||
|
||||
+10
-5
@@ -5267,6 +5267,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
|
||||
if (xhci->hci_version > 0x100)
|
||||
xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2);
|
||||
|
||||
xhci->dma_mask_bits = 64;
|
||||
/* xhci-plat or xhci-pci might have set max_interrupters already */
|
||||
if ((!xhci->max_interrupters) ||
|
||||
xhci->max_interrupters > HCS_MAX_INTRS(xhci->hcs_params1))
|
||||
@@ -5308,12 +5309,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
|
||||
if (xhci->quirks & XHCI_NO_64BIT_SUPPORT)
|
||||
xhci->hcc_params &= ~BIT(0);
|
||||
|
||||
/* Set dma_mask and coherent_dma_mask to 64-bits,
|
||||
* if xHC supports 64-bit addressing */
|
||||
/*
|
||||
* Set dma_mask and coherent_dma_mask to 64-bits if xHC supports
|
||||
* 64-bit addressing, unless a controller-specific quirk callback
|
||||
* limits the usable address width.
|
||||
*/
|
||||
if (HCC_64BIT_ADDR(xhci->hcc_params) &&
|
||||
!dma_set_mask(dev, DMA_BIT_MASK(64))) {
|
||||
xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
|
||||
dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
|
||||
!dma_set_mask(dev, DMA_BIT_MASK(xhci->dma_mask_bits))) {
|
||||
xhci_dbg(xhci, "Enabling %u-bit DMA addresses.\n",
|
||||
xhci->dma_mask_bits);
|
||||
dma_set_coherent_mask(dev, DMA_BIT_MASK(xhci->dma_mask_bits));
|
||||
} else {
|
||||
/*
|
||||
* This is to avoid error in cases where a 32-bit USB
|
||||
|
||||
@@ -1538,6 +1538,7 @@ struct xhci_hcd {
|
||||
int event_ring_max;
|
||||
/* 4KB min, 128MB max */
|
||||
int page_size;
|
||||
unsigned int dma_mask_bits;
|
||||
/* Valid values are 12 to 20, inclusive */
|
||||
int page_shift;
|
||||
/* msi-x vectors */
|
||||
|
||||
Reference in New Issue
Block a user