#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"
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2031, quirk_no_aersid);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2032, quirk_no_aersid);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2033, quirk_no_aersid);
+
+/*
+ * The hibmc card on a HiSilicon D05 board sits behind a non-compliant
+ * bridge. The bridge has the PCI_BRIDGE_CTL_VGA config bit fixed at 0
+ * in hardware. 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);