Skip to content

Commit 596b367

Browse files
superm1bp3tk0v
authored andcommitted
x86/video: Only fall back to vga_default_device() without screen info
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. Fixes: ad90860 ("fbcon: Use screen info to find primary device") Closes: https://lore.kernel.org/linux-pci/20260618081803.2790848-1-aaron.ma@canonical.com/#t Reported-by: Aaron Ma <aaron.ma@canonical.com> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Tested-by: Aaron Ma <aaron.ma@canonical.com> Cc: <stable@kernel.org> Link: https://patch.msgid.link/20260623141505.1816786-1-mario.limonciello@amd.com
1 parent b9f0897 commit 596b367

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

arch/x86/video/video-common.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,26 @@ bool video_is_primary_device(struct device *dev)
4343
if (!pci_is_display(pdev))
4444
return false;
4545

46-
if (pdev == vga_default_device())
47-
return true;
48-
4946
#ifdef CONFIG_SCREEN_INFO
5047
numres = screen_info_resources(si, res, ARRAY_SIZE(res));
51-
for (i = 0; i < numres; ++i) {
52-
if (!(res[i].flags & IORESOURCE_MEM))
53-
continue;
48+
if (numres > 0) {
49+
for (i = 0; i < numres; ++i) {
50+
if (!(res[i].flags & IORESOURCE_MEM))
51+
continue;
52+
53+
if (pci_find_resource(pdev, &res[i]))
54+
return true;
55+
}
5456

55-
if (pci_find_resource(pdev, &res[i]))
56-
return true;
57+
return false;
5758
}
5859
#endif
5960

60-
return false;
61+
/*
62+
* No framebuffer was set up by the firmware/bootloader, so fall back
63+
* to the default VGA device.
64+
*/
65+
return pdev == vga_default_device();
6166
}
6267
EXPORT_SYMBOL(video_is_primary_device);
6368

0 commit comments

Comments
 (0)