[Intel-gfx] [PATCH] drm/i915: Don't clflush purged objects on unbind

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 8 23:17:20 CET 2009


If the object is marked as purgeable and we are about to simply truncate
those pages, don't waste time by clearing the cache lines for the
object.  In typical usage this saves around 10% of the clflushes.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

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);
 
-- 
1.6.5.4




More information about the Intel-gfx mailing list