aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Harrison <John.C.Harrison@Intel.com>2015-02-13 06:48:12 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-02-25 16:53:10 -0500
commit98e1bd4ae68e0a122de21795c946ba36a8259f70 (patch)
treeb99d517d8b04653117ab492e7bf752a24a9a2580
parent5e4be7bda1e3ca00c6f49a74991f438c720c6f4e (diff)
drm/i915: Cache ringbuf pointer in request structure
In execlist mode, the ringbuf is a function of the ring and context whereas in legacy mode, it is derived from the ring alone. Thus the calculation required to determine the ringbuf pointer from the ring (and context) also needs to test execlist mode or not. This is messy. Further, the request structure holds a pointer to both the ring and the context for which it was created. Thus, given a request, it is possible to derive the ringbuf in either legacy or execlist mode. Hence it is necessary to pass just the request in to all the low level functions rather than some combination of request, ring, context and ringbuf. However, rather than recalculating it each time, it is much simpler to just cache the ringbuf pointer in the request structure itself. Caching the pointer means the calculation is done once at request creation time and all further code and simply read it directly from the request structure. OTC-Jira: VIZ-5115 Signed-off-by: John Harrison <John.C.Harrison@Intel.com> [danvet: Drop contentless comment in lrc alloc request entirely. And spelling fix in the commit message.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h3
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c14
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c5
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c1
4 files changed, 5 insertions, 18 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ba0f5b690291..239a382c8b55 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2156,8 +2156,9 @@ struct drm_i915_gem_request {
2156 /** Position in the ringbuffer of the end of the whole request */ 2156 /** Position in the ringbuffer of the end of the whole request */
2157 u32 tail; 2157 u32 tail;
2158 2158
2159 /** Context related to this request */ 2159 /** Context and ring buffer related to this request */
2160 struct intel_context *ctx; 2160 struct intel_context *ctx;
2161 struct intel_ringbuffer *ringbuf;
2161 2162
2162 /** Batch buffer related to this request if any */ 2163 /** Batch buffer related to this request if any */
2163 struct drm_i915_gem_object *batch_obj; 2164 struct drm_i915_gem_object *batch_obj;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index f28f0dea6c96..14ca4cd5e6d7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2763,7 +2763,6 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
2763 2763
2764 while (!list_empty(&ring->request_list)) { 2764 while (!list_empty(&ring->request_list)) {
2765 struct drm_i915_gem_request *request; 2765 struct drm_i915_gem_request *request;
2766 struct intel_ringbuffer *ringbuf;
2767 2766
2768 request = list_first_entry(&ring->request_list, 2767 request = list_first_entry(&ring->request_list,
2769 struct drm_i915_gem_request, 2768 struct drm_i915_gem_request,
@@ -2774,23 +2773,12 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
2774 2773
2775 trace_i915_gem_request_retire(request); 2774 trace_i915_gem_request_retire(request);
2776 2775
2777 /* This is one of the few common intersection points
2778 * between legacy ringbuffer submission and execlists:
2779 * we need to tell them apart in order to find the correct
2780 * ringbuffer to which the request belongs to.
2781 */
2782 if (i915.enable_execlists) {
2783 struct intel_context *ctx = request->ctx;
2784 ringbuf = ctx->engine[ring->id].ringbuf;
2785 } else
2786 ringbuf = ring->buffer;
2787
2788 /* We know the GPU must have read the request to have 2776 /* We know the GPU must have read the request to have
2789 * sent us the seqno + interrupt, so use the position 2777 * sent us the seqno + interrupt, so use the position
2790 * of tail of the request to update the last known position 2778 * of tail of the request to update the last known position
2791 * of the GPU head. 2779 * of the GPU head.
2792 */ 2780 */
2793 ringbuf->last_retired_head = request->postfix; 2781 request->ringbuf->last_retired_head = request->postfix;
2794 2782
2795 i915_gem_free_request(request); 2783 i915_gem_free_request(request);
2796 } 2784 }
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 09af288da6d4..a1a2a61118ba 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -888,12 +888,9 @@ static int logical_ring_alloc_request(struct intel_engine_cs *ring,
888 return ret; 888 return ret;
889 } 889 }
890 890
891 /* Hold a reference to the context this request belongs to
892 * (we will need it when the time comes to emit/retire the
893 * request).
894 */
895 request->ctx = ctx; 891 request->ctx = ctx;
896 i915_gem_context_reference(request->ctx); 892 i915_gem_context_reference(request->ctx);
893 request->ringbuf = ctx->engine[ring->id].ringbuf;
897 894
898 ring->outstanding_lazy_request = request; 895 ring->outstanding_lazy_request = request;
899 return 0; 896 return 0;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 4a4a7aec0fc3..94dc98b44adc 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2230,6 +2230,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring)
2230 2230
2231 kref_init(&request->ref); 2231 kref_init(&request->ref);
2232 request->ring = ring; 2232 request->ring = ring;
2233 request->ringbuf = ring->buffer;
2233 request->uniq = dev_private->request_uniq++; 2234 request->uniq = dev_private->request_uniq++;
2234 2235
2235 ret = i915_gem_get_seqno(ring->dev, &request->seqno); 2236 ret = i915_gem_get_seqno(ring->dev, &request->seqno);