mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <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" <mario.limonciello@amd.com>
Subject: [PATCH v5 1/2] fbcon: Stop using screen_info_pci_dev()
Date: Mon, 21 Jul 2025 23:10:50 -0500	[thread overview]
Message-ID: <20250722041051.3354121-2-superm1@kernel.org> (raw)
In-Reply-To: <20250722041051.3354121-1-superm1@kernel.org>

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


  reply	other threads:[~2025-07-22  4:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22  4:10 [PATCH v5 0/2] Alternative approach for boot_display visibility Mario Limonciello
2025-07-22  4:10 ` Mario Limonciello [this message]
2025-07-22  4:10 ` [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation 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=20250722041051.3354121-2-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=mario.limonciello@amd.com \
    --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

all inboxes | Powered by JetHome®