]> www.infradead.org Git - users/hch/misc.git/commitdiff
PCI/VGA: Replace vga_is_firmware_default() with a screen info check
authorMario Limonciello (AMD) <superm1@kernel.org>
Mon, 11 Aug 2025 16:26:04 +0000 (11:26 -0500)
committerMario Limonciello (AMD) <superm1@kernel.org>
Wed, 10 Sep 2025 14:35:33 +0000 (09:35 -0500)
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>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20250811162606.587759-3-superm1@kernel.org
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
drivers/pci/vgaarb.c

index 78748e8d2dbae6e5d631ca97c9cae860e98a9c06..b58f94ee4891624c4923987246eb2b3112bfb05c 100644 (file)
@@ -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)