Skip to content

Commit ad90860

Browse files
committed
fbcon: Use screen info to find primary device
On systems with non VGA GPUs fbcon can't find the primary GPU because video_is_primary_device() only checks the VGA arbiter. Add a screen info check to video_is_primary_device() so that callers can get accurate data on such systems. Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> Suggested-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/20250811162606.587759-4-superm1@kernel.org Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
1 parent 337bf13 commit ad90860

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

arch/x86/video/video-common.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/module.h>
1111
#include <linux/pci.h>
12+
#include <linux/screen_info.h>
1213
#include <linux/vgaarb.h>
1314

1415
#include <asm/video.h>
@@ -27,14 +28,36 @@ EXPORT_SYMBOL(pgprot_framebuffer);
2728

2829
bool video_is_primary_device(struct device *dev)
2930
{
31+
#ifdef CONFIG_SCREEN_INFO
32+
struct screen_info *si = &screen_info;
33+
struct resource res[SCREEN_INFO_MAX_RESOURCES];
34+
ssize_t i, numres;
35+
#endif
3036
struct pci_dev *pdev;
3137

3238
if (!dev_is_pci(dev))
3339
return false;
3440

3541
pdev = to_pci_dev(dev);
3642

37-
return (pdev == vga_default_device());
43+
if (!pci_is_display(pdev))
44+
return false;
45+
46+
if (pdev == vga_default_device())
47+
return true;
48+
49+
#ifdef CONFIG_SCREEN_INFO
50+
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;
54+
55+
if (pci_find_resource(pdev, &res[i]))
56+
return true;
57+
}
58+
#endif
59+
60+
return false;
3861
}
3962
EXPORT_SYMBOL(video_is_primary_device);
4063

0 commit comments

Comments
 (0)