[PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check

Mario Limonciello (AMD) posted 4 patches 6 months ago
[PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Mario Limonciello (AMD) 6 months ago
vga_is_firmware_default() checks firmware resources to find the owner
framebuffer resources to find the firmware PCI device.  This is an
open coded implementation of screen_info_pci_dev().  Switch to using
screen_info_pci_dev() instead.

Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
v10:
 * Rebase on 6.17-rc1
---
 drivers/pci/vgaarb.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 78748e8d2dbae..b58f94ee48916 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -556,34 +556,13 @@ EXPORT_SYMBOL(vga_put);
 
 static bool vga_is_firmware_default(struct pci_dev *pdev)
 {
-#if defined(CONFIG_X86)
-	u64 base = screen_info.lfb_base;
-	u64 size = screen_info.lfb_size;
-	struct resource *r;
-	u64 limit;
+#ifdef CONFIG_SCREEN_INFO
+	struct screen_info *si = &screen_info;
 
-	/* Select the device owning the boot framebuffer if there is one */
-
-	if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
-		base |= (u64)screen_info.ext_lfb_base << 32;
-
-	limit = base + size;
-
-	/* Does firmware framebuffer belong to us? */
-	pci_dev_for_each_resource(pdev, r) {
-		if (resource_type(r) != IORESOURCE_MEM)
-			continue;
-
-		if (!r->start || !r->end)
-			continue;
-
-		if (base < r->start || limit >= r->end)
-			continue;
-
-		return true;
-	}
-#endif
+	return pdev == screen_info_pci_dev(si);
+#else
 	return false;
+#endif
 }
 
 static bool vga_arb_integrated_gpu(struct device *dev)
-- 
2.43.0
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Eric Biggers 3 months, 4 weeks ago
Hi,

On Mon, Aug 11, 2025 at 11:26:04AM -0500, Mario Limonciello (AMD) wrote:
> vga_is_firmware_default() checks firmware resources to find the owner
> framebuffer resources to find the firmware PCI device.  This is an
> open coded implementation of screen_info_pci_dev().  Switch to using
> screen_info_pci_dev() instead.
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>

I'm getting a black screen on boot on mainline, and it bisected to this
commit.  Reverting this commit fixed it.

Please revert.

- Eric
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Bjorn Helgaas 3 months, 3 weeks ago
[+cc regressions]

On Sun, Oct 12, 2025 at 11:23:02AM -0700, Eric Biggers wrote:
> On Mon, Aug 11, 2025 at 11:26:04AM -0500, Mario Limonciello (AMD) wrote:
> > vga_is_firmware_default() checks firmware resources to find the owner
> > framebuffer resources to find the firmware PCI device.  This is an
> > open coded implementation of screen_info_pci_dev().  Switch to using
> > screen_info_pci_dev() instead.
> > 
> > Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> > Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> 
> I'm getting a black screen on boot on mainline, and it bisected to this
> commit.  Reverting this commit fixed it.

#regzbot introduced: 337bf13aa9dd ("PCI/VGA: Replace vga_is_firmware_default() with a screen info check")
#regzbot link: https://lore.kernel.org/r/20251013154441.1000875-1-superm1@kernel.org
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Bjorn Helgaas 3 months, 1 week ago
On Mon, Oct 13, 2025 at 03:55:31PM -0500, Bjorn Helgaas wrote:
> On Sun, Oct 12, 2025 at 11:23:02AM -0700, Eric Biggers wrote:
> > On Mon, Aug 11, 2025 at 11:26:04AM -0500, Mario Limonciello (AMD) wrote:
> > > vga_is_firmware_default() checks firmware resources to find the owner
> > > framebuffer resources to find the firmware PCI device.  This is an
> > > open coded implementation of screen_info_pci_dev().  Switch to using
> > > screen_info_pci_dev() instead.
> > > 
> > > Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> > > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> > > Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > 
> > I'm getting a black screen on boot on mainline, and it bisected to this
> > commit.  Reverting this commit fixed it.
> 
> #regzbot introduced: 337bf13aa9dd ("PCI/VGA: Replace vga_is_firmware_default() with a screen info check")
> #regzbot link: https://lore.kernel.org/r/20251013154441.1000875-1-superm1@kernel.org

#regzbot fix: a78835b86a44 ("PCI/VGA: Select SCREEN_INFO on X86")
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Mario Limonciello 3 months, 4 weeks ago

On 10/12/25 1:23 PM, Eric Biggers wrote:
> Hi,
> 
> On Mon, Aug 11, 2025 at 11:26:04AM -0500, Mario Limonciello (AMD) wrote:
>> vga_is_firmware_default() checks firmware resources to find the owner
>> framebuffer resources to find the firmware PCI device.  This is an
>> open coded implementation of screen_info_pci_dev().  Switch to using
>> screen_info_pci_dev() instead.
>>
>> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> 
> I'm getting a black screen on boot on mainline, and it bisected to this
> commit.  Reverting this commit fixed it.
> 
> Please revert.
> 
> - Eric

Can you please share more information about your issue before we jump 
straight into a revert?  What kind of hardware do you have?  Perhaps a 
kernel log from mainline and another from mainline with the revert could 
help identify what's going on?

A revert might be the right solution, but I would rather fix the issue 
if it's plausible to do so.
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Eric Biggers 3 months, 4 weeks ago
On Sun, Oct 12, 2025 at 01:37:33PM -0500, Mario Limonciello wrote:
> 
> 
> On 10/12/25 1:23 PM, Eric Biggers wrote:
> > Hi,
> > 
> > On Mon, Aug 11, 2025 at 11:26:04AM -0500, Mario Limonciello (AMD) wrote:
> > > vga_is_firmware_default() checks firmware resources to find the owner
> > > framebuffer resources to find the firmware PCI device.  This is an
> > > open coded implementation of screen_info_pci_dev().  Switch to using
> > > screen_info_pci_dev() instead.
> > > 
> > > Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> > > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> > > Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> > 
> > I'm getting a black screen on boot on mainline, and it bisected to this
> > commit.  Reverting this commit fixed it.
> > 
> > Please revert.
> > 
> > - Eric
> 
> Can you please share more information about your issue before we jump
> straight into a revert?  What kind of hardware do you have?  Perhaps a
> kernel log from mainline and another from mainline with the revert could
> help identify what's going on?
> 
> A revert might be the right solution, but I would rather fix the issue if
> it's plausible to do so.

Relevant hardware is:
    AMD Ryzen 9 9950X 16-Core Processor
    Radeon RX 9070

The following message appears in the good log but not the bad log:

    fbcon: amdgpudrmfb (fb0) is primary device

I don't have CONFIG_SCREEN_INFO enabled, so the commit changed
vga_is_firmware_default() to always return false.

If DRM_AMDGPU depends on SCREEN_INFO now, it needs to select it.

- Eric
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Mario Limonciello 3 months, 4 weeks ago

On 10/12/25 1:47 PM, Eric Biggers wrote:
> On Sun, Oct 12, 2025 at 01:37:33PM -0500, Mario Limonciello wrote:
>>
>>
>> On 10/12/25 1:23 PM, Eric Biggers wrote:
>>> Hi,
>>>
>>> On Mon, Aug 11, 2025 at 11:26:04AM -0500, Mario Limonciello (AMD) wrote:
>>>> vga_is_firmware_default() checks firmware resources to find the owner
>>>> framebuffer resources to find the firmware PCI device.  This is an
>>>> open coded implementation of screen_info_pci_dev().  Switch to using
>>>> screen_info_pci_dev() instead.
>>>>
>>>> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>>>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
>>>> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
>>>
>>> I'm getting a black screen on boot on mainline, and it bisected to this
>>> commit.  Reverting this commit fixed it.
>>>
>>> Please revert.
>>>
>>> - Eric
>>
>> Can you please share more information about your issue before we jump
>> straight into a revert?  What kind of hardware do you have?  Perhaps a
>> kernel log from mainline and another from mainline with the revert could
>> help identify what's going on?
>>
>> A revert might be the right solution, but I would rather fix the issue if
>> it's plausible to do so.
> 
> Relevant hardware is:
>      AMD Ryzen 9 9950X 16-Core Processor
>      Radeon RX 9070
> 
> The following message appears in the good log but not the bad log:
> 
>      fbcon: amdgpudrmfb (fb0) is primary device
> 
> I don't have CONFIG_SCREEN_INFO enabled, so the commit changed
> vga_is_firmware_default() to always return false.

Thanks, that definitely explains it.

> 
> If DRM_AMDGPU depends on SCREEN_INFO now, it needs to select it.
> 
> - Eric

Well the question now is which driver should actually select it.

Although it manifested for you in amdgpu, I don't think this is going to 
be an amdgpu unique issue.

Maybe this:

diff --git a/drivers/video/fbdev/core/Kconfig 
b/drivers/video/fbdev/core/Kconfig
index 006638eefa41..ce2544924b0e 100644
--- a/drivers/video/fbdev/core/Kconfig
+++ b/drivers/video/fbdev/core/Kconfig
@@ -5,6 +5,7 @@

  config FB_CORE
         select VIDEO
+       select SCREEN_INFO
         tristate

  config FB_NOTIFY
Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Thomas Zimmermann 3 months, 4 weeks ago
Hi Mario,

thanks for handling this report quickly.

Am 12.10.25 um 21:06 schrieb Mario Limonciello:
[...]
>> I don't have CONFIG_SCREEN_INFO enabled, so the commit changed
>> vga_is_firmware_default() to always return false.
>
> Thanks, that definitely explains it.
>
>>
>> If DRM_AMDGPU depends on SCREEN_INFO now, it needs to select it.
>>
>> - Eric
>
> Well the question now is which driver should actually select it.
>
> Although it manifested for you in amdgpu, I don't think this is going 
> to be an amdgpu unique issue.
>
> Maybe this:
>
> diff --git a/drivers/video/fbdev/core/Kconfig 
> b/drivers/video/fbdev/core/Kconfig
> index 006638eefa41..ce2544924b0e 100644
> --- a/drivers/video/fbdev/core/Kconfig
> +++ b/drivers/video/fbdev/core/Kconfig
> @@ -5,6 +5,7 @@
>
>  config FB_CORE
>         select VIDEO
> +       select SCREEN_INFO

Let's select it from CONFIG_VGA_ARB. This will restore the old behavior 
for x86. The else branch for CONFIG_SCREEN_INFO can then go away.

Best regards
Thomas

> tristate
>
>  config FB_NOTIFY

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


Re: [PATCH v10 2/4] PCI/VGA: Replace vga_is_firmware_default() with a screen info check
Posted by Thomas Zimmermann 5 months ago

Am 11.08.25 um 18:26 schrieb Mario Limonciello (AMD):
> vga_is_firmware_default() checks firmware resources to find the owner
> framebuffer resources to find the firmware PCI device.  This is an
> open coded implementation of screen_info_pci_dev().  Switch to using
> screen_info_pci_dev() instead.
>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
> v10:
>   * Rebase on 6.17-rc1
> ---
>   drivers/pci/vgaarb.c | 31 +++++--------------------------
>   1 file changed, 5 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> index 78748e8d2dbae..b58f94ee48916 100644
> --- a/drivers/pci/vgaarb.c
> +++ b/drivers/pci/vgaarb.c
> @@ -556,34 +556,13 @@ EXPORT_SYMBOL(vga_put);
>   
>   static bool vga_is_firmware_default(struct pci_dev *pdev)
>   {
> -#if defined(CONFIG_X86)
> -	u64 base = screen_info.lfb_base;
> -	u64 size = screen_info.lfb_size;
> -	struct resource *r;
> -	u64 limit;
> +#ifdef CONFIG_SCREEN_INFO
> +	struct screen_info *si = &screen_info;
>   
> -	/* Select the device owning the boot framebuffer if there is one */
> -
> -	if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
> -		base |= (u64)screen_info.ext_lfb_base << 32;
> -
> -	limit = base + size;
> -
> -	/* Does firmware framebuffer belong to us? */
> -	pci_dev_for_each_resource(pdev, r) {
> -		if (resource_type(r) != IORESOURCE_MEM)
> -			continue;
> -
> -		if (!r->start || !r->end)
> -			continue;
> -
> -		if (base < r->start || limit >= r->end)
> -			continue;
> -
> -		return true;
> -	}
> -#endif
> +	return pdev == screen_info_pci_dev(si);
> +#else
>   	return false;
> +#endif
>   }
>   
>   static bool vga_arb_integrated_gpu(struct device *dev)

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)