Commit 10631d72 authored by Daniel Vetter's avatar Daniel Vetter

drm/pci: Deprecate drm_pci_init/exit completely

The magic switching between proper pci driver and shadow-attach isn't
useful anymore since there's no ums+kms drivers left. Let's split this
up properly, calling pci_register_driver for kms drivers and renaming
the shadow-attach init to drm_legacy_pci_init/exit.
Acked-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170524145212.27837-6-daniel.vetter@ffwll.ch
parent 5c484cee
...@@ -816,7 +816,7 @@ static int __init amdgpu_init(void) ...@@ -816,7 +816,7 @@ static int __init amdgpu_init(void)
driver->num_ioctls = amdgpu_max_kms_ioctl; driver->num_ioctls = amdgpu_max_kms_ioctl;
amdgpu_register_atpx_handler(); amdgpu_register_atpx_handler();
/* let modprobe override vga console setting */ /* let modprobe override vga console setting */
return drm_pci_init(driver, pdriver); return pci_register_driver(pdriver);
error_sched: error_sched:
amdgpu_fence_slab_fini(); amdgpu_fence_slab_fini();
...@@ -831,7 +831,7 @@ static int __init amdgpu_init(void) ...@@ -831,7 +831,7 @@ static int __init amdgpu_init(void)
static void __exit amdgpu_exit(void) static void __exit amdgpu_exit(void)
{ {
amdgpu_amdkfd_fini(); amdgpu_amdkfd_fini();
drm_pci_exit(driver, pdriver); pci_unregister_driver(pdriver);
amdgpu_unregister_atpx_handler(); amdgpu_unregister_atpx_handler();
amdgpu_sync_fini(); amdgpu_sync_fini();
amd_sched_fence_slab_fini(); amd_sched_fence_slab_fini();
......
...@@ -220,11 +220,11 @@ static int __init ast_init(void) ...@@ -220,11 +220,11 @@ static int __init ast_init(void)
if (ast_modeset == 0) if (ast_modeset == 0)
return -EINVAL; return -EINVAL;
return drm_pci_init(&driver, &ast_pci_driver); return pci_register_driver(&ast_pci_driver);
} }
static void __exit ast_exit(void) static void __exit ast_exit(void)
{ {
drm_pci_exit(&driver, &ast_pci_driver); pci_unregister_driver(&ast_pci_driver);
} }
module_init(ast_init); module_init(ast_init);
......
...@@ -223,12 +223,12 @@ static int __init bochs_init(void) ...@@ -223,12 +223,12 @@ static int __init bochs_init(void)
if (bochs_modeset == 0) if (bochs_modeset == 0)
return -EINVAL; return -EINVAL;
return drm_pci_init(&bochs_driver, &bochs_pci_driver); return pci_register_driver(&bochs_pci_driver);
} }
static void __exit bochs_exit(void) static void __exit bochs_exit(void)
{ {
drm_pci_exit(&bochs_driver, &bochs_pci_driver); pci_unregister_driver(&bochs_pci_driver);
} }
module_init(bochs_init); module_init(bochs_init);
......
...@@ -165,12 +165,12 @@ static int __init cirrus_init(void) ...@@ -165,12 +165,12 @@ static int __init cirrus_init(void)
if (cirrus_modeset == 0) if (cirrus_modeset == 0)
return -EINVAL; return -EINVAL;
return drm_pci_init(&driver, &cirrus_pci_driver); return pci_register_driver(&cirrus_pci_driver);
} }
static void __exit cirrus_exit(void) static void __exit cirrus_exit(void)
{ {
drm_pci_exit(&driver, &cirrus_pci_driver); pci_unregister_driver(&cirrus_pci_driver);
} }
module_init(cirrus_init); module_init(cirrus_init);
......
...@@ -280,20 +280,15 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, ...@@ -280,20 +280,15 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
EXPORT_SYMBOL(drm_get_pci_dev); EXPORT_SYMBOL(drm_get_pci_dev);
/** /**
* drm_pci_init - Register matching PCI devices with the DRM subsystem * drm_legacy_pci_init - shadow-attach a legacy DRM PCI driver
* @driver: DRM device driver * @driver: DRM device driver
* @pdriver: PCI device driver * @pdriver: PCI device driver
* *
* Initializes a drm_device structures, registering the stubs and initializing * This is only used by legacy dri1 drivers and deprecated.
* the AGP device.
*
* NOTE: This function is deprecated. Modern modesetting drm drivers should use
* pci_register_driver() directly, this function only provides shadow-binding
* support for old legacy drivers on top of that core pci function.
* *
* Return: 0 on success or a negative error code on failure. * Return: 0 on success or a negative error code on failure.
*/ */
int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
{ {
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
const struct pci_device_id *pid; const struct pci_device_id *pid;
...@@ -301,8 +296,8 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) ...@@ -301,8 +296,8 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (!(driver->driver_features & DRIVER_LEGACY)) if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
return pci_register_driver(pdriver); return -EINVAL;
/* If not using KMS, fall back to stealth mode manual scanning. */ /* If not using KMS, fall back to stealth mode manual scanning. */
INIT_LIST_HEAD(&driver->legacy_dev_list); INIT_LIST_HEAD(&driver->legacy_dev_list);
...@@ -329,6 +324,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) ...@@ -329,6 +324,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
} }
return 0; return 0;
} }
EXPORT_SYMBOL(drm_legacy_pci_init);
int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask) int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask)
{ {
...@@ -390,11 +386,6 @@ EXPORT_SYMBOL(drm_pcie_get_max_link_width); ...@@ -390,11 +386,6 @@ EXPORT_SYMBOL(drm_pcie_get_max_link_width);
#else #else
int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
{
return -1;
}
void drm_pci_agp_destroy(struct drm_device *dev) {} void drm_pci_agp_destroy(struct drm_device *dev) {}
int drm_irq_by_busid(struct drm_device *dev, void *data, int drm_irq_by_busid(struct drm_device *dev, void *data,
...@@ -404,27 +395,21 @@ int drm_irq_by_busid(struct drm_device *dev, void *data, ...@@ -404,27 +395,21 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
} }
#endif #endif
EXPORT_SYMBOL(drm_pci_init);
/** /**
* drm_pci_exit - Unregister matching PCI devices from the DRM subsystem * drm_legacy_pci_exit - unregister shadow-attach legacy DRM driver
* @driver: DRM device driver * @driver: DRM device driver
* @pdriver: PCI device driver * @pdriver: PCI device driver
* *
* Unregisters one or more devices matched by a PCI driver from the DRM * Unregister a DRM driver shadow-attached through drm_legacy_pci_init(). This
* subsystem. * is deprecated and only used by dri1 drivers.
*
* NOTE: This function is deprecated. Modern modesetting drm drivers should use
* pci_unregister_driver() directly, this function only provides shadow-binding
* support for old legacy drivers on top of that core pci function.
*/ */
void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
{ {
struct drm_device *dev, *tmp; struct drm_device *dev, *tmp;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (!(driver->driver_features & DRIVER_LEGACY)) { if (!(driver->driver_features & DRIVER_LEGACY)) {
pci_unregister_driver(pdriver); WARN_ON(1);
} else { } else {
list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list, list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
legacy_dev_list) { legacy_dev_list) {
...@@ -434,4 +419,4 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) ...@@ -434,4 +419,4 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
} }
DRM_INFO("Module unloaded\n"); DRM_INFO("Module unloaded\n");
} }
EXPORT_SYMBOL(drm_pci_exit); EXPORT_SYMBOL(drm_legacy_pci_exit);
...@@ -516,12 +516,12 @@ static struct pci_driver psb_pci_driver = { ...@@ -516,12 +516,12 @@ static struct pci_driver psb_pci_driver = {
static int __init psb_init(void) static int __init psb_init(void)
{ {
return drm_pci_init(&driver, &psb_pci_driver); return pci_register_driver(&psb_pci_driver);
} }
static void __exit psb_exit(void) static void __exit psb_exit(void)
{ {
drm_pci_exit(&driver, &psb_pci_driver); pci_unregister_driver(&psb_pci_driver);
} }
late_initcall(psb_init); late_initcall(psb_init);
......
...@@ -82,12 +82,12 @@ static int __init i810_init(void) ...@@ -82,12 +82,12 @@ static int __init i810_init(void)
return -EINVAL; return -EINVAL;
} }
driver.num_ioctls = i810_max_ioctl; driver.num_ioctls = i810_max_ioctl;
return drm_pci_init(&driver, &i810_pci_driver); return drm_legacy_pci_init(&driver, &i810_pci_driver);
} }
static void __exit i810_exit(void) static void __exit i810_exit(void)
{ {
drm_pci_exit(&driver, &i810_pci_driver); drm_legacy_pci_exit(&driver, &i810_pci_driver);
} }
module_init(i810_init); module_init(i810_init);
......
...@@ -89,12 +89,12 @@ static struct pci_driver mga_pci_driver = { ...@@ -89,12 +89,12 @@ static struct pci_driver mga_pci_driver = {
static int __init mga_init(void) static int __init mga_init(void)
{ {
driver.num_ioctls = mga_max_ioctl; driver.num_ioctls = mga_max_ioctl;
return drm_pci_init(&driver, &mga_pci_driver); return drm_legacy_pci_init(&driver, &mga_pci_driver);
} }
static void __exit mga_exit(void) static void __exit mga_exit(void)
{ {
drm_pci_exit(&driver, &mga_pci_driver); drm_legacy_pci_exit(&driver, &mga_pci_driver);
} }
module_init(mga_init); module_init(mga_init);
......
...@@ -119,12 +119,13 @@ static int __init mgag200_init(void) ...@@ -119,12 +119,13 @@ static int __init mgag200_init(void)
if (mgag200_modeset == 0) if (mgag200_modeset == 0)
return -EINVAL; return -EINVAL;
return drm_pci_init(&driver, &mgag200_pci_driver);
return pci_register_driver(&mgag200_pci_driver);
} }
static void __exit mgag200_exit(void) static void __exit mgag200_exit(void)
{ {
drm_pci_exit(&driver, &mgag200_pci_driver); pci_unregister_driver(&mgag200_pci_driver);
} }
module_init(mgag200_init); module_init(mgag200_init);
......
...@@ -1120,7 +1120,12 @@ nouveau_drm_init(void) ...@@ -1120,7 +1120,12 @@ nouveau_drm_init(void)
nouveau_register_dsm_handler(); nouveau_register_dsm_handler();
nouveau_backlight_ctor(); nouveau_backlight_ctor();
return drm_pci_init(&driver_pci, &nouveau_drm_pci_driver);
#ifdef CONFIG_PCI
return pci_register_driver(&nouveau_drm_pci_driver);
#else
return 0;
#endif
} }
static void __exit static void __exit
...@@ -1129,7 +1134,9 @@ nouveau_drm_exit(void) ...@@ -1129,7 +1134,9 @@ nouveau_drm_exit(void)
if (!nouveau_modeset) if (!nouveau_modeset)
return; return;
drm_pci_exit(&driver_pci, &nouveau_drm_pci_driver); #ifdef CONFIG_PCI
pci_unregister_driver(&nouveau_drm_pci_driver);
#endif
nouveau_backlight_dtor(); nouveau_backlight_dtor();
nouveau_unregister_dsm_handler(); nouveau_unregister_dsm_handler();
......
...@@ -301,12 +301,12 @@ static int __init qxl_init(void) ...@@ -301,12 +301,12 @@ static int __init qxl_init(void)
if (qxl_modeset == 0) if (qxl_modeset == 0)
return -EINVAL; return -EINVAL;
qxl_driver.num_ioctls = qxl_max_ioctls; qxl_driver.num_ioctls = qxl_max_ioctls;
return drm_pci_init(&qxl_driver, &qxl_pci_driver); return pci_register_driver(&qxl_pci_driver);
} }
static void __exit qxl_exit(void) static void __exit qxl_exit(void)
{ {
drm_pci_exit(&qxl_driver, &qxl_pci_driver); pci_unregister_driver(&qxl_pci_driver);
} }
module_init(qxl_init); module_init(qxl_init);
......
...@@ -95,12 +95,12 @@ static int __init r128_init(void) ...@@ -95,12 +95,12 @@ static int __init r128_init(void)
{ {
driver.num_ioctls = r128_max_ioctl; driver.num_ioctls = r128_max_ioctl;
return drm_pci_init(&driver, &r128_pci_driver); return drm_legacy_pci_init(&driver, &r128_pci_driver);
} }
static void __exit r128_exit(void) static void __exit r128_exit(void)
{ {
drm_pci_exit(&driver, &r128_pci_driver); drm_legacy_pci_exit(&driver, &r128_pci_driver);
} }
module_init(r128_init); module_init(r128_init);
......
...@@ -619,14 +619,13 @@ static int __init radeon_init(void) ...@@ -619,14 +619,13 @@ static int __init radeon_init(void)
return -EINVAL; return -EINVAL;
} }
/* let modprobe override vga console setting */ return pci_register_driver(pdriver);
return drm_pci_init(driver, pdriver);
} }
static void __exit radeon_exit(void) static void __exit radeon_exit(void)
{ {
radeon_kfd_fini(); radeon_kfd_fini();
drm_pci_exit(driver, pdriver); pci_unregister_driver(pdriver);
radeon_unregister_atpx_handler(); radeon_unregister_atpx_handler();
} }
......
...@@ -74,12 +74,12 @@ static struct pci_driver savage_pci_driver = { ...@@ -74,12 +74,12 @@ static struct pci_driver savage_pci_driver = {
static int __init savage_init(void) static int __init savage_init(void)
{ {
driver.num_ioctls = savage_max_ioctl; driver.num_ioctls = savage_max_ioctl;
return drm_pci_init(&driver, &savage_pci_driver); return drm_legacy_pci_init(&driver, &savage_pci_driver);
} }
static void __exit savage_exit(void) static void __exit savage_exit(void)
{ {
drm_pci_exit(&driver, &savage_pci_driver); drm_legacy_pci_exit(&driver, &savage_pci_driver);
} }
module_init(savage_init); module_init(savage_init);
......
...@@ -124,12 +124,12 @@ static struct pci_driver sis_pci_driver = { ...@@ -124,12 +124,12 @@ static struct pci_driver sis_pci_driver = {
static int __init sis_init(void) static int __init sis_init(void)
{ {
driver.num_ioctls = sis_max_ioctl; driver.num_ioctls = sis_max_ioctl;
return drm_pci_init(&driver, &sis_pci_driver); return drm_legacy_pci_init(&driver, &sis_pci_driver);
} }
static void __exit sis_exit(void) static void __exit sis_exit(void)
{ {
drm_pci_exit(&driver, &sis_pci_driver); drm_legacy_pci_exit(&driver, &sis_pci_driver);
} }
module_init(sis_init); module_init(sis_init);
......
...@@ -71,12 +71,12 @@ static struct pci_driver tdfx_pci_driver = { ...@@ -71,12 +71,12 @@ static struct pci_driver tdfx_pci_driver = {
static int __init tdfx_init(void) static int __init tdfx_init(void)
{ {
return drm_pci_init(&driver, &tdfx_pci_driver); return drm_legacy_pci_init(&driver, &tdfx_pci_driver);
} }
static void __exit tdfx_exit(void) static void __exit tdfx_exit(void)
{ {
drm_pci_exit(&driver, &tdfx_pci_driver); drm_legacy_pci_exit(&driver, &tdfx_pci_driver);
} }
module_init(tdfx_init); module_init(tdfx_init);
......
...@@ -106,12 +106,12 @@ static int __init via_init(void) ...@@ -106,12 +106,12 @@ static int __init via_init(void)
{ {
driver.num_ioctls = via_max_ioctl; driver.num_ioctls = via_max_ioctl;
via_init_command_verifier(); via_init_command_verifier();
return drm_pci_init(&driver, &via_pci_driver); return drm_legacy_pci_init(&driver, &via_pci_driver);
} }
static void __exit via_exit(void) static void __exit via_exit(void)
{ {
drm_pci_exit(&driver, &via_pci_driver); drm_legacy_pci_exit(&driver, &via_pci_driver);
} }
module_init(via_init); module_init(via_init);
......
...@@ -1570,7 +1570,7 @@ static int __init vmwgfx_init(void) ...@@ -1570,7 +1570,7 @@ static int __init vmwgfx_init(void)
if (vgacon_text_force()) if (vgacon_text_force())
return -EINVAL; return -EINVAL;
ret = drm_pci_init(&driver, &vmw_pci_driver); ret = pci_register_driver(&vmw_pci_driver);
if (ret) if (ret)
DRM_ERROR("Failed initializing DRM.\n"); DRM_ERROR("Failed initializing DRM.\n");
return ret; return ret;
...@@ -1578,7 +1578,7 @@ static int __init vmwgfx_init(void) ...@@ -1578,7 +1578,7 @@ static int __init vmwgfx_init(void)
static void __exit vmwgfx_exit(void) static void __exit vmwgfx_exit(void)
{ {
drm_pci_exit(&driver, &vmw_pci_driver); pci_unregister_driver(&vmw_pci_driver);
} }
module_init(vmwgfx_init); module_init(vmwgfx_init);
......
...@@ -43,8 +43,8 @@ struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, ...@@ -43,8 +43,8 @@ struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
size_t align); size_t align);
void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
int drm_get_pci_dev(struct pci_dev *pdev, int drm_get_pci_dev(struct pci_dev *pdev,
const struct pci_device_id *ent, const struct pci_device_id *ent,
......
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