[Intel-gfx] [PATCH 06/13] drm/i915: move the wait_rendering call into flush_gpu_write_domain

Daniel Vetter daniel.vetter at ffwll.ch
Thu Feb 4 22:05:06 CET 2010


One caller (for the pageflip support) want's a purely pipelined flush.
Distinguish this case by a new parameter. This will also be useful
later on for pipelined fencing.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 drivers/gpu/drm/i915/i915_gem.c |   58 +++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 8b4d159..015c06a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -36,7 +36,8 @@
 
 #define I915_GEM_GPU_DOMAINS	(~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
 
-static void i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj);
+static int i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj,
+						   int pipelined);
 static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj);
 static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj);
 static int i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj,
@@ -2606,8 +2607,7 @@ i915_gem_object_put_fence_reg(struct drm_gem_object *obj)
 	if (!IS_I965G(dev)) {
 		int ret;
 
-		i915_gem_object_flush_gpu_write_domain(obj);
-		ret = i915_gem_object_wait_rendering(obj);
+		ret = i915_gem_object_flush_gpu_write_domain(obj, 0);
 		if (ret != 0)
 			return ret;
 	}
@@ -2756,24 +2756,32 @@ i915_gem_clflush_object(struct drm_gem_object *obj)
 }
 
 /** Flushes any GPU write domain for the object if it's dirty. */
-static void
-i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj)
+static int
+i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj,
+				       int pipelined)
 {
 	struct drm_device *dev = obj->dev;
-	uint32_t old_write_domain;
+	uint32_t old_write_domain, seqno;
+
+	if ((obj->write_domain & I915_GEM_GPU_DOMAINS) != 0) {
+		old_write_domain = obj->write_domain;
+		i915_gem_flush(dev, 0, obj->write_domain);
+		if (!pipelined) {
+			seqno = i915_add_request(dev, NULL);
+			if (seqno == 0)
+				return -ENOMEM;
+		}
+		BUG_ON(obj->write_domain);
 
-	if ((obj->write_domain & I915_GEM_GPU_DOMAINS) == 0)
-		return;
+		trace_i915_gem_object_change_domain(obj,
+						    obj->read_domains,
+						    old_write_domain);
+	}
 
-	/* Queue the GPU write cache flushing we need. */
-	old_write_domain = obj->write_domain;
-	i915_gem_flush(dev, 0, obj->write_domain);
-	(void) i915_add_request(dev, NULL);
-	BUG_ON(obj->write_domain);
+	if (pipelined)
+		return 0;
 
-	trace_i915_gem_object_change_domain(obj,
-					    obj->read_domains,
-					    old_write_domain);
+	return i915_gem_object_wait_rendering(obj);
 }
 
 /** Flushes the GTT write domain for the object if it's dirty. */
@@ -2828,7 +2836,7 @@ i915_gem_object_flush_write_domain(struct drm_gem_object *obj)
 		i915_gem_object_flush_cpu_write_domain(obj);
 		break;
 	default:
-		i915_gem_object_flush_gpu_write_domain(obj);
+		i915_gem_object_flush_gpu_write_domain(obj, 1);
 		break;
 	}
 }
@@ -2850,9 +2858,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write)
 	if (obj_priv->gtt_space == NULL)
 		return -EINVAL;
 
-	i915_gem_object_flush_gpu_write_domain(obj);
-	/* Wait on any GPU rendering and flushing to occur. */
-	ret = i915_gem_object_wait_rendering(obj);
+	ret = i915_gem_object_flush_gpu_write_domain(obj, 0);
 	if (ret != 0)
 		return ret;
 
@@ -2899,9 +2905,7 @@ i915_gem_object_set_to_display_plane(struct drm_gem_object *obj)
 	if (obj_priv->gtt_space == NULL)
 		return -EINVAL;
 
-	i915_gem_object_flush_gpu_write_domain(obj);
-	/* Wait on any GPU rendering and flushing to occur. */
-	ret = i915_gem_object_wait_rendering(obj);
+	ret = i915_gem_object_flush_gpu_write_domain(obj, 0);
 	if (ret != 0)
 		return ret;
 
@@ -2939,9 +2943,7 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
 	uint32_t old_write_domain, old_read_domains;
 	int ret;
 
-	i915_gem_object_flush_gpu_write_domain(obj);
-	/* Wait on any GPU rendering and flushing to occur. */
-	ret = i915_gem_object_wait_rendering(obj);
+	ret = i915_gem_object_flush_gpu_write_domain(obj, 0);
 	if (ret != 0)
 		return ret;
 
@@ -3229,9 +3231,7 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
 	if (offset == 0 && size == obj->size)
 		return i915_gem_object_set_to_cpu_domain(obj, 0);
 
-	i915_gem_object_flush_gpu_write_domain(obj);
-	/* Wait on any GPU rendering and flushing to occur. */
-	ret = i915_gem_object_wait_rendering(obj);
+	ret = i915_gem_object_flush_gpu_write_domain(obj, 0);
 	if (ret != 0)
 		return ret;
 	i915_gem_object_flush_gtt_write_domain(obj);
-- 
1.6.6.1




More information about the Intel-gfx mailing list