Adjust fbcon console device detection
Subsystems (9)
v10 cover Adjust fbcon console device detection
Systems with more than one GPU userspace doesn't know which one to be used to treat as primary. The concept of primary is important to be able to decide which GPU is used for display and which is used for rendering. If it's guessed wrong then both GPUs will be kept awake burning a lot of power.
Historically it would use the "boot_vga" attribute but this isn't present on modern GPUs.
This series started out as changes to VGA arbiter to try to handle a case of a system with 2 GPUs that are not VGA devices and avoid changes to userspace. This was discussed but decided not to overload the VGA arbiter for non VGA devices.
Instead move the x86 specific detection of framebuffer resources into x86 specific code that the fbcon can use to properly identify the primary device. This code is still called from the VGA arbiter, and the logic does not change there. To avoid regression default to VGA arbiter and only fall back to looking up with x86 specific detection method.
In order for userspace to also be able to discover which device was the primary video display device create a new sysfs file 'boot_display'.
A matching userspace implementation for this file is available here:
Dave Airlie has been pinged for a comment on this approach. Dave had suggested in the past [1]:
"
But yes if that doesn't work, then maybe we need to make the boot_vga flag mean boot_display_gpu, and fix it in the kernel
"
This was one of the approached tried in earlier revisions and it was rejected in favor of creating a new sysfs file (which is what this version does).
As the dependendent symbols are in 6.17-rc1 this can merge through drm-misc-next.
---
v10:
* Add patches that didn't merge to v6.17-rc1 in
* Move sysfs file to drm ownership
Mario Limonciello (AMD) (4):
Fix access to video_is_primary_device() when compiled without
CONFIG_VIDEO
PCI/VGA: Replace vga_is_firmware_default() with a screen info check
fbcon: Use screen info to find primary device
DRM: Add a new 'boot_display' attribute
Documentation/ABI/testing/sysfs-class-drm | 8 +++++ arch/parisc/include/asm/video.h | 2 +- arch/sparc/include/asm/video.h | 2 ++ arch/x86/include/asm/video.h | 2 ++ arch/x86/video/video-common.c | 25 +++++++++++++- drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++++ drivers/pci/vgaarb.c | 31 +++-------------- 7 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-drm
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
Signature · 1 line
2.43.0
PATCH v10 1/4 Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO
When compiled without CONFIG_VIDEO the architecture specific implementations of video_is_primary_device() include prototypes and assume that video-common.c will be linked. Guard against this so that the fallback inline implementation that returns false will be used when compiled without CONFIG_VIDEO.
---
v10:
* Rebase on 6.17-rc1
v5:
* add tag
v4:
* new patch
--- arch/parisc/include/asm/video.h | 2 +- arch/sparc/include/asm/video.h | 2 ++ arch/x86/include/asm/video.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-)
arch/parisc/include/asm/video.h +1 -1
@@ -6,7 +6,7 @@struct device ; -#if defined(CONFIG_STI_CORE ) +#if defined(CONFIG_STI_CORE ) && defined(CONFIG_VIDEO )bool video_is_primary_device (struct device *dev);#define video_is_primary_device video_is_primary_device#endif
arch/sparc/include/asm/video.h +2 -0
@@ -19,8 +19,10 @@ static inline pgprot_t pgprot_framebuffer(pgprot_t prot,#define pgprot_framebuffer pgprot_framebuffer#endif +#ifdef CONFIG_VIDEO bool video_is_primary_device (struct device *dev);#define video_is_primary_device video_is_primary_device +#endif static inline void fb_memcpy_fromio (void *to,const volatile void __iomem *from,size_t n) {
arch/x86/include/asm/video.h +2 -0
@@ -13,8 +13,10 @@ pgprot_t pgprot_framebuffer(pgprot_t prot, unsigned long offset);#define pgprot_framebuffer pgprot_framebuffer +#ifdef CONFIG_VIDEO bool video_is_primary_device (struct device *dev);#define video_is_primary_device video_is_primary_device +#endif #include <asm-generic/video.h>
Signature · 1 line
2.43.0
PATCH v10 2/4 PCI/VGA: Replace vga_is_firmware_default() with a screen info check
In reply to Mario Limonciello (AMD)vga_is_firmware_default() checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation of screen_info_pci_dev(). Switch to using screen_info_pci_dev() instead.
---
v10:
* Rebase on 6.17-rc1
--- drivers/pci/vgaarb.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-)
drivers/pci/vgaarb.c +5 -26
@@ -556,34 +556,13 @@ EXPORT_SYMBOL(vga_put);static bool vga_is_firmware_default (struct pci_dev *pdev) { -#if defined(CONFIG_X86 ) -u64 base = screen_info.lfb_base; -u64 size = screen_info.lfb_size; -struct resource *r; -u64 limit; +#ifdef CONFIG_SCREEN_INFO +struct screen_info *si = &screen_info; -/* Select the device owning the boot framebuffer if there is one */ - -if (screen_info.capabilities &VIDEO_CAPABILITY_64BIT_BASE ) - base |= (u64 )screen_info.ext_lfb_base <<32 ; - - limit = base + size; - -/* Does firmware framebuffer belong to us? */ -pci_dev_for_each_resource (pdev, r) { -if (resource_type (r) !=IORESOURCE_MEM ) -continue ; - -if (!r->start || !r->end) -continue ; - -if (base < r->start || limit >= r->end) -continue ; - -return true; - } -#endif +return pdev ==screen_info_pci_dev (si); +#else return false; +#endif }static bool vga_arb_integrated_gpu (struct device *dev)
Signature · 1 line
2.43.0
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Am 11.08.25 um 18:26 schrieb Mario Limonciello (AMD):
Quoted 8 lines
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>
Quoted 51 lines
---
v10:
* Rebase on 6.17-rc1--- drivers/pci/vgaarb.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-)drivers/pci/vgaarb.c +5
-26@@ -556,34 +556,13 @@ EXPORT_SYMBOL(vga_put);static bool vga_is_firmware_default (struct pci_dev *pdev) { -#if defined(CONFIG_X86 ) -u64 base = screen_info.lfb_base; -u64 size = screen_info.lfb_size; -struct resource *r; -u64 limit; +#ifdef CONFIG_SCREEN_INFO +struct screen_info *si = &screen_info; -/* Select the device owning the boot framebuffer if there is one */ - -if (screen_info.capabilities &VIDEO_CAPABILITY_64BIT_BASE ) - base |= (u64 )screen_info.ext_lfb_base <<32 ; - - limit = base + size; - -/* Does firmware framebuffer belong to us? */ -pci_dev_for_each_resource (pdev, r) { -if (resource_type (r) !=IORESOURCE_MEM ) -continue ; - -if (!r->start || !r->end) -continue ; - -if (base < r->start || limit >= r->end) -continue ; - -return true; - } -#endif +return pdev ==screen_info_pci_dev (si); +#else return false; +#endif }static bool vga_arb_integrated_gpu (struct device *dev)
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
In reply to Mario Limonciello (AMD)Hi,
Quoted 8 lines · Mario Limonciello (AMD)
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>
I'm getting a black screen on boot on mainline, and it bisected to this commit. Reverting this commit fixed it.
Please revert.
- Eric
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Quoted 12 lines · Eric Biggers
Hi,
Quoted 8 lines · Mario Limonciello (AMD)
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>
Quoted 6 lines
I'm getting a black screen on boot on mainline, and it bisected to this commit. Reverting this commit fixed it.
Please revert.
- Eric
Can you please share more information about your issue before we jump straight into a revert? What kind of hardware do you have? Perhaps a kernel log from mainline and another from mainline with the revert could help identify what's going on?
A revert might be the right solution, but I would rather fix the issue if it's plausible to do so.
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Quoted 22 lines · Mario Limonciello
Quoted 12 lines · Eric Biggers
Hi,
Quoted 8 lines · Mario Limonciello (AMD)
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>Quoted 6 lines
I'm getting a black screen on boot on mainline, and it bisected to this commit. Reverting this commit fixed it.
Please revert.
- Eric
Quoted 7 lines
Can you please share more information about your issue before we jump straight into a revert? What kind of hardware do you have? Perhaps a kernel log from mainline and another from mainline with the revert could help identify what's going on?
A revert might be the right solution, but I would rather fix the issue if it's plausible to do so.
Relevant hardware is:
AMD Ryzen 9 9950X 16-Core Processor
Radeon RX 9070
The following message appears in the good log but not the bad log:
fbcon: amdgpudrmfb (fb0) is primary device
I don't have CONFIG_SCREEN_INFO enabled, so the commit changed vga_is_firmware_default() to always return false.
If DRM_AMDGPU depends on SCREEN_INFO now, it needs to select it.
- Eric
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Quoted 35 lines · Eric Biggers
Quoted 22 lines · Mario Limonciello
Quoted 12 lines · Eric Biggers
Hi,
Quoted 8 lines · Mario Limonciello (AMD)
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>Quoted 6 lines
I'm getting a black screen on boot on mainline, and it bisected to this commit. Reverting this commit fixed it.
Please revert.
- Eric
Quoted 7 lines
Can you please share more information about your issue before we jump straight into a revert? What kind of hardware do you have? Perhaps a kernel log from mainline and another from mainline with the revert could help identify what's going on?
A revert might be the right solution, but I would rather fix the issue if it's plausible to do so.
Relevant hardware is:
AMD Ryzen 9 9950X 16-Core Processor
Radeon RX 9070
Quoted 6 lines
The following message appears in the good log but not the bad log:
fbcon: amdgpudrmfb (fb0) is primary device
I don't have
CONFIG_SCREEN_INFOenabled, so the commit changedvga_is_firmware_default()to always return false.
Thanks, that definitely explains it.
Quoted 4 lines
If
DRM_AMDGPUdepends onSCREEN_INFOnow, it needs to select it.- Eric
Well the question now is which driver should actually select it.
Although it manifested for you in amdgpu, I don't think this is going to be an amdgpu unique issue.
Maybe this:
drivers/video/fbdev/core/Kconfig +1 -0
@@ -5,6 +5,7 @@ config FB_CORE select VIDEO + select SCREEN_INFO tristate config FB_NOTIFY
Thomas Zimmermann
maintainerRe: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Hi Mario,
thanks for handling this report quickly.
Am 12.10.25 um 21:06 schrieb Mario Limonciello:
[...]
Quoted 22 lines
Quoted 2 lines
I don't have
CONFIG_SCREEN_INFOenabled, so the commit changedvga_is_firmware_default()to always return false.Thanks, that definitely explains it.
Quoted 4 lines
If
DRM_AMDGPUdepends onSCREEN_INFOnow, it needs to select it.- Eric
Well the question now is which driver should actually select it.
Although it manifested for you in amdgpu, I don't think this is going to be an amdgpu unique issue.
Maybe this:
drivers/video/fbdev/core/Kconfig +0
-0@@ -5,6 +5,7 @@
Quoted 3 lines
config
FB_CORE
select VIDEO
+ selectSCREEN_INFO
Let's select it from CONFIG_VGA_ARB. This will restore the old behavior for x86. The else branch for CONFIG_SCREEN_INFO can then go away.
Best regards
Thomas
Quoted 3 lines
tristate
config
FB_NOTIFY
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
In reply to Eric Biggers[+cc regressions]
Quoted 6 lines · Eric Biggers
Quoted 5 lines · Mario Limonciello (AMD)
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.
Quoted 6 lines
Quoted 3 lines
Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>I'm getting a black screen on boot on mainline, and it bisected to this commit. Reverting this commit fixed it.
#regzbot introduced: 337bf13aa9dd ("PCI/VGA: Replace vga_is_firmware_default() with a screen info check") #regzbot link: https://lore.kernel.org/r/[email protected]
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Quoted 11 lines · Bjorn Helgaas
Quoted 10 lines · Eric Biggers
Quoted 8 lines · Mario Limonciello (AMD)
vga_is_firmware_default()checks firmware resources to find the owner framebuffer resources to find the firmware PCI device. This is an open coded implementation ofscreen_info_pci_dev(). Switch to usingscreen_info_pci_dev()instead.Acked-by Bjorn Helgaas <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>
Quoted 5 lines
Quoted 2 lines
I'm getting a black screen on boot on mainline, and it bisected to this commit. Reverting this commit fixed it.
#regzbot introduced:
337bf13aa9dd("PCI/VGA: Replacevga_is_firmware_default()with a screen info check") #regzbot link: https://lore.kernel.org/r/[email protected]
#regzbot fix: a78835b86a44 ("PCI/VGA: Select SCREEN_INFO on X86")
PATCH v10 3/4 fbcon: Use screen info to find primary device
In reply to Mario Limonciello (AMD)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.
---
v10:
* Rebase on 6.17-rc1
* Squash 'fbcon: Stop using screen_info_pci_dev()'
--- arch/x86/video/video-common.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
arch/x86/video/video-common.c +24 -1
@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/pci.h> +#include <linux/screen_info.h> #include <linux/vgaarb.h> #include <asm/video.h>
@@ -27,6 +28,11 @@ EXPORT_SYMBOL(pgprot_framebuffer);bool video_is_primary_device (struct device *dev) { +#ifdef CONFIG_SCREEN_INFO +struct screen_info *si = &screen_info; +struct resource res[SCREEN_INFO_MAX_RESOURCES ]; +ssize_t i, numres; +#endif struct pci_dev *pdev;if (!dev_is_pci (dev))
@@ -34,7 +40,24 @@ bool video_is_primary_device(struct device *dev) pdev =to_pci_dev (dev); -return (pdev ==vga_default_device ()); +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 (pci_find_resource (pdev, &res[i])) +return true; + } +#endif + +return false; }EXPORT_SYMBOL (video_is_primary_device);
Signature · 1 line
2.43.0
Re: [PATCH v10 3/4] fbcon: Use screen info to find primary device
Quoted 10 lines · Mario Limonciello (AMD)
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 <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>
I don't think you need my ack for this, but it does look fine to me.
I wish __screen_info_pci_dev() didn't have to use pci_get_base_class() to iterate through all the devices, but you didn't change that and maybe somebody will dream up a more efficient way someday.
Let me know if you need anything more from me. Thanks for persevering with this!
Quoted 61 lines
---
v10:
* Rebase on 6.17-rc1
* Squash 'fbcon: Stop usingscreen_info_pci_dev()'--- arch/x86/video/video-common.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)arch/x86/video/video-common.c +24
-1@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/pci.h> +#include <linux/screen_info.h> #include <linux/vgaarb.h> #include <asm/video.h> @@ -27,6 +28,11 @@ EXPORT_SYMBOL(pgprot_framebuffer);bool video_is_primary_device (struct device *dev) { +#ifdef CONFIG_SCREEN_INFO +struct screen_info *si = &screen_info; +struct resource res[SCREEN_INFO_MAX_RESOURCES ]; +ssize_t i, numres; +#endif struct pci_dev *pdev;if (!dev_is_pci (dev))@@ -34,7 +40,24 @@ bool video_is_primary_device(struct device *dev) pdev =to_pci_dev (dev); -return (pdev ==vga_default_device ()); +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 (pci_find_resource (pdev, &res[i])) +return true; + } +#endif + +return false; }EXPORT_SYMBOL (video_is_primary_device);Signature · 1 line
2.43.0
Re: [PATCH v10 3/4] fbcon: Use screen info to find primary device
In reply to Mario Limonciello (AMD)Quoted 5 lines · Mario Limonciello (AMD)
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.
I have a question regarding this change. To me, the function name video_is_primary_device() implies that there is only one primary GPU. I would also expect that the 'boot_display' attribute added later in the patch series based on this function is only set for one GPU, but that is not necessarily the case. Since I'm working on a user-space program that reads the 'boot_display' attribute, I need to know what behavior is intended in order to do a correct implementation.
Quoted 38 lines
Reviewed-by Thomas Zimmermann <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>---
v10:
* Rebase on 6.17-rc1
* Squash 'fbcon: Stop usingscreen_info_pci_dev()'--- arch/x86/video/video-common.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)arch/x86/video/video-common.c +6
-0@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/pci.h> +#include <linux/screen_info.h> #include <linux/vgaarb.h> #include <asm/video.h> @@ -27,6 +28,11 @@ EXPORT_SYMBOL(pgprot_framebuffer);bool video_is_primary_device (struct device *dev) { +#ifdef CONFIG_SCREEN_INFO +struct screen_info *si = &screen_info; +struct resource res[SCREEN_INFO_MAX_RESOURCES ]; +ssize_t i, numres; +#endif struct pci_dev *pdev;if (!dev_is_pci (dev))
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 47
Quoted 9 lines
arch/x86/video/video-common.c +5
-1@@ -34,7 +40,24 @@ bool video_is_primary_device(struct device *dev) pdev =to_pci_dev (dev); -return (pdev ==vga_default_device ()); +if (!pci_is_display (pdev)) +return false; + +if (pdev ==vga_default_device ()) +return true;
This can mark a VGA device as primary GPU.
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 58
Quoted 11 lines
arch/x86/video/video-common.c +11
-0+ +#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 (pci_find_resource (pdev, &res[i])) +return true; + } +#endif
And then the new code can also choose a primary GPU.
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 63
Quoted 5 lines
arch/x86/video/video-common.c +2
-0+ +return false; }EXPORT_SYMBOL (video_is_primary_device);
In particular, I have hardware that has this exact configuration where two GPUs are marked as primary and have a 'boot_display' attribute: the first one through vga_default_device(), the second one through the new detection method.
Is this intended?
Kind regards
Aaron
Re: [PATCH v10 3/4] fbcon: Use screen info to find primary device
Quoted 91 lines · Aaron Erhardt
Quoted 5 lines · Mario Limonciello (AMD)
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.I have a question regarding this change. To me, the function name
video_is_primary_device()implies that there is only one primary GPU. I would also expect that the 'boot_display' attribute added later in the patch series based on this function is only set for one GPU, but that is not necessarily the case. Since I'm working on a user-space program that reads the 'boot_display' attribute, I need to know what behavior is intended in order to do a correct implementation.Quoted 38 lines
Reviewed-by Thomas Zimmermann <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>---
v10:
* Rebase on 6.17-rc1
* Squash 'fbcon: Stop usingscreen_info_pci_dev()'--- arch/x86/video/video-common.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)arch/x86/video/video-common.c +6
-0@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/pci.h> +#include <linux/screen_info.h> #include <linux/vgaarb.h> #include <asm/video.h> @@ -27,6 +28,11 @@ EXPORT_SYMBOL(pgprot_framebuffer);bool video_is_primary_device (struct device *dev) { +#ifdef CONFIG_SCREEN_INFO +struct screen_info *si = &screen_info; +struct resource res[SCREEN_INFO_MAX_RESOURCES ]; +ssize_t i, numres; +#endif struct pci_dev *pdev;if (!dev_is_pci (dev))arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 47
Quoted 9 lines
arch/x86/video/video-common.c +5
-1@@ -34,7 +40,24 @@ bool video_is_primary_device(struct device *dev) pdev =to_pci_dev (dev); -return (pdev ==vga_default_device ()); +if (!pci_is_display (pdev)) +return false; + +if (pdev ==vga_default_device ()) +return true;This can mark a VGA device as primary GPU.
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 58
Quoted 11 lines
arch/x86/video/video-common.c +11
-0+ +#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 (pci_find_resource (pdev, &res[i])) +return true; + } +#endif And then the new code can also choose a primary GPU.
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 63
Quoted 5 lines
arch/x86/video/video-common.c +2
-0+ +return false; }EXPORT_SYMBOL (video_is_primary_device);In particular, I have hardware that has this exact configuration where two GPUs are marked as primary and have a '
boot_display' attribute: the first one throughvga_default_device(), the second one through the new detection method.
Quoted 5 lines
Is this intended?
Kind regards
Aaron
I wouldn't have expected a case like this and I think it means there is a logic error.
Can you please file a kernel bugzilla with details about your system and CC me?
dmesg and lspci -vvnn please
Also; please clarify which GPU shows something when booting up.
Thomas Zimmermann
maintainerRe: [PATCH v10 3/4] fbcon: Use screen info to find primary device
Hi
Am 28.10.25 um 14:15 schrieb Mario Limonciello:
Quoted 52 lines · Aaron Erhardt
Quoted 51 lines · Mario Limonciello (AMD)
Quoted 5 lines
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.I have a question regarding this change. To me, the function name
video_is_primary_device()implies that there is only one primary GPU. I would also expect that the 'boot_display' attribute added later in the patch series based on this function is only set for one GPU, but that is not necessarily the case. Since I'm working on a user-space program that reads the 'boot_display' attribute, I need to know what behavior is intended in order to do a correct implementation.Quoted 35 lines
Reviewed-by Thomas Zimmermann <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>---
v10:
* Rebase on 6.17-rc1
* Squash 'fbcon: Stop usingscreen_info_pci_dev()'
---
arch/x86/video/video-common.c| 25 ++++++++++++++++++++++++-1 file changed, 24 insertions(+), 1 deletion(-)arch/x86/video/video-common.c +6
-0@@ -9,6 +9,7 @@ #include <linux/module.h> #include <linux/pci.h> +#include <linux/screen_info.h> #include <linux/vgaarb.h> #include <asm/video.h>@@ -27,6 +28,11 @@ EXPORT_SYMBOL(pgprot_framebuffer); bool video_is_primary_device(struct device *dev) { +#ifdef CONFIG_SCREEN_INFO + struct screen_info *si = &screen_info; + struct resource res[SCREEN_INFO_MAX_RESOURCES]; + ssize_t i, numres; +#endif struct pci_dev *pdev; if (!dev_is_pci(dev))@@ -34,7 +40,24 @@ bool video_is_primary_device(struct device *dev) pdev = to_pci_dev(dev);
Quoted 8 lines
Quoted 8 lines
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 47
Quoted 6 lines
arch/x86/video/video-common.c +5
-0- return (pdev == vga_default_device()); + if (!pci_is_display(pdev)) + return false; + + if (pdev == vga_default_device()) + return true;This can mark a VGA device as primary GPU.
Is the value returned from vga_default_device() eq to NULL?
Quoted 14 lines
Quoted 14 lines
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 58
Quoted 12 lines
arch/x86/video/video-common.c +11
-0+ +#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 (pci_find_resource(pdev, &res[i])) + return true; + } +#endif And then the new code can also choose a primary GPU.
Maybe we should drop this block or move it to [1]? At [1] it would only run if the more sophisticated vgaarb has been disabled.
The vgaarb now selects CONFIG_SCREEN_INFO and already tests for overlapping resources. There's nothing here that vgaarb shouldn't already do. Yet, I don't understand how only one of the can be true at a time.
[1] https://elixir.bootlin.com/linux/v6.18-rc3/source/include/linux/vgaarb.h#L55
Quoted 17 lines
Quoted 11 lines
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 62
Quoted 5 lines
arch/x86/video/video-common.c +2
-0+ + return false; } EXPORT_SYMBOL(video_is_primary_device);In particular, I have hardware that has this exact configuration where two GPUs are marked as primary and have a '
boot_display' attribute: the first one throughvga_default_device(), the second one through the new detection method.Quoted 5 lines
Is this intended?
Kind regards
Aaron
Quoted 7 lines
I wouldn't have expected a case like this and I think it means there is a logic error.
Can you please file a kernel bugzilla with details about your system and CC me?
dmesg and lspci -vvnn please
Also; please clarify which GPU shows something when booting up.
Agreed.
Best regards
Thomas
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Re: [PATCH v10 3/4] fbcon: Use screen info to find primary device
Quoted 81 lines · Thomas Zimmermann
Hi
Am 28.10.25 um 14:15 schrieb Mario Limonciello:
Quoted 52 lines · Aaron Erhardt
Quoted 51 lines · Mario Limonciello (AMD)
Quoted 5 lines
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.I have a question regarding this change. To me, the function name
video_is_primary_device()implies that there is only one primary GPU. I would also expect that the 'boot_display' attribute added later in the patch series based on this function is only set for one GPU, but that is not necessarily the case. Since I'm working on a user-space program that reads the 'boot_display' attribute, I need to know what behavior is intended in order to do a correct implementation.Quoted 35 lines
Reviewed-by Thomas Zimmermann <[email protected]>Suggested-by Thomas Zimmermann <[email protected]>Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Mario Limonciello (AMD) <[email protected]>---
v10:
* Rebase on 6.17-rc1
* Squash 'fbcon: Stop usingscreen_info_pci_dev()'
---
arch/x86/video/video-common.c| 25 ++++++++++++++++++++++++-1 file changed, 24 insertions(+), 1 deletion(-)arch/x86/video/video-common.c +6
-0@@ -9,6 +9,7 @@ #include <linux/module.h> #include <linux/pci.h> +#include <linux/screen_info.h> #include <linux/vgaarb.h> #include <asm/video.h>@@ -27,6 +28,11 @@ EXPORT_SYMBOL(pgprot_framebuffer); bool video_is_primary_device(struct device *dev) { +#ifdef CONFIG_SCREEN_INFO + struct screen_info *si = &screen_info; + struct resource res[SCREEN_INFO_MAX_RESOURCES]; + ssize_t i, numres; +#endif struct pci_dev *pdev; if (!dev_is_pci(dev))@@ -34,7 +40,24 @@ bool video_is_primary_device(struct device *dev) pdev = to_pci_dev(dev);Quoted 8 lines
Quoted 8 lines
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 47
Quoted 6 lines
arch/x86/video/video-common.c +5
-0- return (pdev == vga_default_device()); + if (!pci_is_display(pdev)) + return false; + + if (pdev == vga_default_device()) + return true;This can mark a VGA device as primary GPU.
Is the value returned from
vga_default_device()eq to NULL?Quoted 14 lines
Quoted 14 lines
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 58
Quoted 12 lines
arch/x86/video/video-common.c +11
-0+ +#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 (pci_find_resource(pdev, &res[i])) + return true; + } +#endif And then the new code can also choose a primary GPU.
Quoted 5 lines
Maybe we should drop this block or move it to [1]? At [1] it would only run if the more sophisticated vgaarb has been disabled.
The vgaarb now selects
CONFIG_SCREEN_INFOand already tests for overlapping resources. There's nothing here that vgaarb shouldn't already do. Yet, I don't understand how only one of the can be true at a time.[1] https://elixir.bootlin.com/linux/v6.18-rc3/source/include/linux/ vgaarb.h#L55
There is a hunk at the end of vga_is_boot_device() which I think is causing this issue. We have one VGA device which is NOT the boot display but the code figures if it found nothing this must be right.
/* * Vgadev has neither IO nor MEM enabled. If we haven't found any * other VGA devices, it is the best candidate so far. */ if (!boot_vga) return true;
I feel the right solution is to drop this now.
Quoted 32 lines
Quoted 18 lines
Quoted 12 lines
arch/x86/video/video-common.c bool video_is_primary_device(struct device *dev) · line 62
Quoted 6 lines
arch/x86/video/video-common.c +2
-0+ + return false; } EXPORT_SYMBOL(video_is_primary_device);In particular, I have hardware that has this exact configuration where two GPUs are marked as primary and have a '
boot_display' attribute: the first one throughvga_default_device(), the second one through the new detection method.Quoted 5 lines
Is this intended?
Kind regards
AaronQuoted 7 lines
I wouldn't have expected a case like this and I think it means there is a logic error.
Can you please file a kernel bugzilla with details about your system and CC me?
dmesg and lspci -vvnn please
Also; please clarify which GPU shows something when booting up.
Agreed.
Best regards
Thomas
PATCH v10 4/4 DRM: Add a new 'boot_display' attribute
In reply to Mario Limonciello (AMD)On systems with multiple GPUs there can be uncertainty which GPU is the primary one used to drive the display at bootup. In some desktop environments this can lead to increased power consumption because secondary GPUs may be used for rendering and never go to a low power state. In order to disambiguate this add a new sysfs attribute 'boot_display' that uses the output of video_is_primary_device() to populate whether the PCI device was used for driving the display.
---
v10:
* Rebase on 6.17-rc1
* Drop Thomas' tag, as this is now in a totally different subsystem (although same code)
* Squash "Adjust visibility of boot_display attribute instead of creation"
* Squash "PCI: Move boot display attribute to DRM"
--- Documentation/ABI/testing/sysfs-class-drm | 8 +++++ drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-drm
Documentation/ABI/testing/sysfs-class-drm new file +8 -0
@@ -0,0 +1,8 @@ +What: /sys/class/drm/.../boot_display +Date: January 2026 +Contact: Linux DRI developers <[email protected]> +Description: + This file indicates that displays connected to the device were + used to display the boot sequence. If a display connected to + the device was used to display the boot sequence the file will + be present and contain "1".
drivers/gpu/drm/drm_sysfs.c +41 -0
65 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute
Am 11.08.25 um 18:26 schrieb Mario Limonciello (AMD):
Quoted 8 lines
On systems with multiple GPUs there can be uncertainty which GPU is the primary one used to drive the display at bootup. In some desktop environments this can lead to increased power consumption because secondary GPUs may be used for rendering and never go to a low power state. In order to disambiguate this add a new sysfs attribute '
boot_display' that uses the output ofvideo_is_primary_device()to populate whether the PCI device was used for driving the display.
Quoted 4 lines
Quoted 100 lines
---
v10:
* Rebase on 6.17-rc1
* Drop Thomas' tag, as this is now in a totally different subsystem (although same code)
* Squash "Adjust visibility ofboot_displayattribute instead of creation"
* Squash "PCI: Move boot display attribute to DRM"--- Documentation/ABI/testing/sysfs-class-drm | 8 +++++ drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++++ 2 files changed, 49 insertions(+)create mode 100644
Documentation/ABI/testing/sysfs-class-drmDocumentation/ABI/testing/sysfs-class-drm new file +8
-0@@ -0,0 +1,8 @@ +What: /sys/class/drm/.../boot_display +Date: January 2026 +Contact: Linux DRI developers <[email protected]> +Description: + This file indicates that displays connected to the device were + used to display the boot sequence. If a display connected to + the device was used to display the boot sequence the file will + be present and contain "1".drivers/gpu/drm/drm_sysfs.c +41
-0@@ -18,6 +18,7 @@#include <linux/gfp.h> #include <linux/i2c.h> #include <linux/kdev_t.h> +#include <linux/pci.h> #include <linux/property.h> #include <linux/slab.h> @@ -30,6 +31,8 @@#include <drm/drm_property.h> #include <drm/drm_sysfs.h> +#include <asm/video.h> +#include "drm_internal.h" #include "drm_crtc_internal.h" @@ -508,6 +511,43 @@ void drm_sysfs_connector_property_event(struct drm_connector *connector, }EXPORT_SYMBOL (drm_sysfs_connector_property_event); +static ssize_t boot_display_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +return sysfs_emit (buf,"1\n" ); +} +static DEVICE_ATTR_RO (boot_display); + +static struct attribute *display_attrs[] = { + &dev_attr_boot_display.attr, +NULL +}; + +static umode_t boot_display_visible (struct kobject *kobj, +struct attribute *a,int n) +{ +struct device *dev =kobj_to_dev (kobj)->parent; + +if (dev_is_pci (dev)) { +struct pci_dev *pdev =to_pci_dev (dev); + +if (video_is_primary_device (&pdev->dev)) +return a->mode; + } + +return 0 ; +} + +static const struct attribute_group display_attr_group = { + .attrs = display_attrs, + .is_visible = boot_display_visible, +}; + +static const struct attribute_group *card_dev_groups[] = { + &display_attr_group, +NULL +}; +struct device *drm_sysfs_minor_alloc (struct drm_minor *minor) {const char *minor_str;@@ -531,6 +571,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *minor) kdev->devt =MKDEV (DRM_MAJOR , minor->index); kdev->class = drm_class; + kdev->groups = card_dev_groups; kdev->type = &drm_sysfs_device_minor; }
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 64 lines · Mario Limonciello (AMD)
Systems with more than one GPU userspace doesn't know which one to be used to treat as primary. The concept of primary is important to be able to decide which GPU is used for display and which is used for rendering. If it's guessed wrong then both GPUs will be kept awake burning a lot of power.
Historically it would use the "
boot_vga" attribute but this isn't present on modern GPUs.This series started out as changes to VGA arbiter to try to handle a case of a system with 2 GPUs that are not VGA devices and avoid changes to userspace. This was discussed but decided not to overload the VGA arbiter for non VGA devices.
Instead move the x86 specific detection of framebuffer resources into x86 specific code that the fbcon can use to properly identify the primary device. This code is still called from the VGA arbiter, and the logic does not change there. To avoid regression default to VGA arbiter and only fall back to looking up with x86 specific detection method.
In order for userspace to also be able to discover which device was the primary video display device create a new sysfs file '
boot_display'.A matching userspace implementation for this file is available here:
Dave Airlie has been pinged for a comment on this approach. Dave had suggested in the past [1]:
"
But yes if that doesn't work, then maybe we need to make theboot_vgaflag meanboot_display_gpu, and fix it in the kernel
"This was one of the approached tried in earlier revisions and it was rejected in favor of creating a new sysfs file (which is what this version does).
As the dependendent symbols are in 6.17-rc1 this can merge through drm-misc-next.
---
v10:
* Add patches that didn't merge to v6.17-rc1 in
* Move sysfs file to drm ownershipMario Limonciello (AMD) (4):
Fix access tovideo_is_primary_device()when compiled without
CONFIG_VIDEO
PCI/VGA: Replacevga_is_firmware_default()with a screen info check
fbcon: Use screen info to find primary device
DRM: Add a new 'boot_display' attributeDocumentation/ABI/testing/sysfs-class-drm | 8 +++++ arch/parisc/include/asm/video.h | 2 +- arch/sparc/include/asm/video.h | 2 ++ arch/x86/include/asm/video.h | 2 ++ arch/x86/video/video-common.c | 25 +++++++++++++- drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++++ drivers/pci/vgaarb.c | 31 +++-------------- 7 files changed, 83 insertions(+), 28 deletions(-)
Quoted 4 lines
create mode 100644
Documentation/ABI/testing/sysfs-class-drmbase-commit:
8f5ae30d69d7543eee0d70083daf4de8fe15d585
Bjorn,
Any feedback for this series?
Thanks,
Quoted 64 lines · Mario Limonciello (AMD)
Systems with more than one GPU userspace doesn't know which one to be used to treat as primary. The concept of primary is important to be able to decide which GPU is used for display and which is used for rendering. If it's guessed wrong then both GPUs will be kept awake burning a lot of power.
Historically it would use the "
boot_vga" attribute but this isn't present on modern GPUs.This series started out as changes to VGA arbiter to try to handle a case of a system with 2 GPUs that are not VGA devices and avoid changes to userspace. This was discussed but decided not to overload the VGA arbiter for non VGA devices.
Instead move the x86 specific detection of framebuffer resources into x86 specific code that the fbcon can use to properly identify the primary device. This code is still called from the VGA arbiter, and the logic does not change there. To avoid regression default to VGA arbiter and only fall back to looking up with x86 specific detection method.
In order for userspace to also be able to discover which device was the primary video display device create a new sysfs file '
boot_display'.A matching userspace implementation for this file is available here:
Dave Airlie has been pinged for a comment on this approach. Dave had suggested in the past [1]:
"
But yes if that doesn't work, then maybe we need to make theboot_vgaflag meanboot_display_gpu, and fix it in the kernel
"This was one of the approached tried in earlier revisions and it was rejected in favor of creating a new sysfs file (which is what this version does).
As the dependendent symbols are in 6.17-rc1 this can merge through drm-misc-next.
---
v10:
* Add patches that didn't merge to v6.17-rc1 in
* Move sysfs file to drm ownershipMario Limonciello (AMD) (4):
Fix access tovideo_is_primary_device()when compiled without
CONFIG_VIDEO
PCI/VGA: Replacevga_is_firmware_default()with a screen info check
fbcon: Use screen info to find primary device
DRM: Add a new 'boot_display' attributeDocumentation/ABI/testing/sysfs-class-drm | 8 +++++ arch/parisc/include/asm/video.h | 2 +- arch/sparc/include/asm/video.h | 2 ++ arch/x86/include/asm/video.h | 2 ++ arch/x86/video/video-common.c | 25 +++++++++++++- drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++++ drivers/pci/vgaarb.c | 31 +++-------------- 7 files changed, 83 insertions(+), 28 deletions(-)
Quoted 4 lines
create mode 100644
Documentation/ABI/testing/sysfs-class-drmbase-commit:
8f5ae30d69d7543eee0d70083daf4de8fe15d585
DRM maintainers, can I please get a review on patch 4 [0]? This changes the ABI of DRM to offer a new file, so I would like to make sure that is amenable. All other patches have reviews.
In the earlier versions of this series it was done by PCI, but there was a push to move to DRM.