execlist queue items to hold ptr/ref to gem_request
Subsystems (2)
RFC 1/3 execlist queue items to hold ptr/ref to gem_request
Add a reference and pointer from the execlist queue item to the associated gem request. For execlist requests that don't have a request, create one as a placeholder.
This patchset requires John Harrison's "Replace seqno values with request structures" patchset.
Issue: VIZ-4274
--- drivers/gpu/drm/i915/intel_lrc.c | 31 +++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_lrc.h | 5 ++++- 2 files changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +25 -6
@@ -521,6 +521,7 @@ static void execlists_free_request_task(struct work_struct *work)mutex_lock (&dev->struct_mutex);i915_gem_context_unreference (req->ctx); +i915_gem_request_unreference (req->request);mutex_unlock (&dev->struct_mutex);kfree (req);
@@ -528,7 +529,8 @@ static void execlists_free_request_task(struct work_struct *work)static int execlists_context_queue (struct intel_engine_cs *ring,struct intel_context *to, -u32 tail) +u32 tail, +struct drm_i915_gem_request *request) {struct intel_ctx_submit_request *req =NULL , *cursor;struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -544,6 +546,22 @@ static int execlists_context_queue(struct intel_engine_cs *ring, req->tail = tail;INIT_WORK (&req->work, execlists_free_request_task); +if (!request) + { +/* +* If there isn't a request associated with this submission, +* create one as a temporary holder. +*/ +WARN (1 ,"execlist context submission without request" ); + request =kzalloc (sizeof (*request),GFP_KERNEL ); +if (request ==NULL ) +return -ENOMEM ; + request->ctx = to; + request->ring = ring; + } + req->request = request; +i915_gem_request_reference (request); +intel_runtime_pm_get (dev_priv);spin_lock_irqsave (&ring->execlist_lock, flags);
@@ -778,7 +796,8 @@ int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf)* on a queue waiting for the ELSP to be ready to accept a new context submission. At that * point, the tail *inside* the context is updated and the ELSP written to. */ -void intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf) +void intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, +struct drm_i915_gem_request *request) {struct intel_engine_cs *ring = ringbuf->ring;struct intel_context *ctx = ringbuf->FIXME_lrc_ctx;
@@ -788,7 +807,7 @@ void intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf)if (intel_ring_stopped (ring))return ; -execlists_context_queue (ring, ctx, ringbuf->tail); +execlists_context_queue (ring, ctx, ringbuf->tail, request); } static int logical_ring_alloc_request(struct intel_engine_cs *ring,
@@ -876,7 +895,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,return ret;/* Force the context submission in case we have been skipping it */ -intel_logical_ring_advance_and_submit (ringbuf); +intel_logical_ring_advance_and_submit (ringbuf,NULL );/* With GEM the hangcheck timer should kick us out of the loop, * leaving it early runs the risk of corrupting GEM state (due
@@ -1183,7 +1202,7 @@ static void gen8_set_seqno(struct intel_engine_cs *ring, u32 seqno)intel_write_status_page (ring,I915_GEM_HWS_INDEX , seqno); } -static int gen8_emit_request (struct intel_ringbuffer *ringbuf) +static int gen8_emit_request (struct intel_ringbuffer *ringbuf,struct drm_i915_gem_request *request) {struct intel_engine_cs *ring = ringbuf->ring;u32 cmd;
@@ -1205,7 +1224,7 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf) i915_gem_request_get_seqno(ring->outstanding_lazy_request));intel_logical_ring_emit (ringbuf,MI_USER_INTERRUPT );intel_logical_ring_emit (ringbuf,MI_NOOP ); -intel_logical_ring_advance_and_submit (ringbuf); +intel_logical_ring_advance_and_submit (ringbuf, request);return 0 ; }
drivers/gpu/drm/i915/intel_lrc.h +4 -1
@@ -37,7 +37,8 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring);int intel_logical_rings_init (struct drm_device *dev);int logical_ring_flush_all_caches (struct intel_ringbuffer *ringbuf); -void intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf); +void intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, +struct drm_i915_gem_request *request);/** * intel_logical_ring_advance() - advance the ringbuffer tail * @ringbuf: Ringbuffer to advance.
@@ -107,6 +108,8 @@ struct intel_ctx_submit_request {struct work_struct work;int elsp_submitted; + +struct drm_i915_gem_request *request; };void intel_execlists_handle_ctx_events (struct intel_engine_cs *ring);
Signature · 6 lines
2.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC 2/3 Removed duplicate members from submit_request
Where there were duplicate variables for the tail, context and ring (engine) in the gem request and the execlist queue item, use the one from the request and remove the duplicate from the execlist queue item.
Issue: VIZ-4274
--- drivers/gpu/drm/i915/i915_debugfs.c | 4 ++-- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/intel_lrc.c | 21 +++++++++------------ drivers/gpu/drm/i915/intel_lrc.h | 4 ---- 4 files changed, 12 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
@@ -1891,11 +1891,11 @@ static int i915_execlists(struct seq_file *m, void *data)if (head_req) {struct drm_i915_gem_object *ctx_obj; - ctx_obj = head_req->ctx->engine[ring_id].state; + ctx_obj = head_req->request->ctx->engine[ring_id].state;seq_printf (m,"\tHead request id: %u\n" ,intel_execlists_ctx_id (ctx_obj));seq_printf (m,"\tHead request tail: %u\n" , - head_req->tail); + head_req->request->tail); }seq_putc (m,'\n' );
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2623,7 +2623,7 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, execlist_link);list_del (&submit_req->execlist_link);intel_runtime_pm_put (dev_priv); -i915_gem_context_unreference (submit_req->ctx); +i915_gem_context_unreference (submit_req->request->ctx);kfree (submit_req); }
drivers/gpu/drm/i915/intel_lrc.c +9 -12
@@ -396,7 +396,7 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring) execlist_link) {if (!req0) { req0 = cursor; - }else if (req0->ctx == cursor->ctx) { + }else if (req0->request->ctx == cursor->request->ctx) {/* Same ctx: ignore first request, as second request * will update tail past first request's workload */ cursor->elsp_submitted = req0->elsp_submitted;
@@ -411,9 +411,9 @@ static void execlists_context_unqueue(struct intel_engine_cs *ring)WARN_ON (req1 && req1->elsp_submitted); -execlists_submit_contexts (ring, req0->ctx, req0->tail, - req1 ? req1->ctx :NULL , - req1 ? req1->tail :0 ); +execlists_submit_contexts (ring, req0->request->ctx, req0->request->tail, + req1 ? req1->request->ctx :NULL , + req1 ? req1->request->tail :0 ); req0->elsp_submitted++;if (req1)
@@ -434,7 +434,7 @@ static bool execlists_check_remove_request(struct intel_engine_cs *ring,if (head_req !=NULL ) {struct drm_i915_gem_object *ctx_obj = - head_req->ctx->engine[ring->id].state; + head_req->request->ctx->engine[ring->id].state;if (intel_execlists_ctx_id (ctx_obj) == request_id) {WARN (head_req->elsp_submitted ==0 ,"Never submitted head request\n" );
@@ -514,13 +514,13 @@ static void execlists_free_request_task(struct work_struct *work) {struct intel_ctx_submit_request *req = container_of(work, struct intel_ctx_submit_request, work); -struct drm_device *dev = req->ring->dev; +struct drm_device *dev = req->request->ring->dev;struct drm_i915_private *dev_priv = dev->dev_private;intel_runtime_pm_put (dev_priv);mutex_lock (&dev->struct_mutex); -i915_gem_context_unreference (req->ctx); +i915_gem_context_unreference (req->request->ctx);i915_gem_request_unreference (req->request);mutex_unlock (&dev->struct_mutex);
@@ -540,10 +540,6 @@ static int execlists_context_queue(struct intel_engine_cs *ring, req =kzalloc (sizeof (*req),GFP_KERNEL );if (req ==NULL )return -ENOMEM ; - req->ctx = to; -i915_gem_context_reference (req->ctx); - req->ring = ring; - req->tail = tail;INIT_WORK (&req->work, execlists_free_request_task);if (!request)
@@ -561,6 +557,7 @@ static int execlists_context_queue(struct intel_engine_cs *ring, } req->request = request;i915_gem_request_reference (request); +i915_gem_context_reference (req->request->ctx);intel_runtime_pm_get (dev_priv);
@@ -577,7 +574,7 @@ static int execlists_context_queue(struct intel_engine_cs *ring, struct intel_ctx_submit_request, execlist_link); -if (to == tail_req->ctx) { +if (to == tail_req->request->ctx) {WARN (tail_req->elsp_submitted !=0 ,"More than 2 already-submitted reqs queued\n" );list_del (&tail_req->execlist_link);
drivers/gpu/drm/i915/intel_lrc.h +0 -4
@@ -100,10 +100,6 @@ u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);* All accesses to the queue are mediated by a spinlock (ring->execlist_lock). */ struct intel_ctx_submit_request { -struct intel_context *ctx; -struct intel_engine_cs *ring; -u32 tail; -struct list_head execlist_link;struct work_struct work;
Signature · 6 lines
2.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC 3/3 drm/i915: Remove FIXME_lrc_ctx backpointer
In reply to Nick HoathThe first pass implementation of execlists required a backpointer to the context to be held in the intel_ringbuffer. However the context pointer is available higher in the call stack. Remove the backpointer from the ring buffer structure and instead pass it down through the call stack.
v2: Integrate this changeset with the removal of duplicate request/execlist queue item members.
Issue: VIZ-4268
--- drivers/gpu/drm/i915/i915_gem.c | 7 ++-- drivers/gpu/drm/i915/intel_lrc.c | 67 +++++++++++++++++++++------------ drivers/gpu/drm/i915/intel_lrc.h | 8 +++- drivers/gpu/drm/i915/intel_ringbuffer.h | 12 +++--- 4 files changed, 56 insertions(+), 38 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -4
@@ -2370,8 +2370,7 @@ int __i915_add_request(struct intel_engine_cs *ring,return -ENOMEM ;if (i915.enable_execlists) { -struct intel_context *ctx = request->ctx; - ringbuf = ctx->engine[ring->id].ringbuf; + ringbuf = request->ctx->engine[ring->id].ringbuf; }else ringbuf = ring->buffer;
@@ -2384,7 +2383,7 @@ int __i915_add_request(struct intel_engine_cs *ring,* what. */ if (i915.enable_execlists) { - ret =logical_ring_flush_all_caches (ringbuf); + ret =logical_ring_flush_all_caches (ringbuf, request->ctx);if (ret)return ret; }else {
@@ -2406,7 +2405,7 @@ int __i915_add_request(struct intel_engine_cs *ring, request_ring_position =intel_ring_get_tail (ringbuf);if (i915.enable_execlists) { - ret = ring->emit_request (ringbuf, request); + ret = ring->emit_request (ringbuf, request->ctx, request);if (ret)return ret; }else {
drivers/gpu/drm/i915/intel_lrc.c +42 -25
253 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.h +6 -2
@@ -36,8 +36,10 @@ void intel_logical_ring_stop(struct intel_engine_cs *ring);void intel_logical_ring_cleanup (struct intel_engine_cs *ring);int intel_logical_rings_init (struct drm_device *dev); -int logical_ring_flush_all_caches (struct intel_ringbuffer *ringbuf); +int logical_ring_flush_all_caches (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx);void intel_logical_ring_advance_and_submit (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,struct drm_i915_gem_request *request);/** * intel_logical_ring_advance() - advance the ringbuffer tail
@@ -60,7 +62,9 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,iowrite32 (data, ringbuf->virtual_start + ringbuf->tail); ringbuf->tail +=4 ; } -int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf,int num_dwords); +int intel_logical_ring_begin (struct intel_ringbuffer *ringbuf, +struct intel_context *ctx, +int num_dwords);/* Logical Ring Contexts */ int intel_lr_context_render_state_init(struct intel_engine_cs *ring,
drivers/gpu/drm/i915/intel_ringbuffer.h +5 -7
@@ -99,13 +99,6 @@ struct intel_ringbuffer {struct intel_engine_cs *ring; -/* -* FIXME: This backpointer is an artifact of the history of how the -* execlist patches came into being. It will get removed once the basic -* code has landed. -*/ -struct intel_context *FIXME_lrc_ctx; -u32 head;u32 tail;int space;
@@ -123,6 +116,8 @@ struct intel_ringbuffer {u32 last_retired_head; }; +struct intel_context ; + struct intel_engine_cs { const char *name; enum intel_ring_id {
@@ -238,11 +233,14 @@ struct intel_engine_cs {u8 next_context_status_buffer;u32 irq_keep_mask;/* bitmask for interrupts that should not be masked */ int (*emit_request)(struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,struct drm_i915_gem_request *request);int (*emit_flush)(struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,u32 invalidate_domains,u32 flush_domains);int (*emit_bb_start)(struct intel_ringbuffer *ringbuf, +struct intel_context *ctx,u64 offset,unsigned flags);/**
Signature · 6 lines
2.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · Nick Hoath
Add a reference and pointer from the execlist queue item to the associated gem request. For execlist requests that don't have a request, create one as a placeholder.
This patchset requires John Harrison's "Replace seqno values with request structures" patchset.
The requests are supposed to be a superset of the execlist placeholders, and thus replace them, leaving execlists as just the submission engine...
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx