public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Mario Limonciello (AMD)" <superm1@kernel.org>
To: David Airlie <airlied@gmail.com>, Bjorn Helgaas <bhelgaas@google.com>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	dri-devel@lists.freedesktop.org (open list:DRM DRIVERS),
	linux-kernel@vger.kernel.org (open list),
	linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM),
	"Daniel Dadap" <ddadap@nvidia.com>,
	"Mario Limonciello (AMD)" <superm1@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>
Subject: [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute
Date: Mon, 11 Aug 2025 11:26:06 -0500	[thread overview]
Message-ID: <20250811162606.587759-5-superm1@kernel.org> (raw)
In-Reply-To: <20250811162606.587759-1-superm1@kernel.org>

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


  parent reply	other threads:[~2025-08-11 16:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-09-10 14:33   ` Thomas Zimmermann
2025-10-12 18:23   ` Eric Biggers
2025-10-12 18:37     ` Mario Limonciello
2025-10-12 18:47       ` Eric Biggers
2025-10-12 19:06         ` Mario Limonciello
2025-10-13  7:04           ` Thomas Zimmermann
2025-10-13 20:55     ` Bjorn Helgaas
2025-10-28 22:50       ` Bjorn Helgaas
2025-08-11 16:26 ` [PATCH v10 3/4] fbcon: Use screen info to find primary device Mario Limonciello (AMD)
2025-09-04 20:42   ` Bjorn Helgaas
2025-10-28 10:16   ` Aaron Erhardt
2025-10-28 13:15     ` Mario Limonciello
2025-10-28 16:50       ` Thomas Zimmermann
2025-10-28 21:25         ` Mario Limonciello
2025-08-11 16:26 ` Mario Limonciello (AMD) [this message]
2025-09-10 14:28   ` [PATCH v10 4/4] DRM: Add a new 'boot_display' attribute Thomas Zimmermann
2025-09-03  4:42 ` [PATCH v10 0/4] Adjust fbcon console device detection Mario Limonciello
2025-09-04 22:36 ` Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250811162606.587759-5-superm1@kernel.org \
    --to=superm1@kernel.org \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=bhelgaas@google.com \
    --cc=christian.koenig@amd.com \
    --cc=ddadap@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mani@kernel.org \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox