Commit 97c9bfe3 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/aperture: Pass DRM driver structure instead of driver name

Print the name of the DRM driver when taking over fbdev devices. Makes
the output to dmesg more consistent. Note that the driver name is only
used for printing a string to the kernel log. No UAPI is affected by this
change.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarNirmoy Das <nirmoy.das@amd.com>
Acked-by: Chen-Yu Tsai <wens@csie.org> # sun4i
Acked-by: Neil Armstrong <narmstrong@baylibre.com> # meson
Link: https://patchwork.freedesktop.org/patch/msgid/20210629135833.22679-1-tzimmermann@suse.de
parent 0ec187f6
...@@ -1263,7 +1263,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, ...@@ -1263,7 +1263,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
#endif #endif
/* Get rid of things like offb */ /* Get rid of things like offb */
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "amdgpudrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &amdgpu_kms_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -95,7 +95,7 @@ static int armada_drm_bind(struct device *dev) ...@@ -95,7 +95,7 @@ static int armada_drm_bind(struct device *dev)
} }
/* Remove early framebuffers */ /* Remove early framebuffers */
ret = drm_aperture_remove_framebuffers(false, "armada-drm-fb"); ret = drm_aperture_remove_framebuffers(false, &armada_drm_driver);
if (ret) { if (ret) {
dev_err(dev, "[" DRM_NAME ":%s] can't kick out simple-fb: %d\n", dev_err(dev, "[" DRM_NAME ":%s] can't kick out simple-fb: %d\n",
__func__, ret); __func__, ret);
......
...@@ -100,7 +100,7 @@ static int ast_remove_conflicting_framebuffers(struct pci_dev *pdev) ...@@ -100,7 +100,7 @@ static int ast_remove_conflicting_framebuffers(struct pci_dev *pdev)
primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif #endif
return drm_aperture_remove_conflicting_framebuffers(base, size, primary, "astdrmfb"); return drm_aperture_remove_conflicting_framebuffers(base, size, primary, &ast_driver);
} }
static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
......
...@@ -110,7 +110,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, ...@@ -110,7 +110,7 @@ static int bochs_pci_probe(struct pci_dev *pdev,
return -ENOMEM; return -ENOMEM;
} }
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "bochsdrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &bochs_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
* *
* .. code-block:: c * .. code-block:: c
* *
* static const struct drm_driver example_driver = {
* ...
* };
*
* static int remove_conflicting_framebuffers(struct pci_dev *pdev) * static int remove_conflicting_framebuffers(struct pci_dev *pdev)
* { * {
* bool primary = false; * bool primary = false;
...@@ -46,7 +50,7 @@ ...@@ -46,7 +50,7 @@
* #endif * #endif
* *
* return drm_aperture_remove_conflicting_framebuffers(base, size, primary, * return drm_aperture_remove_conflicting_framebuffers(base, size, primary,
* "example driver"); * &example_driver);
* } * }
* *
* static int probe(struct pci_dev *pdev) * static int probe(struct pci_dev *pdev)
...@@ -274,7 +278,7 @@ static void drm_aperture_detach_drivers(resource_size_t base, resource_size_t si ...@@ -274,7 +278,7 @@ static void drm_aperture_detach_drivers(resource_size_t base, resource_size_t si
* @base: the aperture's base address in physical memory * @base: the aperture's base address in physical memory
* @size: aperture size in bytes * @size: aperture size in bytes
* @primary: also kick vga16fb if present * @primary: also kick vga16fb if present
* @name: requesting driver name * @req_driver: requesting DRM driver
* *
* This function removes graphics device drivers which use memory range described by * This function removes graphics device drivers which use memory range described by
* @base and @size. * @base and @size.
...@@ -283,7 +287,7 @@ static void drm_aperture_detach_drivers(resource_size_t base, resource_size_t si ...@@ -283,7 +287,7 @@ static void drm_aperture_detach_drivers(resource_size_t base, resource_size_t si
* 0 on success, or a negative errno code otherwise * 0 on success, or a negative errno code otherwise
*/ */
int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size, int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size,
bool primary, const char *name) bool primary, const struct drm_driver *req_driver)
{ {
#if IS_REACHABLE(CONFIG_FB) #if IS_REACHABLE(CONFIG_FB)
struct apertures_struct *a; struct apertures_struct *a;
...@@ -296,7 +300,7 @@ int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_ ...@@ -296,7 +300,7 @@ int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_
a->ranges[0].base = base; a->ranges[0].base = base;
a->ranges[0].size = size; a->ranges[0].size = size;
ret = remove_conflicting_framebuffers(a, name, primary); ret = remove_conflicting_framebuffers(a, req_driver->name, primary);
kfree(a); kfree(a);
if (ret) if (ret)
...@@ -312,7 +316,7 @@ EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers); ...@@ -312,7 +316,7 @@ EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers);
/** /**
* drm_aperture_remove_conflicting_pci_framebuffers - remove existing framebuffers for PCI devices * drm_aperture_remove_conflicting_pci_framebuffers - remove existing framebuffers for PCI devices
* @pdev: PCI device * @pdev: PCI device
* @name: requesting driver name * @req_driver: requesting DRM driver
* *
* This function removes graphics device drivers using memory range configured * This function removes graphics device drivers using memory range configured
* for any of @pdev's memory bars. The function assumes that PCI device with * for any of @pdev's memory bars. The function assumes that PCI device with
...@@ -321,7 +325,8 @@ EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers); ...@@ -321,7 +325,8 @@ EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers);
* Returns: * Returns:
* 0 on success, or a negative errno code otherwise * 0 on success, or a negative errno code otherwise
*/ */
int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const char *name) int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
const struct drm_driver *req_driver)
{ {
resource_size_t base, size; resource_size_t base, size;
int bar, ret = 0; int bar, ret = 0;
...@@ -339,7 +344,7 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const ...@@ -339,7 +344,7 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const
* otherwise the vga fbdev driver falls over. * otherwise the vga fbdev driver falls over.
*/ */
#if IS_REACHABLE(CONFIG_FB) #if IS_REACHABLE(CONFIG_FB)
ret = remove_conflicting_pci_framebuffers(pdev, name); ret = remove_conflicting_pci_framebuffers(pdev, req_driver->name);
#endif #endif
if (ret == 0) if (ret == 0)
ret = vga_remove_vgacon(pdev); ret = vga_remove_vgacon(pdev);
......
...@@ -313,7 +313,7 @@ static int hibmc_pci_probe(struct pci_dev *pdev, ...@@ -313,7 +313,7 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
struct drm_device *dev; struct drm_device *dev;
int ret; int ret;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "hibmcdrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &hibmc_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -82,7 +82,7 @@ static int hyperv_setup_gen1(struct hyperv_drm_device *hv) ...@@ -82,7 +82,7 @@ static int hyperv_setup_gen1(struct hyperv_drm_device *hv)
return -ENODEV; return -ENODEV;
} }
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "hypervdrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &hyperv_driver);
if (ret) { if (ret) {
drm_err(dev, "Not able to remove boot fb\n"); drm_err(dev, "Not able to remove boot fb\n");
return ret; return ret;
...@@ -127,7 +127,7 @@ static int hyperv_setup_gen2(struct hyperv_drm_device *hv, ...@@ -127,7 +127,7 @@ static int hyperv_setup_gen2(struct hyperv_drm_device *hv,
drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base,
screen_info.lfb_size, screen_info.lfb_size,
false, false,
"hypervdrmfb"); &hyperv_driver);
hv->fb_size = (unsigned long)hv->mmio_megabytes * 1024 * 1024; hv->fb_size = (unsigned long)hv->mmio_megabytes * 1024 * 1024;
......
...@@ -562,7 +562,7 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv) ...@@ -562,7 +562,7 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
if (ret) if (ret)
goto err_perf; goto err_perf;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "inteldrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, dev_priv->drm.driver);
if (ret) if (ret)
goto err_ggtt; goto err_ggtt;
......
...@@ -285,7 +285,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) ...@@ -285,7 +285,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
* Remove early framebuffers (ie. simplefb). The framebuffer can be * Remove early framebuffers (ie. simplefb). The framebuffer can be
* located anywhere in RAM * located anywhere in RAM
*/ */
ret = drm_aperture_remove_framebuffers(false, "meson-drm-fb"); ret = drm_aperture_remove_framebuffers(false, &meson_driver);
if (ret) if (ret)
goto free_drm; goto free_drm;
......
...@@ -342,7 +342,7 @@ mgag200_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -342,7 +342,7 @@ mgag200_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct drm_device *dev; struct drm_device *dev;
int ret; int ret;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "mgag200drmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &mgag200_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -169,7 +169,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) ...@@ -169,7 +169,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev)
} }
/* the fw fb could be anywhere in memory */ /* the fw fb could be anywhere in memory */
ret = drm_aperture_remove_framebuffers(false, "msm"); ret = drm_aperture_remove_framebuffers(false, dev->driver);
if (ret) if (ret)
goto fini; goto fini;
......
...@@ -736,7 +736,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev, ...@@ -736,7 +736,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
nvkm_device_del(&device); nvkm_device_del(&device);
/* Remove conflicting drivers (vesafb, efifb etc). */ /* Remove conflicting drivers (vesafb, efifb etc). */
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "nouveaufb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver_pci);
if (ret) if (ret)
return ret; return ret;
......
...@@ -95,7 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -95,7 +95,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
return ret; return ret;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "qxl"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &qxl_driver);
if (ret) if (ret)
goto disable_pci; goto disable_pci;
......
...@@ -330,7 +330,7 @@ static int radeon_pci_probe(struct pci_dev *pdev, ...@@ -330,7 +330,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
return -EPROBE_DEFER; return -EPROBE_DEFER;
/* Get rid of things like offb */ /* Get rid of things like offb */
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "radeondrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &kms_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -116,7 +116,7 @@ static int rockchip_drm_bind(struct device *dev) ...@@ -116,7 +116,7 @@ static int rockchip_drm_bind(struct device *dev)
int ret; int ret;
/* Remove existing drivers that may own the framebuffer memory. */ /* Remove existing drivers that may own the framebuffer memory. */
ret = drm_aperture_remove_framebuffers(false, "rockchip-drm-fb"); ret = drm_aperture_remove_framebuffers(false, &rockchip_drm_driver);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev, DRM_DEV_ERROR(dev,
"Failed to remove existing framebuffers - %d.\n", "Failed to remove existing framebuffers - %d.\n",
......
...@@ -98,7 +98,7 @@ static int sun4i_drv_bind(struct device *dev) ...@@ -98,7 +98,7 @@ static int sun4i_drv_bind(struct device *dev)
goto cleanup_mode_config; goto cleanup_mode_config;
/* Remove early framebuffers (ie. simplefb) */ /* Remove early framebuffers (ie. simplefb) */
ret = drm_aperture_remove_framebuffers(false, "sun4i-drm-fb"); ret = drm_aperture_remove_framebuffers(false, &sun4i_drv_driver);
if (ret) if (ret)
goto cleanup_mode_config; goto cleanup_mode_config;
......
...@@ -1197,7 +1197,7 @@ static int host1x_drm_probe(struct host1x_device *dev) ...@@ -1197,7 +1197,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
drm_mode_config_reset(drm); drm_mode_config_reset(drm);
err = drm_aperture_remove_framebuffers(false, "tegradrmfb"); err = drm_aperture_remove_framebuffers(false, &tegra_drm_driver);
if (err < 0) if (err < 0)
goto hub; goto hub;
......
...@@ -550,7 +550,7 @@ static int cirrus_pci_probe(struct pci_dev *pdev, ...@@ -550,7 +550,7 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
struct cirrus_device *cirrus; struct cirrus_device *cirrus;
int ret; int ret;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "cirrusdrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &cirrus_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -43,7 +43,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -43,7 +43,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!vbox_check_supported(VBE_DISPI_ID_HGSMI)) if (!vbox_check_supported(VBE_DISPI_ID_HGSMI))
return -ENODEV; return -ENODEV;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "vboxvideodrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -265,7 +265,7 @@ static int vc4_drm_bind(struct device *dev) ...@@ -265,7 +265,7 @@ static int vc4_drm_bind(struct device *dev)
if (ret) if (ret)
goto unbind_all; goto unbind_all;
ret = drm_aperture_remove_framebuffers(false, "vc4drmfb"); ret = drm_aperture_remove_framebuffers(false, &vc4_drm_driver);
if (ret) if (ret)
goto unbind_all; goto unbind_all;
......
...@@ -57,7 +57,7 @@ static int virtio_gpu_pci_quirk(struct drm_device *dev, struct virtio_device *vd ...@@ -57,7 +57,7 @@ static int virtio_gpu_pci_quirk(struct drm_device *dev, struct virtio_device *vd
vga ? "virtio-vga" : "virtio-gpu-pci", vga ? "virtio-vga" : "virtio-gpu-pci",
pname); pname);
if (vga) { if (vga) {
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "virtiodrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -1574,7 +1574,7 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1574,7 +1574,7 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct vmw_private *vmw; struct vmw_private *vmw;
int ret; int ret;
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, "svgadrmfb"); ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -6,20 +6,22 @@ ...@@ -6,20 +6,22 @@
#include <linux/types.h> #include <linux/types.h>
struct drm_device; struct drm_device;
struct drm_driver;
struct pci_dev; struct pci_dev;
int devm_aperture_acquire_from_firmware(struct drm_device *dev, resource_size_t base, int devm_aperture_acquire_from_firmware(struct drm_device *dev, resource_size_t base,
resource_size_t size); resource_size_t size);
int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size, int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size,
bool primary, const char *name); bool primary, const struct drm_driver *req_driver);
int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const char *name); int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
const struct drm_driver *req_driver);
/** /**
* drm_aperture_remove_framebuffers - remove all existing framebuffers * drm_aperture_remove_framebuffers - remove all existing framebuffers
* @primary: also kick vga16fb if present * @primary: also kick vga16fb if present
* @name: requesting driver name * @req_driver: requesting DRM driver
* *
* This function removes all graphics device drivers. Use this function on systems * This function removes all graphics device drivers. Use this function on systems
* that can have their framebuffer located anywhere in memory. * that can have their framebuffer located anywhere in memory.
...@@ -27,9 +29,11 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const ...@@ -27,9 +29,11 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const
* Returns: * Returns:
* 0 on success, or a negative errno code otherwise * 0 on success, or a negative errno code otherwise
*/ */
static inline int drm_aperture_remove_framebuffers(bool primary, const char *name) static inline int
drm_aperture_remove_framebuffers(bool primary, const struct drm_driver *req_driver)
{ {
return drm_aperture_remove_conflicting_framebuffers(0, (resource_size_t)-1, primary, name); return drm_aperture_remove_conflicting_framebuffers(0, (resource_size_t)-1, primary,
req_driver);
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment