[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250721185726.1264909-2-superm1@kernel.org>
Date: Mon, 21 Jul 2025 13:57:26 -0500
From: Mario Limonciello <superm1@...nel.org>
To: David Airlie <airlied@...il.com>,
Bjorn Helgaas <bhelgaas@...gle.com>
Cc: Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>,
Simona Vetter <simona@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
dri-devel@...ts.freedesktop.org (open list:DRM DRIVERS),
linux-kernel@...r.kernel.org (open list),
linux-pci@...r.kernel.org (open list:PCI SUBSYSTEM),
Daniel Dadap <ddadap@...dia.com>,
Mario Limonciello <mario.limonciello@....com>,
Manivannan Sadhasivam <mani@...nel.org>,
Stephen Rothwell <sfr@...b.auug.org.au>
Subject: [PATCH v4 1/1] PCI: Move boot display attribute to DRM
From: Mario Limonciello <mario.limonciello@....com>
The boot_display attribute is currently created by PCI core, but the
main reason it exists is for userspace software that interacts with
drm to make decisions. Move the attribute to DRM.
This also fixes a compilation failure when compiled without
CONFIG_VIDEO on sparc.
Suggested-by: Manivannan Sadhasivam <mani@...nel.org>
Reported-by: Stephen Rothwell <sfr@...b.auug.org.au>
Closes: https://lore.kernel.org/linux-next/20250718224118.5b3f22b0@canb.auug.org.au/
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
Documentation/ABI/testing/sysfs-bus-pci | 9 -----
Documentation/ABI/testing/sysfs-class-drm | 8 ++++
drivers/gpu/drm/drm_sysfs.c | 41 +++++++++++++++++++++
drivers/pci/pci-sysfs.c | 45 -----------------------
4 files changed, 49 insertions(+), 54 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-class-drm
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index a2c74d4ebeadd..69f952fffec72 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -612,12 +612,3 @@ Description:
# ls doe_features
0001:01 0001:02 doe_discovery
-
-What: /sys/bus/pci/devices/.../boot_display
-Date: October 2025
-Contact: Linux PCI developers <linux-pci@...r.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/Documentation/ABI/testing/sysfs-class-drm b/Documentation/ABI/testing/sysfs-class-drm
new file mode 100644
index 0000000000000..536820afca05b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-drm
@@ -0,0 +1,8 @@
+What: /sys/class/drm/.../boot_display
+Date: October 2025
+Contact: Linux DRI developers <dri-devel@...r.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 60c1f26edb6fa..1bc2e6abaa1a9 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;
}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6ccd65f5b1051..b3fb6024e0ba7 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -680,13 +680,6 @@ const struct attribute_group *pcibus_groups[] = {
NULL,
};
-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 ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -1059,37 +1052,6 @@ void pci_remove_legacy_files(struct pci_bus *b)
}
#endif /* HAVE_PCI_LEGACY */
-/**
- * pci_create_boot_display_file - create "boot_display"
- * @pdev: dev in question
- *
- * Create "boot_display" in sysfs for the PCI device @pdev if it is the
- * boot display device.
- */
-static int pci_create_boot_display_file(struct pci_dev *pdev)
-{
-#ifdef CONFIG_VIDEO
- if (video_is_primary_device(&pdev->dev))
- return sysfs_create_file(&pdev->dev.kobj, &dev_attr_boot_display.attr);
-#endif
- return 0;
-}
-
-/**
- * pci_remove_boot_display_file - remove "boot_display"
- * @pdev: dev in question
- *
- * Remove "boot_display" in sysfs for the PCI device @pdev if it is the
- * boot display device.
- */
-static void pci_remove_boot_display_file(struct pci_dev *pdev)
-{
-#ifdef CONFIG_VIDEO
- if (video_is_primary_device(&pdev->dev))
- sysfs_remove_file(&pdev->dev.kobj, &dev_attr_boot_display.attr);
-#endif
-}
-
#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)
/**
* pci_mmap_resource - map a PCI resource into user memory space
@@ -1693,15 +1655,9 @@ static const struct attribute_group pci_dev_resource_resize_group = {
int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
{
- int retval;
-
if (!sysfs_initialized)
return -EACCES;
- retval = pci_create_boot_display_file(pdev);
- if (retval)
- return retval;
-
return pci_create_resource_files(pdev);
}
@@ -1716,7 +1672,6 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
if (!sysfs_initialized)
return;
- pci_remove_boot_display_file(pdev);
pci_remove_resource_files(pdev);
}
--
2.43.0
Powered by blists - more mailing lists