diff mbox

drm/i915: Don't clflush purged objects on unbind

Message ID 1260310640-5638-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State Rejected
Headers show

Commit Message

Chris Wilson Dec. 8, 2009, 10:17 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4a400b8..4b0d563 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2028,18 +2028,22 @@  i915_gem_object_unbind(struct drm_gem_object *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
-	 * any possible CPU writes while it's not in the GTT
-	 * are flushed when we go to remap it. This will
-	 * also ensure that all pending GPU writes are finished
-	 * before we unbind.
-	 */
-	ret = i915_gem_object_set_to_cpu_domain(obj, 1);
-	if (ret) {
-		if (ret != -ERESTARTSYS)
-			DRM_ERROR("set_domain failed: %d\n", ret);
-		return ret;
+	if (i915_gem_object_is_purgeable(obj_priv)) {
+		/* Wait on any GPU rendering and flushing to occur. */
+		i915_gem_object_flush_gpu_write_domain(obj);
+		i915_gem_object_flush_gtt_write_domain(obj);
+		ret = i915_gem_object_wait_rendering(obj);
+	} else {
+		/* Move the object to the CPU domain to ensure that
+		 * any possible CPU writes while it's not in the GTT
+		 * are flushed when we go to remap it. This will
+		 * also ensure that all pending GPU writes are finished
+		 * before we unbind.
+		 */
+		ret = i915_gem_object_set_to_cpu_domain(obj, 1);
 	}
+	if (ret)
+		return ret;
 
 	BUG_ON(obj_priv->active);