[tip: x86/urgent] x86/video: Only fall back to vga_default_device() without screen info
From: tip-bot2 for Mario Limonciello
Date: Tue Jul 07 2026 - 11:39:56 EST
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 596b3678326d3d1aed7c19423b6746f1ce09688a
Gitweb: https://git.kernel.org/tip/596b3678326d3d1aed7c19423b6746f1ce09688a
Author: Mario Limonciello <mario.limonciello@xxxxxxx>
AuthorDate: Tue, 23 Jun 2026 07:15:05 -07:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Tue, 07 Jul 2026 08:14:55 -07:00
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: ad90860bd10ee ("fbcon: Use screen info to find primary device")
Closes: https://lore.kernel.org/linux-pci/20260618081803.2790848-1-aaron.ma@xxxxxxxxxxxxx/#t
Reported-by: Aaron Ma <aaron.ma@xxxxxxxxxxxxx>
Suggested-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
Tested-by: Aaron Ma <aaron.ma@xxxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxx>
Link: https://patch.msgid.link/20260623141505.1816786-1-mario.limonciello@xxxxxxx
---
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 152789f..8ed82ff 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);