aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_drv.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2009-01-04 16:55:33 -0500
committerDave Airlie <airlied@redhat.com>2009-03-13 00:23:58 -0400
commit112b715e8e2f9ef7b96930888bb099ce10b4c3cc (patch)
tree1058edb8beb6dd60a794d2333e43d37cc7116f06 /drivers/gpu/drm/drm_drv.c
parent41c2e75e60200a860a74b7c84a6375c105e7437f (diff)
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>
Diffstat (limited to 'drivers/gpu/drm/drm_drv.c')
-rw-r--r--drivers/gpu/drm/drm_drv.c71
1 files changed, 12 insertions, 59 deletions
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)
252int drm_init(struct drm_driver *driver) 252int drm_init(struct drm_driver *driver)
253{ 253{
254 struct pci_dev *pdev = NULL; 254 struct pci_dev *pdev = NULL;
255 struct pci_device_id *pid; 255 const struct pci_device_id *pid;
256 int i; 256 int i;
257 257
258 DRM_DEBUG("\n"); 258 DRM_DEBUG("\n");
259 259
260 INIT_LIST_HEAD(&driver->device_list); 260 INIT_LIST_HEAD(&driver->device_list);
261 261
262 if (driver->driver_features & DRIVER_MODESET)
263 return pci_register_driver(&driver->pci_driver);
264
265 /* If not using KMS, fall back to stealth mode manual scanning. */
262 for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) { 266 for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
263 pid = (struct pci_device_id *)&driver->pci_driver.id_table[i]; 267 pid = &driver->pci_driver.id_table[i];
264 268
265 /* Loop around setting up a DRM device for each PCI device 269 /* Loop around setting up a DRM device for each PCI device
266 * matching our ID and device class. If we had the internal 270 * matching our ID and device class. If we had the internal
@@ -285,68 +289,17 @@ int drm_init(struct drm_driver *driver)
285 289
286EXPORT_SYMBOL(drm_init); 290EXPORT_SYMBOL(drm_init);
287 291
288/**
289 * Called via cleanup_module() at module unload time.
290 *
291 * Cleans up all DRM device, calling drm_lastclose().
292 *
293 * \sa drm_init
294 */
295static void drm_cleanup(struct drm_device * dev)
296{
297 struct drm_map_list *r_list, *list_temp;
298 DRM_DEBUG("\n");
299
300 if (!dev) {
301 DRM_ERROR("cleanup called no dev\n");
302 return;
303 }
304
305 drm_vblank_cleanup(dev);
306
307 drm_lastclose(dev);
308
309 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
310 dev->agp && dev->agp->agp_mtrr >= 0) {
311 int retval;
312 retval = mtrr_del(dev->agp->agp_mtrr,
313 dev->agp->agp_info.aper_base,
314 dev->agp->agp_info.aper_size * 1024 * 1024);
315 DRM_DEBUG("mtrr_del=%d\n", retval);
316 }
317
318 if (dev->driver->unload)
319 dev->driver->unload(dev);
320
321 if (drm_core_has_AGP(dev) && dev->agp) {
322 drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
323 dev->agp = NULL;
324 }
325
326 drm_ht_remove(&dev->map_hash);
327 drm_ctxbitmap_cleanup(dev);
328
329 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
330 drm_rmmap(dev, r_list->map);
331
332 if (drm_core_check_feature(dev, DRIVER_MODESET))
333 drm_put_minor(&dev->control);
334
335 if (dev->driver->driver_features & DRIVER_GEM)
336 drm_gem_destroy(dev);
337
338 drm_put_minor(&dev->primary);
339 if (drm_put_dev(dev))
340 DRM_ERROR("Cannot unload module\n");
341}
342
343void drm_exit(struct drm_driver *driver) 292void drm_exit(struct drm_driver *driver)
344{ 293{
345 struct drm_device *dev, *tmp; 294 struct drm_device *dev, *tmp;
346 DRM_DEBUG("\n"); 295 DRM_DEBUG("\n");
347 296
348 list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) 297 if (driver->driver_features & DRIVER_MODESET) {
349 drm_cleanup(dev); 298 pci_unregister_driver(&driver->pci_driver);
299 } else {
300 list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
301 drm_put_dev(dev);
302 }
350 303
351 DRM_INFO("Module unloaded\n"); 304 DRM_INFO("Module unloaded\n");
352} 305}