* [PATCH v10 0/4] Adjust fbcon console device detection
@ 2025-08-11 16:26 Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 1/4] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Mario Limonciello (AMD)
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Mario Limonciello (AMD) @ 2025-08-11 16:26 UTC (permalink / raw)
To: David Airlie, Bjorn Helgaas
Cc: Alex Deucher, Christian König, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
open list:DRM DRIVERS, open list, open list:PCI SUBSYSTEM,
Daniel Dadap, Mario Limonciello
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:
Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/merge_requests/39
Link: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2038
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.
Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/merge_requests/37#note_2938602 [1]
---
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
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v10 1/4] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO
2025-08-11 16:26 [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello (AMD)
@ 2025-08-11 16:26 ` Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Mario Limonciello (AMD)
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello (AMD) @ 2025-08-11 16:26 UTC (permalink / raw)
To: David Airlie, Bjorn Helgaas
Cc: Alex Deucher, Christian König, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
open list:DRM DRIVERS, open list, open list:PCI SUBSYSTEM,
Daniel Dadap, Mario Limonciello (AMD), kernel test robot
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.
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506221312.49Fy1aNA-lkp@intel.com/
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
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(-)
diff --git a/arch/parisc/include/asm/video.h b/arch/parisc/include/asm/video.h
index c5dff3223194a..a9d50ebd6e769 100644
--- a/arch/parisc/include/asm/video.h
+++ b/arch/parisc/include/asm/video.h
@@ -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
diff --git a/arch/sparc/include/asm/video.h b/arch/sparc/include/asm/video.h
index a6f48f52db584..773717b6d4914 100644
--- a/arch/sparc/include/asm/video.h
+++ b/arch/sparc/include/asm/video.h
@@ -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)
{
diff --git a/arch/x86/include/asm/video.h b/arch/x86/include/asm/video.h
index 0950c9535fae9..08ec328203ef8 100644
--- a/arch/x86/include/asm/video.h
+++ b/arch/x86/include/asm/video.h
@@ -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>
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
2025-08-11 16:26 [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 1/4] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Mario Limonciello (AMD)
@ 2025-08-11 16:26 ` Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 3/4] fbcon: Use screen info to find primary device Mario Limonciello (AMD)
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello (AMD) @ 2025-08-11 16:26 UTC (permalink / raw)
To: David Airlie, Bjorn Helgaas
Cc: Alex Deucher, Christian König, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
open list:DRM DRIVERS, open list, open list:PCI SUBSYSTEM,
Daniel Dadap, 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.
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
v10:
* Rebase on 6.17-rc1
---
drivers/pci/vgaarb.c | 31 +++++--------------------------
1 file changed, 5 insertions(+), 26 deletions(-)
diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 78748e8d2dbae..b58f94ee48916 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v10 3/4] fbcon: Use screen info to find primary device
2025-08-11 16:26 [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 1/4] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Mario Limonciello (AMD)
@ 2025-08-11 16:26 ` Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute Mario Limonciello (AMD)
2025-09-03 4:42 ` [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello
4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello (AMD) @ 2025-08-11 16:26 UTC (permalink / raw)
To: David Airlie, Bjorn Helgaas
Cc: Alex Deucher, Christian König, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
open list:DRM DRIVERS, open list, open list:PCI SUBSYSTEM,
Daniel Dadap, 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 <tzimmermann@suse.de>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
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(-)
diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
index 81fc97a2a837a..e0aeee99bc99e 100644
--- a/arch/x86/video/video-common.c
+++ b/arch/x86/video/video-common.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute
2025-08-11 16:26 [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello (AMD)
` (2 preceding siblings ...)
2025-08-11 16:26 ` [PATCH v10 3/4] fbcon: Use screen info to find primary device Mario Limonciello (AMD)
@ 2025-08-11 16:26 ` Mario Limonciello (AMD)
2025-09-03 4:42 ` [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello
4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello (AMD) @ 2025-08-11 16:26 UTC (permalink / raw)
To: David Airlie, Bjorn Helgaas
Cc: Alex Deucher, Christian König, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
open list:DRM DRIVERS, open list, open list:PCI SUBSYSTEM,
Daniel Dadap, Mario Limonciello (AMD), Manivannan Sadhasivam
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.
Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/issues/23
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
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
diff --git a/Documentation/ABI/testing/sysfs-class-drm b/Documentation/ABI/testing/sysfs-class-drm
new file mode 100644
index 0000000000000..d23fed5e29a74
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-drm
@@ -0,0 +1,8 @@
+What: /sys/class/drm/.../boot_display
+Date: January 2026
+Contact: Linux DRI developers <dri-devel@vger.kernel.org>
+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".
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index a455c56dbbeb7..b01ffa4d65098 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v10 0/4] Adjust fbcon console device detection
2025-08-11 16:26 [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello (AMD)
` (3 preceding siblings ...)
2025-08-11 16:26 ` [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute Mario Limonciello (AMD)
@ 2025-09-03 4:42 ` Mario Limonciello
4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2025-09-03 4:42 UTC (permalink / raw)
To: David Airlie, Bjorn Helgaas
Cc: Alex Deucher, Christian König, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
open list:DRM DRIVERS, open list, open list:PCI SUBSYSTEM,
Daniel Dadap
On 8/11/2025 11:26 AM, Mario Limonciello (AMD) wrote:
> 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:
> Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/merge_requests/39
> Link: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2038
>
> 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.
>
> Link: https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/merge_requests/37#note_2938602 [1]
>
> ---
> 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
Bjorn,
Any feedback for this series?
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-03 4:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 16:26 [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 1/4] Fix access to video_is_primary_device() when compiled without CONFIG_VIDEO Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 3/4] fbcon: Use screen info to find primary device Mario Limonciello (AMD)
2025-08-11 16:26 ` [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute Mario Limonciello (AMD)
2025-09-03 4:42 ` [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).