Commit b3f2333d authored by Daniel Vetter's avatar Daniel Vetter Committed by Dave Airlie

drm: restrict the device list for shadow attached drivers

There's really no need for the drm core to keep a list of all
devices of a given driver - the linux device model keeps perfect
track of this already for us.

The exception is old legacy ums drivers using pci shadow attaching.
So rename the lists to make the use case clearer and rip out everything
else.

v2: Rebase on top of David Herrmann's drm device register changes.
Also drop the bogus dev_set_drvdata for platform drivers that somehow
crept into the original version - drivers really should be in full
control of that field.

v3: Initialize driver->legacy_dev_list outside of the loop, spotted by
David Herrmann.

v4: Rebase on top of the newly created host1x drm_bus for tegra.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent e2577d45
...@@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, ...@@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
driver->name, driver->major, driver->minor, driver->patchlevel, driver->name, driver->major, driver->minor, driver->patchlevel,
driver->date, pci_name(pdev), dev->primary->index); driver->date, pci_name(pdev), dev->primary->index);
/* No locking needed since shadow-attach is single-threaded since it may
* only be called from the per-driver module init hook. */
if (!drm_core_check_feature(dev, DRIVER_MODESET))
list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
return 0; return 0;
err_pci: err_pci:
...@@ -375,7 +380,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) ...@@ -375,7 +380,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
DRM_DEBUG("\n"); DRM_DEBUG("\n");
INIT_LIST_HEAD(&driver->device_list);
driver->kdriver.pci = pdriver; driver->kdriver.pci = pdriver;
driver->bus = &drm_pci_bus; driver->bus = &drm_pci_bus;
...@@ -383,6 +387,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) ...@@ -383,6 +387,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
return pci_register_driver(pdriver); return pci_register_driver(pdriver);
/* 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);
for (i = 0; pdriver->id_table[i].vendor != 0; i++) { for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
pid = &pdriver->id_table[i]; pid = &pdriver->id_table[i];
...@@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver) ...@@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
if (driver->driver_features & DRIVER_MODESET) { if (driver->driver_features & DRIVER_MODESET) {
pci_unregister_driver(pdriver); pci_unregister_driver(pdriver);
} else { } else {
list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
legacy_dev_list) {
drm_put_dev(dev); drm_put_dev(dev);
list_del(&dev->legacy_dev_list);
}
} }
DRM_INFO("Module unloaded\n"); DRM_INFO("Module unloaded\n");
} }
......
...@@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor ...@@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor
driver->kdriver.platform_device = platform_device; driver->kdriver.platform_device = platform_device;
driver->bus = &drm_platform_bus; driver->bus = &drm_platform_bus;
INIT_LIST_HEAD(&driver->device_list);
return drm_get_platform_dev(platform_device, driver); return drm_get_platform_dev(platform_device, driver);
} }
EXPORT_SYMBOL(drm_platform_init); EXPORT_SYMBOL(drm_platform_init);
...@@ -563,8 +563,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) ...@@ -563,8 +563,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
goto err_unload; goto err_unload;
} }
list_add_tail(&dev->driver_item, &dev->driver->device_list);
ret = 0; ret = 0;
goto out_unlock; goto out_unlock;
...@@ -614,7 +612,5 @@ void drm_dev_unregister(struct drm_device *dev) ...@@ -614,7 +612,5 @@ void drm_dev_unregister(struct drm_device *dev)
drm_unplug_minor(dev->control); drm_unplug_minor(dev->control);
drm_unplug_minor(dev->render); drm_unplug_minor(dev->render);
drm_unplug_minor(dev->primary); drm_unplug_minor(dev->primary);
list_del(&dev->driver_item);
} }
EXPORT_SYMBOL(drm_dev_unregister); EXPORT_SYMBOL(drm_dev_unregister);
...@@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) ...@@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
int res; int res;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
INIT_LIST_HEAD(&driver->device_list);
driver->kdriver.usb = udriver; driver->kdriver.usb = udriver;
driver->bus = &drm_usb_bus; driver->bus = &drm_usb_bus;
......
...@@ -46,7 +46,6 @@ int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device) ...@@ -46,7 +46,6 @@ int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
struct drm_device *drm; struct drm_device *drm;
int ret; int ret;
INIT_LIST_HEAD(&driver->device_list);
driver->bus = &drm_host1x_bus; driver->bus = &drm_host1x_bus;
drm = drm_dev_alloc(driver, &device->dev); drm = drm_dev_alloc(driver, &device->dev);
......
...@@ -1012,8 +1012,8 @@ struct drm_driver { ...@@ -1012,8 +1012,8 @@ struct drm_driver {
} kdriver; } kdriver;
struct drm_bus *bus; struct drm_bus *bus;
/* List of devices hanging off this driver */ /* List of devices hanging off this driver with stealth attach. */
struct list_head device_list; struct list_head legacy_dev_list;
}; };
#define DRM_MINOR_UNASSIGNED 0 #define DRM_MINOR_UNASSIGNED 0
...@@ -1102,7 +1102,7 @@ struct drm_vblank_crtc { ...@@ -1102,7 +1102,7 @@ struct drm_vblank_crtc {
* may contain multiple heads. * may contain multiple heads.
*/ */
struct drm_device { struct drm_device {
struct list_head driver_item; /**< list of devices per driver */ struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
char *devname; /**< For /proc/interrupts */ char *devname; /**< For /proc/interrupts */
int if_version; /**< Highest interface version set */ int if_version; /**< Highest interface version set */
......
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