From: Daniel Axtens <dja@axtens.net>
To: linux-pci@vger.kernel.org
Cc: Daniel Axtens <dja@axtens.net>,
Xinliang Liu <z.liuxinliang@hisilicon.com>,
Rongrong Zou <zourongrong@gmail.com>
Subject: [PATCH] PCI: Support hibmc VGA cards behind a misbehaving HiSilicon bridge
Date: Mon, 19 Jun 2017 12:35:28 +1000 [thread overview]
Message-ID: <20170619023528.11532-1-dja@axtens.net> (raw)
The HiSilicon D05 board has some PCI bridges (PCI ID 19e5:1610) that
are not spec-compliant: they do not set the VGA Enable bit when a VGA
card is behind the bridge. This breaks Xorg auto-detection.
Despite this, the hibmc VGA card (PCI ID 19e5:1711) is known to work
when behind these bridges.
Provide a quirk so that this combination of bridge and card is eligible
to be the default VGA card.
This fixes Xorg auto-detection.
Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
Cc: Rongrong Zou <zourongrong@gmail.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
drivers/pci/quirks.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 16e6cd86ad71..9475d6056dd3 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -25,6 +25,7 @@
#include <linux/sched.h>
#include <linux/ktime.h>
#include <linux/mm.h>
+#include <linux/vgaarb.h>
#include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h"
@@ -4664,3 +4665,48 @@ static void quirk_intel_no_flr(struct pci_dev *dev)
}
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_intel_no_flr);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_intel_no_flr);
+
+/*
+ * The hibmc card on a HiSilicon D05 board sits behind a non-compliant
+ * bridge. The bridge doesn't advertise the PCI_BRIDGE_CTL_VGA bit in
+ * its config space. This prevents the vgaarb from marking a card
+ * behind it as boot VGA device.
+ *
+ * However, the hibmc card is known to still work, so if we have that
+ * card behind that particular bridge (19e5:1610), mark it as the
+ * default device if none has been detected.
+ */
+static void hibmc_fixup_vgaarb(struct pci_dev *pdev)
+{
+ struct pci_dev *bridge;
+ struct pci_bus *bus;
+ u16 config;
+
+ bus = pdev->bus;
+ bridge = bus->self;
+ if (!bridge)
+ return;
+
+ if (!pci_is_bridge(bridge))
+ return;
+
+ if (bridge->vendor != PCI_VENDOR_ID_HUAWEI ||
+ bridge->device != 0x1610)
+ return;
+
+ pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
+ &config);
+ if (config & PCI_BRIDGE_CTL_VGA) {
+ /*
+ * Weirdly, this bridge *is* spec compliant, so bail
+ * and let vgaarb do its job
+ */
+ return;
+ }
+
+ if (vga_default_device())
+ return;
+
+ vga_set_default_device(pdev);
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1711, hibmc_fixup_vgaarb);
--
2.11.0
next reply other threads:[~2017-06-19 2:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 2:35 Daniel Axtens [this message]
2017-06-19 23:55 ` [PATCH] PCI: Support hibmc VGA cards behind a misbehaving HiSilicon bridge Bjorn Helgaas
2017-06-20 0:28 ` Daniel Axtens
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=20170619023528.11532-1-dja@axtens.net \
--to=dja@axtens.net \
--cc=linux-pci@vger.kernel.org \
--cc=z.liuxinliang@hisilicon.com \
--cc=zourongrong@gmail.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;
as well as URLs for NNTP newsgroup(s).