linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] Alternative approach for boot_display visibility
@ 2025-07-22  4:10 Mario Limonciello
  2025-07-22  4:10 ` [PATCH v5 1/2] fbcon: Stop using screen_info_pci_dev() Mario Limonciello
  2025-07-22  4:10 ` [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation Mario Limonciello
  0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-07-22  4:10 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

From: Mario Limonciello <mario.limonciello@amd.com>

The past few days there have been various discussions about what to do
with the boot_display sysfs file so that it doesn't need to be made so
late in startup.

Bjorn had an aha moment pointing out that there is no reason to "find"
the PCI device using screen_info_pci_dev() because the device is already
known.  Instead we just need to check if it has the screen resources.

This series adjusts the boot_display behavior to use that and then convert
boot_display into a static sysfs file that can be loaded when the device
is created without needing to change visibility.

This is an ALTERNATIVE to moving it to DRM, which is what v4 does [1].
Either solution can be picked up depending upon the collective decision
whether to keep boot_display file in PCI core or DRM core.

Link: https://lore.kernel.org/linux-pci/20250721185726.1264909-1-superm1@kernel.org/T/#me4356b3a172cbdafe83393bedce10f17a86e0da7

Mario Limonciello (2):
  fbcon: Stop using screen_info_pci_dev()
  PCI: Adjust visibility of boot_display attribute instead of creation

 arch/x86/video/video-common.c | 12 ++++++--
 drivers/pci/pci-sysfs.c       | 58 ++++++++++++-----------------------
 2 files changed, 30 insertions(+), 40 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v5 1/2] fbcon: Stop using screen_info_pci_dev()
  2025-07-22  4:10 [PATCH v5 0/2] Alternative approach for boot_display visibility Mario Limonciello
@ 2025-07-22  4:10 ` Mario Limonciello
  2025-07-22  4:10 ` [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation Mario Limonciello
  1 sibling, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-07-22  4:10 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

From: Mario Limonciello <mario.limonciello@amd.com>

screen_info_pci_dev() relies upon resources being set up for devices
before walking and thus isn't a good candidate for video_is_primary_device()
when called as part of PCI device initialization.

The device argument passed to video_is_primary_device() already has the
necessary information.  Check that directly instead.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 arch/x86/video/video-common.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/x86/video/video-common.c b/arch/x86/video/video-common.c
index 4bbfffec4b640..e0aeee99bc99e 100644
--- a/arch/x86/video/video-common.c
+++ b/arch/x86/video/video-common.c
@@ -30,6 +30,8 @@ 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;
 
@@ -45,8 +47,14 @@ bool video_is_primary_device(struct device *dev)
 		return true;
 
 #ifdef CONFIG_SCREEN_INFO
-	if (pdev == screen_info_pci_dev(si))
-		return true;
+	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;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation
  2025-07-22  4:10 [PATCH v5 0/2] Alternative approach for boot_display visibility Mario Limonciello
  2025-07-22  4:10 ` [PATCH v5 1/2] fbcon: Stop using screen_info_pci_dev() Mario Limonciello
@ 2025-07-22  4:10 ` Mario Limonciello
  1 sibling, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-07-22  4:10 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, Stephen Rothwell

From: Mario Limonciello <mario.limonciello@amd.com>

There is a desire to avoid creating new sysfs files late, so instead
of dynamically deciding to create the boot_display attribute, make
it static.

This also fixes a compilation failure when compiled without
CONFIG_VIDEO on sparc.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/linux-next/20250718224118.5b3f22b0@canb.auug.org.au/
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5
 * Fixups for comma and CONFIG_VIDEO
 * Drop sysfs_update_group() as it's no longer needed
 * Drop pointers in pci_boot_display_visible()
v3:
 * Move to pci_sysfs_init()
v2:
 * Change to sysfs_update_group() instead
---
 drivers/pci/pci-sysfs.c | 58 ++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 38 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6b1a0ae254d3a..f5d98795a12fe 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1059,37 +1059,6 @@ void pci_remove_legacy_files(struct pci_bus *b)
 }
 #endif /* HAVE_PCI_LEGACY */
 
-/**
- * pci_create_boot_display_file - create a file in sysfs for @dev
- * @pdev: dev in question
- *
- * Creates a file `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 the boot display file for @dev
- * @pdev: dev in question
- *
- * Removes the file `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
@@ -1691,17 +1660,30 @@ static const struct attribute_group pci_dev_resource_resize_group = {
 	.is_visible = resource_resize_is_visible,
 };
 
-int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
+static struct attribute *pci_display_attrs[] = {
+	&dev_attr_boot_display.attr,
+	NULL
+};
+
+static umode_t pci_boot_display_visible(struct kobject *kobj,
+					struct attribute *a, int n)
 {
-	int retval;
+	if (video_is_primary_device(kobj_to_dev(kobj)))
+		return a->mode;
 
+	return 0;
+}
+
+static const struct attribute_group pci_display_attr_group = {
+	.attrs = pci_display_attrs,
+	.is_visible = pci_boot_display_visible,
+};
+
+int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
+{
 	if (!sysfs_initialized)
 		return -EACCES;
 
-	retval = pci_create_boot_display_file(pdev);
-	if (retval)
-		return retval;
-
 	return pci_create_resource_files(pdev);
 }
 
@@ -1716,7 +1698,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);
 }
 
@@ -1845,6 +1826,7 @@ static const struct attribute_group pcie_dev_attr_group = {
 
 const struct attribute_group *pci_dev_attr_groups[] = {
 	&pci_dev_attr_group,
+	&pci_display_attr_group,
 	&pci_dev_hp_attr_group,
 #ifdef CONFIG_PCI_IOV
 	&sriov_pf_dev_attr_group,
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-22  4:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22  4:10 [PATCH v5 0/2] Alternative approach for boot_display visibility Mario Limonciello
2025-07-22  4:10 ` [PATCH v5 1/2] fbcon: Stop using screen_info_pci_dev() Mario Limonciello
2025-07-22  4:10 ` [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation 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).