[PATCH 152/190] drm/i915: Replace request->postfix with ->head for space searching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can simplify the request code slightly by removing the postfix marker
and simply using the head of the request when calculating how much space
will be available when retiring upto that request. (We ignore the end of
the request in case the interrupt arrives before the ring is actually
past the tail and so risk overwritting an active part of the
ringbuffer.) Using the head for the space calculation limits us to
having requests such that any two can fit into the ringbuffer.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_gem_request.c | 12 +++++-------
 drivers/gpu/drm/i915/i915_gem_request.h | 15 ++-------------
 drivers/gpu/drm/i915/i915_gpu_error.c   |  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |  4 ++--
 4 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 4ebe4b7e02d0..9e8e594ce2bd 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -371,7 +371,7 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
 	 * Note this requires that we are always called in request
 	 * completion order.
 	 */
-	request->ring->last_retired_head = request->postfix;
+	request->ring->last_retired_head = request->head;
 
 	__i915_gem_request_retire_active(request);
 	__i915_gem_request_release(request);
@@ -447,17 +447,15 @@ void __i915_add_request(struct drm_i915_gem_request *request, bool flush_caches)
 		WARN(ret, "*_ring_flush_all_caches failed: %d!\n", ret);
 	}
 
+	ret = request->engine->add_request(request);
+	/* Not allowed to fail! */
+	WARN(ret, "emit|add_request failed: %d!\n", ret);
+
 	/* Record the position of the start of the request so that
 	 * should we detect the updated seqno part-way through the
 	 * GPU processing the request, we never over-estimate the
 	 * position of the head.
 	 */
-	request->postfix = intel_ring_get_tail(ring);
-
-	ret = request->engine->add_request(request);
-	/* Not allowed to fail! */
-	WARN(ret, "emit|add_request failed: %d!\n", ret);
-
 	request->head = request_start;
 
 	request->emitted_jiffies = jiffies;
diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
index 2294234b4bf5..d87136edf117 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.h
+++ b/drivers/gpu/drm/i915/i915_gem_request.h
@@ -55,19 +55,8 @@ struct drm_i915_gem_request {
 	  */
 	u32 previous_seqno;
 
-	/** Position in the ringbuffer of the start of the request */
-	u32 head;
-
-	/**
-	 * Position in the ringbuffer of the start of the postfix.
-	 * This is required to calculate the maximum available ringbuffer
-	 * space without overwriting the postfix.
-	 */
-	u32 postfix;
-
-	/** Position in the ringbuffer of the end of the whole request */
-	u32 tail;
-	u32 wa_tail;
+	/** Position in the ringbuffer of the request */
+	u32 head, tail, wa_tail;
 
 	/**
 	 * Context and ring buffer related to this request
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 7c7e0e76260c..a2935d7e9278 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1067,7 +1067,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 			erq = &error->ring[i].requests[count++];
 			erq->seqno = request->fence.seqno;
 			erq->jiffies = request->emitted_jiffies;
-			erq->tail = request->postfix;
+			erq->tail = request->tail;
 		}
 	}
 }
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index dbc76cd54c3e..be2207f551e3 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2213,8 +2213,8 @@ static int wait_for_space(struct drm_i915_gem_request *req, int bytes)
 			continue;
 
 		/* Would completion of this request free enough space? */
-		space = __intel_ring_space(target->postfix, ring->tail,
-					   ring->size);
+		space = __intel_ring_space(target->head,
+					   ring->tail, ring->size);
 		if (space >= bytes)
 			break;
 	}
-- 
2.7.0.rc3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux