Commit 5323fd04 authored by Eric Anholt's avatar Eric Anholt

drm/i915: Zap mmaps of objects before unbinding them from the GTT.

Otherwise, some other userland writing into its buffer may race to land
writes either after the CPU thinks it's got a coherent view, or after its
GTT entries have been redirected to point at the scratch page.  Either
result is unpleasant.
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
parent 7839c5d5
...@@ -1915,6 +1915,12 @@ i915_gem_object_unbind(struct drm_gem_object *obj) ...@@ -1915,6 +1915,12 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
return -EINVAL; return -EINVAL;
} }
/* blow away mappings if mapped through GTT */
i915_gem_release_mmap(obj);
if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
i915_gem_clear_fence_reg(obj);
/* Move the object to the CPU domain to ensure that /* Move the object to the CPU domain to ensure that
* any possible CPU writes while it's not in the GTT * any possible CPU writes while it's not in the GTT
* are flushed when we go to remap it. This will * are flushed when we go to remap it. This will
...@@ -1928,20 +1934,14 @@ i915_gem_object_unbind(struct drm_gem_object *obj) ...@@ -1928,20 +1934,14 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
return ret; return ret;
} }
BUG_ON(obj_priv->active);
if (obj_priv->agp_mem != NULL) { if (obj_priv->agp_mem != NULL) {
drm_unbind_agp(obj_priv->agp_mem); drm_unbind_agp(obj_priv->agp_mem);
drm_free_agp(obj_priv->agp_mem, obj->size / PAGE_SIZE); drm_free_agp(obj_priv->agp_mem, obj->size / PAGE_SIZE);
obj_priv->agp_mem = NULL; obj_priv->agp_mem = NULL;
} }
BUG_ON(obj_priv->active);
/* blow away mappings if mapped through GTT */
i915_gem_release_mmap(obj);
if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
i915_gem_clear_fence_reg(obj);
i915_gem_object_put_pages(obj); i915_gem_object_put_pages(obj);
if (obj_priv->gtt_space) { if (obj_priv->gtt_space) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment