fbdev/hyperv_fb: Remove firmware framebuffers with aperture helpers
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 3 Jan 2024 10:15:10 +0000 (11:15 +0100)
committerHelge Deller <deller@gmx.de>
Fri, 12 Jan 2024 11:38:37 +0000 (12:38 +0100)
Replace use of screen_info state with the correct interfaces from
the aperture helpers. The state is only for architecture and firmware
code. It is not guaranteed to contain valid data. Drivers are thus
not allowed to use it.

For removing conflicting firmware framebuffers, there are aperture
helpers. Hence replace screen_info with the correct functions that will
remove conflicting framebuffers for the hypervfb driver. For GEN1 PCI
devices, the driver reads the framebuffer base and size from the PCI
BAR, and uses the range for removing the firmware framebuffer. For
GEN2 VMBUS devices no range can be detected, so the driver clears all
firmware framebuffers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/hyperv_fb.c

index 6a29d2594b914c915c791a1d7153c14e68611144..09b18a8cddeed6310727ac7b06d2c7c94f879d5f 100644 (file)
@@ -975,7 +975,8 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
        struct pci_dev *pdev  = NULL;
        void __iomem *fb_virt;
        int gen2vm = efi_enabled(EFI_BOOT);
-       resource_size_t base, size;
+       resource_size_t base = 0;
+       resource_size_t size = 0;
        phys_addr_t paddr;
        int ret;
 
@@ -1010,9 +1011,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
                        goto getmem_done;
                }
                pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
-       } else if (IS_ENABLED(CONFIG_SYSFB)) {
-               base = screen_info.lfb_base;
-               size = screen_info.lfb_size;
        } else {
                goto err1;
        }
@@ -1056,7 +1054,10 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
        info->screen_size = dio_fb_size;
 
 getmem_done:
-       aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME);
+       if (base && size)
+               aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME);
+       else
+               aperture_remove_all_conflicting_devices(KBUILD_MODNAME);
 
        if (!gen2vm) {
                pci_dev_put(pdev);