@@ -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;
@@ -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
@@ -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;
}
}
}
@@ -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;
}
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@chris-wilson.co.uk> --- 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(-)