@@ -17,6 +17,13 @@ config VGA_ARB_MAX_GPUS
Reserves space in the kernel to maintain resource locking for
multiple GPUS. The overhead for each GPU is very small.
+config ARCH_WANT_VGA_ARB_FALLBACK
+ bool
+ help
+ Some architectures don't have a concept of "legacy" PCI addresses
+ which the VGA arbiter relies on. Instead, they can fall back to
+ selecting the first device that decodes memory and I/O.
+
config VGA_SWITCHEROO
bool "Laptop Hybrid Graphics - GPU switching support"
depends on X86
@@ -1472,3 +1472,24 @@ static int __init vga_arb_device_init(void)
return rc;
}
subsys_initcall(vga_arb_device_init);
+
+#if defined(CONFIG_ARCH_WANT_VGA_ARB_FALLBACK)
+static void vga_arb_fallback_fixup(struct pci_dev *pdev)
+{
+ u16 cmd;
+
+ if (vga_default_device())
+ return;
+
+ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+ if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
+ vgaarb_info(&pdev->dev, "[fallback]"
+ " setting as default device\n");
+ vga_set_default_device(pdev);
+ }
+
+}
+DECLARE_PCI_FIXUP_CLASS_ENABLE(PCI_ANY_ID, PCI_ANY_ID,
+ PCI_CLASS_DISPLAY_VGA, 8,
+ vga_arb_fallback_fixup);
+#endif
The VGA arbiter currently only selects a card as default if it can decode legacy I/O and memory ranges. However, on some architectures, legacy PCI resources are not used. This has lead to a powerpc quirk, and issues on arm64. Allow architectures to select ARCH_WANT_VGA_ARB_FALLBACK. When that symbol is selected, add a PCI_FIXUP_CLASS_ENABLE hook, which will mark the first card that is enabled and that can control I/O and memory as the default card. Behaviour is unchanged unless arches opt-in by selecting the Kconfig option. Signed-off-by: Daniel Axtens <dja@axtens.net> --- drivers/gpu/vga/Kconfig | 7 +++++++ drivers/gpu/vga/vgaarb.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)