From 9357c93cfa7dc7d8333cefb32eb3d47a1fc72a61 Mon Sep 17 00:00:00 2001 From: Xiongfeng Wang Date: Mon, 18 Nov 2019 09:48:55 +0800 Subject: [PATCH] PCI: Add quirk for hisilicon NP devices 5896 hulk inclusion category: bugfix bugzilla: 13666 CVE: NA --------------------------------------- Add pci quirk for hisilicon PCI Network Processor devices 5896. The size of the unused BAR3 is set as 265T wrongly. This patch disalbes this bar. Signed-off-by: Rui Ding Signed-off-by: Xiongfeng Wang Reviewed-by: Hanjun Guo Signed-off-by: Yang Yingliang --- drivers/pci/quirks.c | 23 +++++++++++++++++++++++ include/linux/pci_ids.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index cd51d5356079..83e3f2c5c7e6 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -5176,3 +5176,26 @@ static void quirk_reset_lenovo_thinkpad_p50_nvgpu(struct pci_dev *pdev) DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, 0x13b1, PCI_CLASS_DISPLAY_VGA, 8, quirk_reset_lenovo_thinkpad_p50_nvgpu); + +static void pci_quirk_hisi_fixup_class(struct pci_dev *dev) +{ + dev->class = PCI_BASE_CLASS_NETWORK << 8; + pci_info(dev, "force hisi class type to network\n"); +} +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_HUAWEI, PCIE_DEVICE_ID_HISI_5896, + pci_quirk_hisi_fixup_class); + +static void pci_quirk_hisi_fixup_bar(struct pci_dev *dev) +{ + int i, start = 3; + + for (i = start; i < PCI_NUM_RESOURCES; i++) { + dev->resource[i].start = 0; + dev->resource[i].end = 0; + dev->resource[i].flags = 0; + } + + pci_info(dev, "force disable hisilicon np bar\n"); +} +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HUAWEI, PCIE_DEVICE_ID_HISI_5896, + pci_quirk_hisi_fixup_bar); diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index a051ae7068f5..5dd03b5d68c8 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2539,6 +2539,8 @@ #define PCI_VENDOR_ID_HUAWEI 0x19e5 #define PCI_DEVICE_ID_ZIP_PF 0xa250 #define PCI_DEVICE_ID_ZIP_VF 0xa251 +/* Hisilicon PCIe NP devices */ +#define PCIE_DEVICE_ID_HISI_5896 0x5896 #define PCI_VENDOR_ID_NETRONOME 0x19ee #define PCI_DEVICE_ID_NETRONOME_NFP3200 0x3200 -- GitLab