PCI: Fix SD5896 NP init failure
euleros inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8URYL?from=project-issue CVE: NA
-------------------------------------
SD5896 NP init failed, when some unused BAR is enabled. The unused BAR should be disabled to fix this problem.
Signed-off-by: geruijun geruijun@huawei.com Signed-off-by: Yeqing Peng pengyeqing@huawei.com Signed-off-by: Jiangtian Feng fengjiangtian@huawei.com
Signed-off-by: Jiangtian Feng fengjiangtian@huawei.com --- drivers/pci/quirks.c | 25 +++++++++++++++++++++++++ include/linux/pci_ids.h | 3 +++ 2 files changed, 28 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 9d521e16de44..e19055d879e5 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -5833,6 +5833,31 @@ static void quirk_switchtec_ntb_dma_alias(struct pci_dev *pdev) pci_iounmap(pdev, mmio); pci_disable_device(pdev); } + +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); + + #define SWITCHTEC_QUIRK(vid) \ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_MICROSEMI, vid, \ PCI_CLASS_BRIDGE_OTHER, 8, quirk_switchtec_ntb_dma_alias) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index fe4a3589bb3f..866f0cb674f9 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2564,6 +2564,9 @@ #define PCI_DEVICE_ID_HUAWEI_SEC_VF 0xa256 #define PCI_DEVICE_ID_HUAWEI_HPRE_VF 0xa259
+/* Hisilicon PCIe NP devices */ +#define PCIE_DEVICE_ID_HISI_5896 0x5896 + #define PCI_VENDOR_ID_NETRONOME 0x19ee #define PCI_DEVICE_ID_NETRONOME_NFP3800 0x3800 #define PCI_DEVICE_ID_NETRONOME_NFP4000 0x4000