linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: Add quirk for HiSilicon NP 5896 devices
@ 2019-12-06  7:01 Xiongfeng Wang
  2019-12-06 18:10 ` Bjorn Helgaas
  2019-12-18  8:41 ` Xiongfeng Wang
  0 siblings, 2 replies; 10+ messages in thread
From: Xiongfeng Wang @ 2019-12-06  7:01 UTC (permalink / raw)
  To: andrew.murray, bhelgaas
  Cc: wangxiongfeng2, linux-pci, linux-kernel, wangkefeng.wang,
	huawei.libin, guohanjun

HiSilicon PCI Network Processor 5896 devices misreport the class type as
'NOT_DEFINED', but it is actually a network device. Also the size of
BAR3 is reported as 265T, but this BAR is actually unused.
This patch modify the class type to 'CLASS_NETWORK' and disable the
unused BAR3.

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/pci/quirks.c    | 29 +++++++++++++++++++++++++++++
 include/linux/pci_ids.h |  1 +
 2 files changed, 30 insertions(+)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 4937a08..b9adebb 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -5431,3 +5431,32 @@ 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 quirk_hisi_fixup_np_class(struct pci_dev *pdev)
+{
+	u32 class = pdev->class;
+
+	pdev->class = PCI_BASE_CLASS_NETWORK << 8;
+	pci_info(pdev, "PCI class overriden (%#08x -> %#08x)\n",
+		 class, pdev->class);
+}
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HISI_5896,
+			quirk_hisi_fixup_np_class);
+
+/*
+ * HiSilicon NP 5896 devices BAR3 size is reported as 256T and causes problem
+ * when assigning the resources. But this BAR is actually unused by the driver,
+ * so let's disable it.
+ */
+static void quirk_hisi_fixup_np_bar(struct pci_dev *pdev)
+{
+	struct resource *r = &pdev->resource[3];
+
+	r->start = 0;
+	r->end = 0;
+	r->flags = 0;
+
+	pci_info(pdev, "Disabling invalid BAR 3\n");
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HISI_5896,
+			 quirk_hisi_fixup_np_bar);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 2302d133..f21cd8b 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2558,6 +2558,7 @@
 #define PCI_DEVICE_ID_KORENIX_JETCARDF3	0x17ff
 
 #define PCI_VENDOR_ID_HUAWEI		0x19e5
+#define PCI_DEVICE_ID_HISI_5896        0x5896 /* HiSilicon NP 5896 devices */
 
 #define PCI_VENDOR_ID_NETRONOME		0x19ee
 #define PCI_DEVICE_ID_NETRONOME_NFP4000	0x4000
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-12-30 14:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-06  7:01 [PATCH v2] PCI: Add quirk for HiSilicon NP 5896 devices Xiongfeng Wang
2019-12-06 18:10 ` Bjorn Helgaas
2019-12-11  3:27   ` Xiongfeng Wang
2019-12-11  4:10     ` Bjorn Helgaas
2019-12-18  9:16       ` Xiongfeng Wang
2019-12-18 14:28         ` Bjorn Helgaas
2019-12-19  8:51           ` Xiongfeng Wang
2019-12-30  8:11           ` Xiongfeng Wang
2019-12-30 14:19             ` Bjorn Helgaas
2019-12-18  8:41 ` Xiongfeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).