drm/i915: Remove mmap_offset
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 28 Oct 2010 12:03:06 +0000 (13:03 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 28 Oct 2010 19:55:02 +0000 (20:55 +0100)
Since we rarely use the mmap_offset and it is easily computable from the
obj->map_list.hash, remove it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c

index 29e8b7962edf5150dc0e20a0d2cb9d0e04acdb48..1f7e8b3c8df05158bbe56a227af8e1434d73f9fe 100644 (file)
@@ -796,11 +796,6 @@ struct drm_i915_gem_object {
        /* Which ring is refering to is this object */
        struct intel_ring_buffer *ring;
 
-       /**
-        * Fake offset for use by mmap(2)
-        */
-       uint64_t mmap_offset;
-
        /** Breadcrumb of last rendering to the buffer. */
        uint32_t last_rendering_seqno;
 
index 1af7285ca1626427e6855f44ed8fd1d9eea907af..4ade4e2433790ec67f7a532f8973ea3287aa75c9 100644 (file)
@@ -1392,7 +1392,6 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
 {
        struct drm_device *dev = obj->dev;
        struct drm_gem_mm *mm = dev->mm_private;
-       struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
        struct drm_map_list *list;
        struct drm_local_map *map;
        int ret = 0;
@@ -1431,16 +1430,13 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
                goto out_free_mm;
        }
 
-       /* By now we should be all set, any drm_mmap request on the offset
-        * below will get to our mmap & fault handler */
-       obj_priv->mmap_offset = ((uint64_t) list->hash.key) << PAGE_SHIFT;
-
        return 0;
 
 out_free_mm:
        drm_mm_put_block(list->file_offset_node);
 out_free_list:
        kfree(list->map);
+       list->map = NULL;
 
        return ret;
 }
@@ -1466,9 +1462,10 @@ i915_gem_release_mmap(struct drm_gem_object *obj)
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
 
-       if (dev->dev_mapping)
+       if (unlikely(obj->map_list.map && dev->dev_mapping))
                unmap_mapping_range(dev->dev_mapping,
-                                   obj_priv->mmap_offset, obj->size, 1);
+                                   (loff_t)obj->map_list.hash.key<<PAGE_SHIFT,
+                                   obj->size, 1);
 
        if (obj_priv->fault_mappable) {
                obj_priv->fault_mappable = false;
@@ -1480,24 +1477,13 @@ static void
 i915_gem_free_mmap_offset(struct drm_gem_object *obj)
 {
        struct drm_device *dev = obj->dev;
-       struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
        struct drm_gem_mm *mm = dev->mm_private;
-       struct drm_map_list *list;
+       struct drm_map_list *list = &obj->map_list;
 
-       list = &obj->map_list;
        drm_ht_remove_item(&mm->offset_hash, &list->hash);
-
-       if (list->file_offset_node) {
-               drm_mm_put_block(list->file_offset_node);
-               list->file_offset_node = NULL;
-       }
-
-       if (list->map) {
-               kfree(list->map);
-               list->map = NULL;
-       }
-
-       obj_priv->mmap_offset = 0;
+       drm_mm_put_block(list->file_offset_node);
+       kfree(list->map);
+       list->map = NULL;
 }
 
 /**
@@ -1586,23 +1572,13 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
                goto out;
        }
 
-       if (!obj_priv->mmap_offset) {
+       if (!obj->map_list.map) {
                ret = i915_gem_create_mmap_offset(obj);
                if (ret)
                        goto out;
        }
 
-       args->offset = obj_priv->mmap_offset;
-
-       /*
-        * Pull it into the GTT so that we have a page list (makes the
-        * initial fault faster and any subsequent flushing possible).
-        */
-       if (!obj_priv->agp_mem) {
-               ret = i915_gem_object_bind_to_gtt(obj, 0, true);
-               if (ret)
-                       goto out;
-       }
+       args->offset = (u64)obj->map_list.hash.key << PAGE_SHIFT;
 
 out:
        drm_gem_object_unreference(obj);
@@ -4477,7 +4453,7 @@ static void i915_gem_free_object_tail(struct drm_gem_object *obj)
                return;
        }
 
-       if (obj_priv->mmap_offset)
+       if (obj->map_list.map)
                i915_gem_free_mmap_offset(obj);
 
        drm_gem_object_release(obj);