]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/i915: Kill obj->gtt_offset
authorBen Widawsky <ben@bwidawsk.net>
Fri, 5 Jul 2013 21:41:05 +0000 (14:41 -0700)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 8 Jul 2013 20:04:35 +0000 (22:04 +0200)
With the getters in place from the previous patch this members serves no
purpose other than saving one spare pointer chase, which will be killed
in the next patch anyway.

Moving to VMAs, this members adds unnecessary confusion since an object
may exist at different offsets in different VMs.

v2: Properly preserve the stolen offset. This code is a bit hacky but it
all goes away when we embed the drm_mm_node and removes the need for the
incorrect patch I submitted previously: "Use gtt_space->start for stolen
reservation"

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_stolen.c

index 8a92174109c20a5fed49c42f2f89710ad2c94ada..7b8fbba4c6e7f65fedc3cacdd079d6306632f45e 100644 (file)
@@ -1201,7 +1201,7 @@ enum hdmi_force_audio {
        HDMI_AUDIO_ON,                  /* force turn on HDMI audio */
 };
 
-#define I915_GTT_RESERVED ((struct drm_mm_node *)0x1)
+#define I915_GTT_RESERVED (1<<0)
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
@@ -1329,13 +1329,6 @@ struct drm_i915_gem_object {
        unsigned long exec_handle;
        struct drm_i915_gem_exec_object2 *exec_entry;
 
-       /**
-        * Current offset of the object in GTT space.
-        *
-        * This is the same as gtt_space->start
-        */
-       uint32_t gtt_offset;
-
        struct intel_ring_buffer *ring;
 
        /** Breadcrumb of last rendering to the buffer. */
index b8a0d91f2e2de879e7fe244a8d9eae48053981bf..3ea54c8eec247f460a545c50b18f61eb199aabb9 100644 (file)
@@ -2634,7 +2634,6 @@ i915_gem_object_unbind(struct drm_i915_gem_object *obj)
 
        drm_mm_put_block(obj->gtt_space);
        obj->gtt_space = NULL;
-       obj->gtt_offset = 0;
 
        return 0;
 }
@@ -3164,7 +3163,6 @@ search_free:
        list_add_tail(&obj->mm_list, &dev_priv->mm.inactive_list);
 
        obj->gtt_space = node;
-       obj->gtt_offset = node->start;
 
        fenceable =
                node->size == fence_size &&
index 6f0a4c09e26a91753c97787313c00a653a0a13f2..76a4095452c7324832d9a9b01ea05b835c6b56a0 100644 (file)
@@ -629,18 +629,20 @@ void i915_gem_setup_global_gtt(struct drm_device *dev,
 
        /* Mark any preallocated objects as occupied */
        list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
+               uintptr_t offset = (uintptr_t) obj->gtt_space;
                int ret;
-               DRM_DEBUG_KMS("reserving preallocated space: %x + %zx\n",
-                             obj->gtt_offset, obj->base.size);
+               DRM_DEBUG_KMS("reserving preallocated space: %lx + %zx\n",
+                             offset, obj->base.size);
 
-               BUG_ON(obj->gtt_space != I915_GTT_RESERVED);
+               BUG_ON((offset & I915_GTT_RESERVED) != 0);
+               offset &= ~I915_GTT_RESERVED;
                obj->gtt_space = kzalloc(sizeof(*obj->gtt_space), GFP_KERNEL);
                if (!obj->gtt_space) {
-                       DRM_ERROR("Failed to preserve object at offset %x\n",
-                                 obj->gtt_offset);
+                       DRM_ERROR("Failed to preserve object at offset %lx\n",
+                                 offset);
                        continue;
                }
-               obj->gtt_space->start = obj->gtt_offset;
+               obj->gtt_space->start = (unsigned long)offset;
                obj->gtt_space->size = obj->base.size;
                ret = drm_mm_reserve_node(&dev_priv->mm.gtt_space,
                                          obj->gtt_space);
index 4e6dbbb47dfe64a5d767bd1246198b79279cc3a5..559f75450d35b58aed2faae6765d0b8598bb6175 100644 (file)
@@ -389,10 +389,13 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
                        DRM_DEBUG_KMS("failed to allocate stolen GTT space\n");
                        goto free_out;
                }
-       } else
-               obj->gtt_space = I915_GTT_RESERVED;
+       } else {
+               if (WARN_ON(gtt_offset & ~PAGE_MASK))
+                       DRM_DEBUG_KMS("Cannot preserve non page aligned offset\n");
+               obj->gtt_space =
+                       (struct drm_mm_node *)((uintptr_t)(I915_GTT_RESERVED | gtt_offset));
+       }
 
-       obj->gtt_offset = gtt_offset;
        obj->has_global_gtt_mapping = 1;
 
        list_add_tail(&obj->global_list, &dev_priv->mm.bound_list);