From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
To: <bhelgaas@google.com>
Cc: <wangxiongfeng2@huawei.com>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <wangkefeng.wang@huawei.com>,
<huawei.libin@huawei.com>, <guohanjun@huawei.com>
Subject: [PATCH] PCI: Add quirk to disable unused BAR for hisilicon NP devices 5896
Date: Thu, 5 Dec 2019 19:40:41 +0800 [thread overview]
Message-ID: <1575546041-50907-1-git-send-email-wangxiongfeng2@huawei.com> (raw)
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: 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..7dfb272 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 devices 5896 BAR3 size is misreported as 256T. Actually, this
+ * BAR is unused, so let's disable it.
+ */
+#define HISI_5896_WRONG_BAR 3
+static void quirk_hisi_fixup_np_bar(struct pci_dev *pdev)
+{
+ struct resource *r = &pdev->resource[HISI_5896_WRONG_BAR];
+
+ r->start = 0;
+ r->end = 0;
+ r->flags = 0;
+
+ pci_info(pdev, "disable BAR %d\n", HISI_5896_WRONG_BAR);
+}
+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..56e2b91 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 devices 5896 */
#define PCI_VENDOR_ID_NETRONOME 0x19ee
#define PCI_DEVICE_ID_NETRONOME_NFP4000 0x4000
--
1.7.12.4
next reply other threads:[~2019-12-05 11:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 11:40 Xiongfeng Wang [this message]
2019-12-05 12:15 ` Andrew Murray
2019-12-05 12:24 ` Xiongfeng Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1575546041-50907-1-git-send-email-wangxiongfeng2@huawei.com \
--to=wangxiongfeng2@huawei.com \
--cc=bhelgaas@google.com \
--cc=guohanjun@huawei.com \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=wangkefeng.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®