* [PATCH v2] x86/video: Only fall back to vga_default_device() without screen info
@ 2026-06-23 14:15 Mario Limonciello
2026-06-23 14:21 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2026-06-23 14:15 UTC (permalink / raw)
To: Bjorn Helgaas, Thomas Zimmermann, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen
Cc: maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:PCI SUBSYSTEM, Mario Limonciello, Aaron Ma
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@suse.de>
Fixes: ad90860bd10ee ("fbcon: Use screen info to find primary device")
Reported-by: Aaron Ma <aaron.ma@canonical.com>
Closes: https://lore.kernel.org/linux-pci/20260618081803.2790848-1-aaron.ma@canonical.com/#t
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] x86/video: Only fall back to vga_default_device() without screen info
2026-06-23 14:15 [PATCH v2] x86/video: Only fall back to vga_default_device() without screen info Mario Limonciello
@ 2026-06-23 14:21 ` sashiko-bot
2026-06-23 14:25 ` Mario Limonciello
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-06-23 14:21 UTC (permalink / raw)
To: Mario Limonciello; +Cc: linux-pci
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch unconditionally returns `false` if `screen_info` has memory resources that do not match any standard PCI BAR, breaking primary device detection for systems booting in legacy VGA text modes.
--
commit a8c04b0c2e4edb24a29bd696ebde27323036eb98
Author: Mario Limonciello <mario.limonciello@amd.com>
x86/video: Only fall back to vga_default_device() without screen info
This commit changes the primary video device detection on x86 to rely
exclusively on screen_info if available, and only falls back to
vga_default_device() when no screen info resources are present. This
prevents multiple devices from erroneously claiming the primary
boot_display attribute.
Closes: https://lore.kernel.org/linux-pci/20260618081803.2790848-1-aaron.ma@canonical.com/#t
> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
> index e0aeee99bc99e..e5fb3cf885fbd 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;
[Severity: High]
Does this unconditional return break primary display detection for systems
booting via legacy BIOS or VGA text mode?
When booting in legacy VGA text mode, screen_info_resources() populates
resources with legacy memory ranges like 0xa0000 or 0xb8000. Since numres > 0,
the code enters this block.
However, legacy VGA windows are implicitly routed and not explicitly
represented as standard PCI BARs. Because of this, pci_find_resource() will
fail to match.
By returning false here, the code completely bypasses the fallback to
vga_default_device() for these legacy systems. Should this fall through to the
vga_default_device() check instead of returning false when the resources do
not match any standard PCI BAR?
> }
> #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();
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623141505.1816786-1-mario.limonciello@amd.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] x86/video: Only fall back to vga_default_device() without screen info
2026-06-23 14:21 ` sashiko-bot
@ 2026-06-23 14:25 ` Mario Limonciello
0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-06-23 14:25 UTC (permalink / raw)
To: sashiko-reviews; +Cc: linux-pci
On 6/23/26 07:21, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The patch unconditionally returns `false` if `screen_info` has memory resources that do not match any standard PCI BAR, breaking primary device detection for systems booting in legacy VGA text modes.
> --
>
> commit a8c04b0c2e4edb24a29bd696ebde27323036eb98
> Author: Mario Limonciello <mario.limonciello@amd.com>
>
> x86/video: Only fall back to vga_default_device() without screen info
>
> This commit changes the primary video device detection on x86 to rely
> exclusively on screen_info if available, and only falls back to
> vga_default_device() when no screen info resources are present. This
> prevents multiple devices from erroneously claiming the primary
> boot_display attribute.
>
> Closes: https://lore.kernel.org/linux-pci/20260618081803.2790848-1-aaron.ma@canonical.com/#t
>
>> diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
>> index e0aeee99bc99e..e5fb3cf885fbd 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;
>
> [Severity: High]
> Does this unconditional return break primary display detection for systems
> booting via legacy BIOS or VGA text mode?
>
> When booting in legacy VGA text mode, screen_info_resources() populates
> resources with legacy memory ranges like 0xa0000 or 0xb8000. Since numres > 0,
> the code enters this block.
>
> However, legacy VGA windows are implicitly routed and not explicitly
> represented as standard PCI BARs. Because of this, pci_find_resource() will
> fail to match.
>
> By returning false here, the code completely bypasses the fallback to
> vga_default_device() for these legacy systems. Should this fall through to the
> vga_default_device() check instead of returning false when the resources do
> not match any standard PCI BAR?
>
Those devices should get a boot_vga attribute instead of boot_display
attribute. I think this is OK.
>> }
>> #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();
>> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-23 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 14:15 [PATCH v2] x86/video: Only fall back to vga_default_device() without screen info Mario Limonciello
2026-06-23 14:21 ` sashiko-bot
2026-06-23 14:25 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox