Re: [PATCH v2] x86/video: Only fall back to vga_default_device() without screen info

From: Aaron Ma

Date: Wed Jun 24 2026 - 04:46:08 EST


Hi Mario,

Tested your v2 patch + Xorg MR !2242 on the hybrid system
(AMD 0x0380 + NVIDIA 0x030000, EFI framebuffer on AMD).

Result:

AMD: boot_display=1, boot_vga absent
NVIDIA: boot_display absent, boot_vga=1

Xorg now picks AMD correctly. boot_display is fixed.

Tested-by: Aaron Ma <aaron.ma@xxxxxxxxxxxxx>

Aaron

On Tue, Jun 23, 2026 at 10:15 PM Mario Limonciello
<mario.limonciello@xxxxxxx> wrote:
>
> Some multi GPU systems may have a VGA compatible device, but that might
> not be used for display. If due to enumeration order this device is
> found before the one actually used for display then multiple devices
> may show the boot_display attribute, confusing userspace.
>
> When screen info is valid, use it exclusively to find the primary
> device so that only the device backing the framebuffer is reported.
> Only when no framebuffer has been set up does it make sense to fall
> back to the default VGA device. This ensures at most one primary
> graphics device, preferably the one with the framebuffer.
>
> Suggested-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
> Fixes: ad90860bd10ee ("fbcon: Use screen info to find primary device")
> Reported-by: Aaron Ma <aaron.ma@xxxxxxxxxxxxx>
> Closes: https://lore.kernel.org/linux-pci/20260618081803.2790848-1-aaron.ma@xxxxxxxxxxxxx/#t
> Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> ---
> v1->v2:
> * Fix subject
> * Keep vga_default_device() as fallback instead of remove all
> together
> arch/x86/video/video-common.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
> index 152789f00fcda..8ed82fff7638e 100644
> --- a/arch/x86/video/video-common.c
> +++ b/arch/x86/video/video-common.c
> @@ -43,21 +43,26 @@ bool video_is_primary_device(struct device *dev)
> if (!pci_is_display(pdev))
> return false;
>
> - if (pdev == vga_default_device())
> - return true;
> -
> #ifdef CONFIG_SCREEN_INFO
> numres = screen_info_resources(si, res, ARRAY_SIZE(res));
> - for (i = 0; i < numres; ++i) {
> - if (!(res[i].flags & IORESOURCE_MEM))
> - continue;
> + if (numres > 0) {
> + for (i = 0; i < numres; ++i) {
> + if (!(res[i].flags & IORESOURCE_MEM))
> + continue;
> +
> + if (pci_find_resource(pdev, &res[i]))
> + return true;
> + }
>
> - if (pci_find_resource(pdev, &res[i]))
> - return true;
> + return false;
> }
> #endif
>
> - return false;
> + /*
> + * No framebuffer was set up by the firmware/bootloader, so fall back
> + * to the default VGA device.
> + */
> + return pdev == vga_default_device();
> }
> EXPORT_SYMBOL(video_is_primary_device);
>
> --
> 2.43.0
>