]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
drm: add _DRM_DRIVER flag, and re-order unload.
authorDave Airlie <airlied@redhat.com>
Sun, 16 Dec 2007 23:41:56 +0000 (09:41 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 7 Feb 2008 05:09:39 +0000 (15:09 +1000)
Allow drivers to addmaps that won't be removed by lastclose or unload.
The unload needs to be re-ordered to avoid removing the hashs before
the driver has removed the final maps.

Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/drm.h
drivers/char/drm/drm_drv.c
drivers/char/drm/i915_dma.c

index 82fb3d0d2785c5bf563b79fdcd39f782a8f48624..3a05c6d5ebe1f9306bca6a3e11740d54b9e6e5ef 100644 (file)
@@ -202,7 +202,8 @@ enum drm_map_flags {
        _DRM_KERNEL = 0x08,          /**< kernel requires access */
        _DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */
        _DRM_CONTAINS_LOCK = 0x20,   /**< SHM page that contains lock */
-       _DRM_REMOVABLE = 0x40        /**< Removable mapping */
+       _DRM_REMOVABLE = 0x40,       /**< Removable mapping */
+       _DRM_DRIVER = 0x80           /**< Managed by driver */
 };
 
 struct drm_ctx_priv_map {
index d29d7ed91bdd8d62702d61b69e216cb475352107..77e2fb7b7b3707be0eec8a8d892c7cd16c9463df 100644 (file)
@@ -200,8 +200,10 @@ int drm_lastclose(struct drm_device * dev)
        }
 
        list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
-               drm_rmmap_locked(dev, r_list->map);
-               r_list = NULL;
+               if (!(r_list->map->flags & _DRM_DRIVER)) {
+                       drm_rmmap_locked(dev, r_list->map);
+                       r_list = NULL;
+               }
        }
 
        if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
@@ -291,10 +293,6 @@ static void drm_cleanup(struct drm_device * dev)
 
        drm_lastclose(dev);
 
-       drm_ht_remove(&dev->map_hash);
-
-       drm_ctxbitmap_cleanup(dev);
-
        if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
            dev->agp && dev->agp->agp_mtrr >= 0) {
                int retval;
@@ -312,6 +310,9 @@ static void drm_cleanup(struct drm_device * dev)
        if (dev->driver->unload)
                dev->driver->unload(dev);
 
+       drm_ht_remove(&dev->map_hash);
+       drm_ctxbitmap_cleanup(dev);
+
        drm_put_head(&dev->primary);
        if (drm_put_dev(dev))
                DRM_ERROR("Cannot unload module\n");
index b8db9652e9ddf2d2bfde64bafd1343c2552fb232..24f86e07d6a48873dc09eda0bb1987672ecf7942 100644 (file)
@@ -778,7 +778,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        base = drm_get_resource_start(dev, mmio_bar);
        size = drm_get_resource_len(dev, mmio_bar);
 
-       ret = drm_addmap(dev, base, size, _DRM_REGISTERS, _DRM_KERNEL,
+       ret = drm_addmap(dev, base, size, _DRM_REGISTERS,
+                        _DRM_KERNEL | _DRM_DRIVER,
                         &dev_priv->mmio_map);
        return ret;
 }