Skip to content

Commit 7df7b72

Browse files
committed
DRM: Add a new 'boot_display' attribute
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 Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250811162606.587759-5-superm1@kernel.org Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
1 parent ad90860 commit 7df7b72

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
What: /sys/class/drm/.../boot_display
2+
Date: January 2026
3+
Contact: Linux DRI developers <dri-devel@vger.kernel.org>
4+
Description:
5+
This file indicates that displays connected to the device were
6+
used to display the boot sequence. If a display connected to
7+
the device was used to display the boot sequence the file will
8+
be present and contain "1".

drivers/gpu/drm/drm_sysfs.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/gfp.h>
1919
#include <linux/i2c.h>
2020
#include <linux/kdev_t.h>
21+
#include <linux/pci.h>
2122
#include <linux/property.h>
2223
#include <linux/slab.h>
2324

@@ -30,6 +31,8 @@
3031
#include <drm/drm_property.h>
3132
#include <drm/drm_sysfs.h>
3233

34+
#include <asm/video.h>
35+
3336
#include "drm_internal.h"
3437
#include "drm_crtc_internal.h"
3538

@@ -508,6 +511,43 @@ void drm_sysfs_connector_property_event(struct drm_connector *connector,
508511
}
509512
EXPORT_SYMBOL(drm_sysfs_connector_property_event);
510513

514+
static ssize_t boot_display_show(struct device *dev, struct device_attribute *attr,
515+
char *buf)
516+
{
517+
return sysfs_emit(buf, "1\n");
518+
}
519+
static DEVICE_ATTR_RO(boot_display);
520+
521+
static struct attribute *display_attrs[] = {
522+
&dev_attr_boot_display.attr,
523+
NULL
524+
};
525+
526+
static umode_t boot_display_visible(struct kobject *kobj,
527+
struct attribute *a, int n)
528+
{
529+
struct device *dev = kobj_to_dev(kobj)->parent;
530+
531+
if (dev_is_pci(dev)) {
532+
struct pci_dev *pdev = to_pci_dev(dev);
533+
534+
if (video_is_primary_device(&pdev->dev))
535+
return a->mode;
536+
}
537+
538+
return 0;
539+
}
540+
541+
static const struct attribute_group display_attr_group = {
542+
.attrs = display_attrs,
543+
.is_visible = boot_display_visible,
544+
};
545+
546+
static const struct attribute_group *card_dev_groups[] = {
547+
&display_attr_group,
548+
NULL
549+
};
550+
511551
struct device *drm_sysfs_minor_alloc(struct drm_minor *minor)
512552
{
513553
const char *minor_str;
@@ -531,6 +571,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *minor)
531571

532572
kdev->devt = MKDEV(DRM_MAJOR, minor->index);
533573
kdev->class = drm_class;
574+
kdev->groups = card_dev_groups;
534575
kdev->type = &drm_sysfs_device_minor;
535576
}
536577

0 commit comments

Comments
 (0)