drm: claim PCI device when running in modesetting mode.
Under kernel modesetting, we manage the device at all times, regardless of VT switching and X servers, so the only decent thing to do is to claim the PCI device. In that case, we call the suspend/resume hooks directly from the pci driver hooks instead of the current class device detour. Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
This commit is contained in:
committed by
Dave Airlie
parent
41c2e75e60
commit
112b715e8e
@@ -252,15 +252,19 @@ int drm_lastclose(struct drm_device * dev)
|
||||
int drm_init(struct drm_driver *driver)
|
||||
{
|
||||
struct pci_dev *pdev = NULL;
|
||||
struct pci_device_id *pid;
|
||||
const struct pci_device_id *pid;
|
||||
int i;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
INIT_LIST_HEAD(&driver->device_list);
|
||||
|
||||
if (driver->driver_features & DRIVER_MODESET)
|
||||
return pci_register_driver(&driver->pci_driver);
|
||||
|
||||
/* If not using KMS, fall back to stealth mode manual scanning. */
|
||||
for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
|
||||
pid = (struct pci_device_id *)&driver->pci_driver.id_table[i];
|
||||
pid = &driver->pci_driver.id_table[i];
|
||||
|
||||
/* Loop around setting up a DRM device for each PCI device
|
||||
* matching our ID and device class. If we had the internal
|
||||
@@ -285,68 +289,17 @@ int drm_init(struct drm_driver *driver)
|
||||
|
||||
EXPORT_SYMBOL(drm_init);
|
||||
|
||||
/**
|
||||
* Called via cleanup_module() at module unload time.
|
||||
*
|
||||
* Cleans up all DRM device, calling drm_lastclose().
|
||||
*
|
||||
* \sa drm_init
|
||||
*/
|
||||
static void drm_cleanup(struct drm_device * dev)
|
||||
{
|
||||
struct drm_map_list *r_list, *list_temp;
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
if (!dev) {
|
||||
DRM_ERROR("cleanup called no dev\n");
|
||||
return;
|
||||
}
|
||||
|
||||
drm_vblank_cleanup(dev);
|
||||
|
||||
drm_lastclose(dev);
|
||||
|
||||
if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
|
||||
dev->agp && dev->agp->agp_mtrr >= 0) {
|
||||
int retval;
|
||||
retval = mtrr_del(dev->agp->agp_mtrr,
|
||||
dev->agp->agp_info.aper_base,
|
||||
dev->agp->agp_info.aper_size * 1024 * 1024);
|
||||
DRM_DEBUG("mtrr_del=%d\n", retval);
|
||||
}
|
||||
|
||||
if (dev->driver->unload)
|
||||
dev->driver->unload(dev);
|
||||
|
||||
if (drm_core_has_AGP(dev) && dev->agp) {
|
||||
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
|
||||
dev->agp = NULL;
|
||||
}
|
||||
|
||||
drm_ht_remove(&dev->map_hash);
|
||||
drm_ctxbitmap_cleanup(dev);
|
||||
|
||||
list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
|
||||
drm_rmmap(dev, r_list->map);
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
drm_put_minor(&dev->control);
|
||||
|
||||
if (dev->driver->driver_features & DRIVER_GEM)
|
||||
drm_gem_destroy(dev);
|
||||
|
||||
drm_put_minor(&dev->primary);
|
||||
if (drm_put_dev(dev))
|
||||
DRM_ERROR("Cannot unload module\n");
|
||||
}
|
||||
|
||||
void drm_exit(struct drm_driver *driver)
|
||||
{
|
||||
struct drm_device *dev, *tmp;
|
||||
DRM_DEBUG("\n");
|
||||
|
||||
list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
|
||||
drm_cleanup(dev);
|
||||
if (driver->driver_features & DRIVER_MODESET) {
|
||||
pci_unregister_driver(&driver->pci_driver);
|
||||
} else {
|
||||
list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
|
||||
drm_put_dev(dev);
|
||||
}
|
||||
|
||||
DRM_INFO("Module unloaded\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user