PCI/VGA: Move firmware default device detection to ADD_DEVICE path
authorHuacai Chen <chenhuacai@loongson.cn>
Thu, 24 Feb 2022 22:47:47 +0000 (16:47 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 10 Mar 2022 00:31:08 +0000 (18:31 -0600)
commitf8d81df285a2fa2e739a9e4774e413ac778d282c
tree95ceecd550dce11aba828003c44ea07c7ce57733
parentdfe3da812d99b40f99ce018152db4b3a87bd86c4
PCI/VGA: Move firmware default device detection to ADD_DEVICE path

Previously we selected the firmware default device, i.e., one that owns the
boot framebuffer, as the default device in vga_arb_select_default_device().
This was only done in the vga_arb_device_init() subsys_initcall, so devices
enumerated later, e.g., by pcibios_init(), were not eligible.

Fix this by moving the firmware default device selection from
vga_arb_select_default_device() to vga_arbiter_add_pci_device(), which is
called after every PCI device is enumerated, either by the
vga_arb_device_init() subsys_initcall or as an ADD_DEVICE notifier.

Note that if vga_arb_select_default_device() previously found a device
owning the boot framebuffer, it unconditionally set it to be the default
VGA device, and no subsequent device could replace it.

[bhelgaas: commit log, restructure slightly]
Link: https://lore.kernel.org/r/20211015061512.2941859-7-chenhuacai@loongson.cn
Link: https://lore.kernel.org/r/20220224224753.297579-6-helgaas@kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Bruno Prémont <bonbons@linux-vserver.org>
drivers/pci/vgaarb.c