Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/aperture: Convert drivers to aperture interfaces

Mass-convert all drivers from FB helpers to aperture interfaces. No
functional changes besides checking for returned errno codes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210412131043.5787-3-tzimmermann@suse.de

+67 -56
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 23 23 */ 24 24 25 25 #include <drm/amdgpu_drm.h> 26 + #include <drm/drm_aperture.h> 26 27 #include <drm/drm_drv.h> 27 28 #include <drm/drm_gem.h> 28 29 #include <drm/drm_vblank.h> ··· 1197 1196 #endif 1198 1197 1199 1198 /* Get rid of things like offb */ 1200 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "amdgpudrmfb"); 1199 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "amdgpudrmfb"); 1201 1200 if (ret) 1202 1201 return ret; 1203 1202
+2 -3
drivers/gpu/drm/armada/armada_drv.c
··· 9 9 #include <linux/of_graph.h> 10 10 #include <linux/platform_device.h> 11 11 12 + #include <drm/drm_aperture.h> 12 13 #include <drm/drm_atomic_helper.h> 13 14 #include <drm/drm_drv.h> 14 15 #include <drm/drm_ioctl.h> ··· 95 94 } 96 95 97 96 /* Remove early framebuffers */ 98 - ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, 99 - "armada-drm-fb", 100 - false); 97 + ret = drm_aperture_remove_framebuffers(false, "armada-drm-fb"); 101 98 if (ret) { 102 99 dev_err(dev, "[" DRM_NAME ":%s] can't kick out simple-fb: %d\n", 103 100 __func__, ret);
+10 -13
drivers/gpu/drm/ast/ast_drv.c
··· 30 30 #include <linux/module.h> 31 31 #include <linux/pci.h> 32 32 33 + #include <drm/drm_aperture.h> 33 34 #include <drm/drm_atomic_helper.h> 34 35 #include <drm/drm_crtc_helper.h> 35 36 #include <drm/drm_drv.h> 36 - #include <drm/drm_fb_helper.h> 37 37 #include <drm/drm_gem_vram_helper.h> 38 38 #include <drm/drm_probe_helper.h> 39 39 ··· 89 89 90 90 MODULE_DEVICE_TABLE(pci, ast_pciidlist); 91 91 92 - static void ast_kick_out_firmware_fb(struct pci_dev *pdev) 92 + static int ast_remove_conflicting_framebuffers(struct pci_dev *pdev) 93 93 { 94 - struct apertures_struct *ap; 95 94 bool primary = false; 95 + resource_size_t base, size; 96 96 97 - ap = alloc_apertures(1); 98 - if (!ap) 99 - return; 100 - 101 - ap->ranges[0].base = pci_resource_start(pdev, 0); 102 - ap->ranges[0].size = pci_resource_len(pdev, 0); 103 - 97 + base = pci_resource_start(pdev, 0); 98 + size = pci_resource_len(pdev, 0); 104 99 #ifdef CONFIG_X86 105 100 primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; 106 101 #endif 107 - drm_fb_helper_remove_conflicting_framebuffers(ap, "astdrmfb", primary); 108 - kfree(ap); 102 + 103 + return drm_aperture_remove_conflicting_framebuffers(base, size, primary, "astdrmfb"); 109 104 } 110 105 111 106 static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ··· 109 114 struct drm_device *dev; 110 115 int ret; 111 116 112 - ast_kick_out_firmware_fb(pdev); 117 + ret = ast_remove_conflicting_framebuffers(pdev); 118 + if (ret) 119 + return ret; 113 120 114 121 ret = pcim_enable_device(pdev); 115 122 if (ret)
+2 -1
drivers/gpu/drm/bochs/bochs_drv.c
··· 6 6 #include <linux/pci.h> 7 7 8 8 #include <drm/drm_drv.h> 9 + #include <drm/drm_aperture.h> 9 10 #include <drm/drm_atomic_helper.h> 10 11 #include <drm/drm_managed.h> 11 12 ··· 110 109 return -ENOMEM; 111 110 } 112 111 113 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "bochsdrmfb"); 112 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "bochsdrmfb"); 114 113 if (ret) 115 114 return ret; 116 115
+2 -2
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/pci.h> 16 16 17 + #include <drm/drm_aperture.h> 17 18 #include <drm/drm_atomic_helper.h> 18 19 #include <drm/drm_drv.h> 19 20 #include <drm/drm_gem_framebuffer_helper.h> ··· 314 313 struct drm_device *dev; 315 314 int ret; 316 315 317 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 318 - "hibmcdrmfb"); 316 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "hibmcdrmfb"); 319 317 if (ret) 320 318 return ret; 321 319
+2 -1
drivers/gpu/drm/i915/i915_drv.c
··· 40 40 #include <linux/vt.h> 41 41 #include <acpi/video.h> 42 42 43 + #include <drm/drm_aperture.h> 43 44 #include <drm/drm_atomic_helper.h> 44 45 #include <drm/drm_ioctl.h> 45 46 #include <drm/drm_irq.h> ··· 558 557 if (ret) 559 558 goto err_perf; 560 559 561 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "inteldrmfb"); 560 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "inteldrmfb"); 562 561 if (ret) 563 562 goto err_ggtt; 564 563
+8 -19
drivers/gpu/drm/meson/meson_drv.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/soc/amlogic/meson-canvas.h> 17 17 18 + #include <drm/drm_aperture.h> 18 19 #include <drm/drm_atomic_helper.h> 19 20 #include <drm/drm_drv.h> 20 21 #include <drm/drm_fb_helper.h> ··· 157 156 writel_relaxed(value, priv->io_base + _REG(VPU_WRARB_MODE_L2C1)); 158 157 } 159 158 160 - static void meson_remove_framebuffers(void) 161 - { 162 - struct apertures_struct *ap; 163 - 164 - ap = alloc_apertures(1); 165 - if (!ap) 166 - return; 167 - 168 - /* The framebuffer can be located anywhere in RAM */ 169 - ap->ranges[0].base = 0; 170 - ap->ranges[0].size = ~0; 171 - 172 - drm_fb_helper_remove_conflicting_framebuffers(ap, "meson-drm-fb", 173 - false); 174 - kfree(ap); 175 - } 176 - 177 159 struct meson_drm_soc_attr { 178 160 struct meson_drm_soc_limits limits; 179 161 const struct soc_device_attribute *attrs; ··· 281 297 } 282 298 } 283 299 284 - /* Remove early framebuffers (ie. simplefb) */ 285 - meson_remove_framebuffers(); 300 + /* 301 + * Remove early framebuffers (ie. simplefb). The framebuffer can be 302 + * located anywhere in RAM 303 + */ 304 + ret = drm_aperture_remove_framebuffers(false, "meson-drm-fb"); 305 + if (ret) 306 + goto free_drm; 286 307 287 308 ret = drmm_mode_config_init(drm); 288 309 if (ret)
+4 -1
drivers/gpu/drm/mgag200/mgag200_drv.c
··· 11 11 #include <linux/pci.h> 12 12 #include <linux/vmalloc.h> 13 13 14 + #include <drm/drm_aperture.h> 14 15 #include <drm/drm_drv.h> 15 16 #include <drm/drm_file.h> 16 17 #include <drm/drm_ioctl.h> ··· 342 341 struct drm_device *dev; 343 342 int ret; 344 343 345 - drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "mgag200drmfb"); 344 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "mgag200drmfb"); 345 + if (ret) 346 + return ret; 346 347 347 348 ret = pcim_enable_device(pdev); 348 349 if (ret)
+4 -1
drivers/gpu/drm/msm/msm_fbdev.c
··· 4 4 * Author: Rob Clark <robdclark@gmail.com> 5 5 */ 6 6 7 + #include <drm/drm_aperture.h> 7 8 #include <drm/drm_crtc.h> 8 9 #include <drm/drm_fb_helper.h> 9 10 #include <drm/drm_fourcc.h> ··· 169 168 } 170 169 171 170 /* the fw fb could be anywhere in memory */ 172 - drm_fb_helper_remove_conflicting_framebuffers(NULL, "msm", false); 171 + ret = drm_aperture_remove_framebuffers(false, "msm"); 172 + if (ret) 173 + goto fini; 173 174 174 175 ret = drm_fb_helper_initial_config(helper, 32); 175 176 if (ret)
+2 -1
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 30 30 #include <linux/vga_switcheroo.h> 31 31 #include <linux/mmu_notifier.h> 32 32 33 + #include <drm/drm_aperture.h> 33 34 #include <drm/drm_crtc_helper.h> 34 35 #include <drm/drm_gem_ttm_helper.h> 35 36 #include <drm/drm_ioctl.h> ··· 738 737 nvkm_device_del(&device); 739 738 740 739 /* Remove conflicting drivers (vesafb, efifb etc). */ 741 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "nouveaufb"); 740 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "nouveaufb"); 742 741 if (ret) 743 742 return ret; 744 743
+4 -1
drivers/gpu/drm/qxl/qxl_drv.c
··· 29 29 */ 30 30 31 31 #include "qxl_drv.h" 32 + 32 33 #include <linux/console.h> 33 34 #include <linux/module.h> 34 35 #include <linux/pci.h> 36 + #include <linux/vgaarb.h> 35 37 36 38 #include <drm/drm.h> 39 + #include <drm/drm_aperture.h> 37 40 #include <drm/drm_atomic_helper.h> 38 41 #include <drm/drm_drv.h> 39 42 #include <drm/drm_file.h> ··· 96 93 if (ret) 97 94 return ret; 98 95 99 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "qxl"); 96 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "qxl"); 100 97 if (ret) 101 98 goto disable_pci; 102 99
+2 -1
drivers/gpu/drm/radeon/radeon_drv.c
··· 38 38 #include <linux/mmu_notifier.h> 39 39 #include <linux/pci.h> 40 40 41 + #include <drm/drm_aperture.h> 41 42 #include <drm/drm_agpsupport.h> 42 43 #include <drm/drm_crtc_helper.h> 43 44 #include <drm/drm_drv.h> ··· 331 330 return -EPROBE_DEFER; 332 331 333 332 /* Get rid of things like offb */ 334 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "radeondrmfb"); 333 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "radeondrmfb"); 335 334 if (ret) 336 335 return ret; 337 336
+4 -1
drivers/gpu/drm/sun4i/sun4i_drv.c
··· 13 13 #include <linux/of_reserved_mem.h> 14 14 #include <linux/platform_device.h> 15 15 16 + #include <drm/drm_aperture.h> 16 17 #include <drm/drm_atomic_helper.h> 17 18 #include <drm/drm_drv.h> 18 19 #include <drm/drm_fb_cma_helper.h> ··· 100 99 drm->irq_enabled = true; 101 100 102 101 /* Remove early framebuffers (ie. simplefb) */ 103 - drm_fb_helper_remove_conflicting_framebuffers(NULL, "sun4i-drm-fb", false); 102 + ret = drm_aperture_remove_framebuffers(false, "sun4i-drm-fb"); 103 + if (ret) 104 + goto cleanup_mode_config; 104 105 105 106 sun4i_framebuffer_init(drm); 106 107
+2 -2
drivers/gpu/drm/tegra/drm.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/platform_device.h> 13 13 14 + #include <drm/drm_aperture.h> 14 15 #include <drm/drm_atomic.h> 15 16 #include <drm/drm_atomic_helper.h> 16 17 #include <drm/drm_debugfs.h> ··· 1199 1198 1200 1199 drm_mode_config_reset(drm); 1201 1200 1202 - err = drm_fb_helper_remove_conflicting_framebuffers(NULL, "tegradrmfb", 1203 - false); 1201 + err = drm_aperture_remove_framebuffers(false, "tegradrmfb"); 1204 1202 if (err < 0) 1205 1203 goto hub; 1206 1204
+2 -1
drivers/gpu/drm/tiny/cirrus.c
··· 24 24 #include <video/cirrus.h> 25 25 #include <video/vga.h> 26 26 27 + #include <drm/drm_aperture.h> 27 28 #include <drm/drm_atomic_helper.h> 28 29 #include <drm/drm_atomic_state_helper.h> 29 30 #include <drm/drm_connector.h> ··· 550 549 struct cirrus_device *cirrus; 551 550 int ret; 552 551 553 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "cirrusdrmfb"); 552 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "cirrusdrmfb"); 554 553 if (ret) 555 554 return ret; 556 555
+2 -1
drivers/gpu/drm/vboxvideo/vbox_drv.c
··· 12 12 #include <linux/pci.h> 13 13 #include <linux/vt_kern.h> 14 14 15 + #include <drm/drm_aperture.h> 15 16 #include <drm/drm_crtc_helper.h> 16 17 #include <drm/drm_drv.h> 17 18 #include <drm/drm_fb_helper.h> ··· 43 42 if (!vbox_check_supported(VBE_DISPI_ID_HGSMI)) 44 43 return -ENODEV; 45 44 46 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "vboxvideodrmfb"); 45 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "vboxvideodrmfb"); 47 46 if (ret) 48 47 return ret; 49 48
+4 -1
drivers/gpu/drm/vc4/vc4_drv.c
··· 30 30 #include <linux/platform_device.h> 31 31 #include <linux/pm_runtime.h> 32 32 33 + #include <drm/drm_aperture.h> 33 34 #include <drm/drm_atomic_helper.h> 34 35 #include <drm/drm_drv.h> 35 36 #include <drm/drm_fb_cma_helper.h> ··· 267 266 if (ret) 268 267 goto unbind_all; 269 268 270 - drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false); 269 + ret = drm_aperture_remove_framebuffers(false, "vc4drmfb"); 270 + if (ret) 271 + goto unbind_all; 271 272 272 273 ret = vc4_kms_load(drm); 273 274 if (ret < 0)
+7 -3
drivers/gpu/drm/virtio/virtgpu_drv.c
··· 31 31 #include <linux/pci.h> 32 32 33 33 #include <drm/drm.h> 34 + #include <drm/drm_aperture.h> 34 35 #include <drm/drm_atomic_helper.h> 35 36 #include <drm/drm_drv.h> 36 37 #include <drm/drm_file.h> ··· 51 50 const char *pname = dev_name(&pdev->dev); 52 51 bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; 53 52 char unique[20]; 53 + int ret; 54 54 55 55 DRM_INFO("pci: %s detected at %s\n", 56 56 vga ? "virtio-vga" : "virtio-gpu-pci", 57 57 pname); 58 - if (vga) 59 - drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 60 - "virtiodrmfb"); 58 + if (vga) { 59 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "virtiodrmfb"); 60 + if (ret) 61 + return ret; 62 + } 61 63 62 64 /* 63 65 * Normally the drm_dev_set_unique() call is done by core DRM.
+2 -2
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
··· 31 31 #include <linux/pci.h> 32 32 #include <linux/mem_encrypt.h> 33 33 34 + #include <drm/drm_aperture.h> 34 35 #include <drm/drm_drv.h> 35 - #include <drm/drm_fb_helper.h> 36 36 #include <drm/drm_ioctl.h> 37 37 #include <drm/drm_sysfs.h> 38 38 #include <drm/ttm/ttm_bo_driver.h> ··· 1491 1491 struct vmw_private *vmw; 1492 1492 int ret; 1493 1493 1494 - ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "svgadrmfb"); 1494 + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "svgadrmfb"); 1495 1495 if (ret) 1496 1496 return ret; 1497 1497