From ffd3f410ef4c6a3e68853471c874775922f48beb Mon Sep 17 00:00:00 2001 From: Hanjun Guo Date: Wed, 29 Sep 2021 16:02:07 +0800 Subject: [PATCH] usb: xhci: Add workaround for phytium hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4CGER CVE: NA --------------------------- Add workaround for phytium as the firmware didn't report the DMA size info. Signed-off-by: Hanjun Guo Signed-off-by: Yang Yingliang Reviewed-by: Xie XiuQi Signed-off-by: Yang Yingliang Signed-off-by: Zheng Zengkai --- drivers/usb/host/xhci-pci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 44dd77343cc1..3fe73d2f39e9 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -371,6 +371,18 @@ static int xhci_pci_setup(struct usb_hcd *hcd) return xhci_pci_reinit(xhci, pdev); } +#ifdef CONFIG_ARM64 +#include +static void phytium_xhci_pci_workaround(struct pci_dev *dev) +{ + /* Firmware bug, DMA mask is not reported by the firmware */ + if (read_cpuid_implementor() == ARM_CPU_IMP_PHYTIUM) + dma_set_mask(&dev->dev, DMA_BIT_MASK(64)); +} +#else +static inline void phytium_xhci_pci_workaround(struct pci_dev *dev) { } +#endif + /* * We need to register our own PCI probe function (instead of the USB core's * function) in order to create a second roothub under xHCI. @@ -395,6 +407,8 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) return PTR_ERR(reset); reset_control_reset(reset); + phytium_xhci_pci_workaround(dev); + /* Prevent runtime suspending between USB-2 and USB-3 initialization */ pm_runtime_get_noresume(&dev->dev); -- GitLab