drm/i915: Zap the GTT mapping when transitioning from untiled to tiled.
authorEric Anholt <eric@anholt.net>
Fri, 10 Jul 2009 20:02:26 +0000 (13:02 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 10 Jul 2009 21:10:58 +0000 (14:10 -0700)
As of 52dc7d32b88156248167864f77a9026abe27b432, we could leave an old
linear GTT mapping in place, so that apps trying to GTT-mapped write in
tiled data wouldn't get the fence added, and garbage would get displayed.

Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_tiling.c

index 9d6889799d01ef029ec3e07b3a79d4d68e8371e7..d087528758856c78b5b8e6d6f4a1857dc5be20e4 100644 (file)
@@ -673,6 +673,7 @@ void i915_gem_free_object(struct drm_gem_object *obj);
 int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment);
 void i915_gem_object_unpin(struct drm_gem_object *obj);
 int i915_gem_object_unbind(struct drm_gem_object *obj);
+void i915_gem_release_mmap(struct drm_gem_object *obj);
 void i915_gem_lastclose(struct drm_device *dev);
 uint32_t i915_get_gem_seqno(struct drm_device *dev);
 int i915_gem_object_get_fence_reg(struct drm_gem_object *obj);
index 08d8e5d859555afd65f7734d905fbb803d1d249f..5bf420378b6d547a8146535c36830d84dd7bc087 100644 (file)
@@ -1266,7 +1266,7 @@ out_free_list:
  * mapping will then trigger a page fault on the next user access, allowing
  * fixup by i915_gem_fault().
  */
-static void
+void
 i915_gem_release_mmap(struct drm_gem_object *obj)
 {
        struct drm_device *dev = obj->dev;
index daeae62e1c28b889eb1a56b1e9d8e6d4963a3dd6..a2d527b22ec4f7ba837d9787f11585cf141cf844 100644 (file)
@@ -521,6 +521,12 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
                        goto err;
                }
 
+               /* If we've changed tiling, GTT-mappings of the object
+                * need to re-fault to ensure that the correct fence register
+                * setup is in place.
+                */
+               i915_gem_release_mmap(obj);
+
                obj_priv->tiling_mode = args->tiling_mode;
                obj_priv->stride = args->stride;
        }