aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_stub.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_stub.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_stub.c')
-rw-r--r--drivers/gpu/drm/drm_stub.c89
1 files changed, 66 insertions, 23 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 7c8b15b22bf2..f51c685011ed 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -372,6 +372,7 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
372 } 372 }
373 373
374 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 374 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
375 pci_set_drvdata(pdev, dev);
375 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); 376 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
376 if (ret) 377 if (ret)
377 goto err_g2; 378 goto err_g2;
@@ -409,29 +410,7 @@ err_g1:
409 drm_free(dev, sizeof(*dev), DRM_MEM_STUB); 410 drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
410 return ret; 411 return ret;
411} 412}
412 413EXPORT_SYMBOL(drm_get_dev);
413/**
414 * Put a device minor number.
415 *
416 * \param dev device data structure
417 * \return always zero
418 *
419 * Cleans up the proc resources. If it is the last minor then release the foreign
420 * "drm" data, otherwise unregisters the "drm" data, frees the dev list and
421 * unregisters the character device.
422 */
423int drm_put_dev(struct drm_device * dev)
424{
425 DRM_DEBUG("release primary %s\n", dev->driver->pci_driver.name);
426
427 if (dev->devname) {
428 drm_free(dev->devname, strlen(dev->devname) + 1,
429 DRM_MEM_DRIVER);
430 dev->devname = NULL;
431 }
432 drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
433 return 0;
434}
435 414
436/** 415/**
437 * Put a secondary minor number. 416 * Put a secondary minor number.
@@ -459,3 +438,67 @@ int drm_put_minor(struct drm_minor **minor_p)
459 *minor_p = NULL; 438 *minor_p = NULL;
460 return 0; 439 return 0;
461} 440}
441
442/**
443 * Called via drm_exit() at module unload time or when pci device is
444 * unplugged.
445 *
446 * Cleans up all DRM device, calling drm_lastclose().
447 *
448 * \sa drm_init
449 */
450void drm_put_dev(struct drm_device *dev)
451{
452 struct drm_driver *driver = dev->driver;
453 struct drm_map_list *r_list, *list_temp;
454
455 DRM_DEBUG("\n");
456
457 if (!dev) {
458 DRM_ERROR("cleanup called no dev\n");
459 return;
460 }
461
462 drm_vblank_cleanup(dev);
463
464 drm_lastclose(dev);
465
466 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
467 dev->agp && dev->agp->agp_mtrr >= 0) {
468 int retval;
469 retval = mtrr_del(dev->agp->agp_mtrr,
470 dev->agp->agp_info.aper_base,
471 dev->agp->agp_info.aper_size * 1024 * 1024);
472 DRM_DEBUG("mtrr_del=%d\n", retval);
473 }
474
475 if (dev->driver->unload)
476 dev->driver->unload(dev);
477
478 if (drm_core_has_AGP(dev) && dev->agp) {
479 drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
480 dev->agp = NULL;
481 }
482
483 drm_ht_remove(&dev->map_hash);
484 drm_ctxbitmap_cleanup(dev);
485
486 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
487 drm_rmmap(dev, r_list->map);
488
489 if (drm_core_check_feature(dev, DRIVER_MODESET))
490 drm_put_minor(&dev->control);
491
492 if (driver->driver_features & DRIVER_GEM)
493 drm_gem_destroy(dev);
494
495 drm_put_minor(&dev->primary);
496
497 if (dev->devname) {
498 drm_free(dev->devname, strlen(dev->devname) + 1,
499 DRM_MEM_DRIVER);
500 dev->devname = NULL;
501 }
502 drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
503}
504EXPORT_SYMBOL(drm_put_dev);