From 112b715e8e2f9ef7b96930888bb099ce10b4c3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Sun, 4 Jan 2009 16:55:33 -0500 Subject: drm: claim PCI device when running in modesetting mode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_drv.c | 71 ++++++++--------------------------------------- 1 file changed, 12 insertions(+), 59 deletions(-) (limited to 'drivers/gpu/drm/drm_drv.c') diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 6394c2b67658..1441655388ab 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -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"); } -- cgit v1.2.3