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: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170524145212.27837-6-daniel.vetter@ffwll.ch
This commit is contained in:
Daniel Vetter 2017-05-24 16:51:40 +02:00
parent 5c484cee7e
commit 10631d724d
19 changed files with 56 additions and 64 deletions

View File

@ -816,7 +816,7 @@ static int __init amdgpu_init(void)
driver->num_ioctls = amdgpu_max_kms_ioctl;
amdgpu_register_atpx_handler();
/* let modprobe override vga console setting */
return drm_pci_init(driver, pdriver);
return pci_register_driver(pdriver);
error_sched:
amdgpu_fence_slab_fini();
@ -831,7 +831,7 @@ error_sync:
static void __exit amdgpu_exit(void)
{
amdgpu_amdkfd_fini();
drm_pci_exit(driver, pdriver);
pci_unregister_driver(pdriver);
amdgpu_unregister_atpx_handler();
amdgpu_sync_fini();
amd_sched_fence_slab_fini();

View File

@ -220,11 +220,11 @@ static int __init ast_init(void)
if (ast_modeset == 0)
return -EINVAL;
return drm_pci_init(&driver, &ast_pci_driver);
return pci_register_driver(&ast_pci_driver);
}
static void __exit ast_exit(void)
{
drm_pci_exit(&driver, &ast_pci_driver);
pci_unregister_driver(&ast_pci_driver);
}
module_init(ast_init);

View File

@ -223,12 +223,12 @@ static int __init bochs_init(void)
if (bochs_modeset == 0)
return -EINVAL;
return drm_pci_init(&bochs_driver, &bochs_pci_driver);
return pci_register_driver(&bochs_pci_driver);
}
static void __exit bochs_exit(void)
{
drm_pci_exit(&bochs_driver, &bochs_pci_driver);
pci_unregister_driver(&bochs_pci_driver);
}
module_init(bochs_init);

View File

@ -165,12 +165,12 @@ static int __init cirrus_init(void)
if (cirrus_modeset == 0)
return -EINVAL;
return drm_pci_init(&driver, &cirrus_pci_driver);
return pci_register_driver(&cirrus_pci_driver);
}
static void __exit cirrus_exit(void)
{
drm_pci_exit(&driver, &cirrus_pci_driver);
pci_unregister_driver(&cirrus_pci_driver);
}
module_init(cirrus_init);

View File

@ -280,20 +280,15 @@ err_free:
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
* @pdriver: PCI device driver
*
* Initializes a drm_device structures, registering the stubs and initializing
* 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.
* This is only used by legacy dri1 drivers and deprecated.
*
* 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;
const struct pci_device_id *pid;
@ -301,8 +296,8 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
DRM_DEBUG("\n");
if (!(driver->driver_features & DRIVER_LEGACY))
return pci_register_driver(pdriver);
if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY)))
return -EINVAL;
/* If not using KMS, fall back to stealth mode manual scanning. */
INIT_LIST_HEAD(&driver->legacy_dev_list);
@ -329,6 +324,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
}
return 0;
}
EXPORT_SYMBOL(drm_legacy_pci_init);
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);
#else
int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
{
return -1;
}
void drm_pci_agp_destroy(struct drm_device *dev) {}
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
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
* @pdriver: PCI device driver
*
* Unregisters one or more devices matched by a PCI driver from the DRM
* subsystem.
*
* 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.
* Unregister a DRM driver shadow-attached through drm_legacy_pci_init(). This
* is deprecated and only used by dri1 drivers.
*/
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;
DRM_DEBUG("\n");
if (!(driver->driver_features & DRIVER_LEGACY)) {
pci_unregister_driver(pdriver);
WARN_ON(1);
} else {
list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
legacy_dev_list) {
@ -434,4 +419,4 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
}
DRM_INFO("Module unloaded\n");
}
EXPORT_SYMBOL(drm_pci_exit);
EXPORT_SYMBOL(drm_legacy_pci_exit);

View File

@ -516,12 +516,12 @@ static struct pci_driver psb_pci_driver = {
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)
{
drm_pci_exit(&driver, &psb_pci_driver);
pci_unregister_driver(&psb_pci_driver);
}
late_initcall(psb_init);

View File

@ -82,12 +82,12 @@ static int __init i810_init(void)
return -EINVAL;
}
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)
{
drm_pci_exit(&driver, &i810_pci_driver);
drm_legacy_pci_exit(&driver, &i810_pci_driver);
}
module_init(i810_init);

View File

@ -89,12 +89,12 @@ static struct pci_driver mga_pci_driver = {
static int __init mga_init(void)
{
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)
{
drm_pci_exit(&driver, &mga_pci_driver);
drm_legacy_pci_exit(&driver, &mga_pci_driver);
}
module_init(mga_init);

View File

@ -119,12 +119,13 @@ static int __init mgag200_init(void)
if (mgag200_modeset == 0)
return -EINVAL;
return drm_pci_init(&driver, &mgag200_pci_driver);
return pci_register_driver(&mgag200_pci_driver);
}
static void __exit mgag200_exit(void)
{
drm_pci_exit(&driver, &mgag200_pci_driver);
pci_unregister_driver(&mgag200_pci_driver);
}
module_init(mgag200_init);

View File

@ -1120,7 +1120,12 @@ nouveau_drm_init(void)
nouveau_register_dsm_handler();
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
@ -1129,7 +1134,9 @@ nouveau_drm_exit(void)
if (!nouveau_modeset)
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_unregister_dsm_handler();

View File

@ -301,12 +301,12 @@ static int __init qxl_init(void)
if (qxl_modeset == 0)
return -EINVAL;
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)
{
drm_pci_exit(&qxl_driver, &qxl_pci_driver);
pci_unregister_driver(&qxl_pci_driver);
}
module_init(qxl_init);

View File

@ -95,12 +95,12 @@ static int __init r128_init(void)
{
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)
{
drm_pci_exit(&driver, &r128_pci_driver);
drm_legacy_pci_exit(&driver, &r128_pci_driver);
}
module_init(r128_init);

View File

@ -619,14 +619,13 @@ static int __init radeon_init(void)
return -EINVAL;
}
/* let modprobe override vga console setting */
return drm_pci_init(driver, pdriver);
return pci_register_driver(pdriver);
}
static void __exit radeon_exit(void)
{
radeon_kfd_fini();
drm_pci_exit(driver, pdriver);
pci_unregister_driver(pdriver);
radeon_unregister_atpx_handler();
}

View File

@ -74,12 +74,12 @@ static struct pci_driver savage_pci_driver = {
static int __init savage_init(void)
{
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)
{
drm_pci_exit(&driver, &savage_pci_driver);
drm_legacy_pci_exit(&driver, &savage_pci_driver);
}
module_init(savage_init);

View File

@ -124,12 +124,12 @@ static struct pci_driver sis_pci_driver = {
static int __init sis_init(void)
{
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)
{
drm_pci_exit(&driver, &sis_pci_driver);
drm_legacy_pci_exit(&driver, &sis_pci_driver);
}
module_init(sis_init);

View File

@ -71,12 +71,12 @@ static struct pci_driver tdfx_pci_driver = {
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)
{
drm_pci_exit(&driver, &tdfx_pci_driver);
drm_legacy_pci_exit(&driver, &tdfx_pci_driver);
}
module_init(tdfx_init);

View File

@ -106,12 +106,12 @@ static int __init via_init(void)
{
driver.num_ioctls = via_max_ioctl;
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)
{
drm_pci_exit(&driver, &via_pci_driver);
drm_legacy_pci_exit(&driver, &via_pci_driver);
}
module_init(via_init);

View File

@ -1570,7 +1570,7 @@ static int __init vmwgfx_init(void)
if (vgacon_text_force())
return -EINVAL;
ret = drm_pci_init(&driver, &vmw_pci_driver);
ret = pci_register_driver(&vmw_pci_driver);
if (ret)
DRM_ERROR("Failed initializing DRM.\n");
return ret;
@ -1578,7 +1578,7 @@ static int __init vmwgfx_init(void)
static void __exit vmwgfx_exit(void)
{
drm_pci_exit(&driver, &vmw_pci_driver);
pci_unregister_driver(&vmw_pci_driver);
}
module_init(vmwgfx_init);

View File

@ -43,8 +43,8 @@ struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
size_t align);
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);
void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
#ifdef CONFIG_PCI
int drm_get_pci_dev(struct pci_dev *pdev,
const struct pci_device_id *ent,