Skip to contentSkip to conversation

drm/i915: Untangle execlist tracking

PATCH In review Nick Hoath 2 participants 6 messages Dec 22, 2014

Subsystems (2)
lore
Share & tools
lore

Nick Hoath

author
#0 lore raw

cover drm/i915: Untangle execlist tracking

This patchset merges execlist queue items in to gem requests. It does this by using the reference count added by the "Replace seqno values with request structures" patchset to ensure that the gem request is available for the whole execlist submission lifespan.

v2: merge intel_ctx_submit_request and drm_i915_gem_request, rebase changes &
add cover letter

v3: Rebase over upstreamed "Replace seqno values with request structures" and add overzealous freeing fix.

v4: Removed re-addition of cleanup work queue (found by Daniel Vetter)

Issue: VIZ-4274

Nick Hoath (4):
drm/i915: execlist request keeps ptr/ref to gem_request drm/i915: Removed duplicate members from submit_request drm/i915: Remove FIXME_lrc_ctx backpointer
drm/i915: Subsume intel_ctx_submit_request in to drm_i915_gem_request

 drivers/gpu/drm/i915/i915_debugfs.c     |   4 +-
 drivers/gpu/drm/i915/i915_drv.h         |  24 +++++++
 drivers/gpu/drm/i915/i915_gem.c         |  11 ++-
 drivers/gpu/drm/i915/intel_lrc.c        | 123 +++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_lrc.h        |  18 +++--
 drivers/gpu/drm/i915/intel_ringbuffer.h |  15 ++--
 6 files changed, 122 insertions(+), 73 deletions(-)
Signature · 6 lines
2.1.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH 1/4 drm/i915: execlist request keeps 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.

Issue: VIZ-4274
v1: Rebase after upstream of "Replace seqno values with request structures" patchset.

---
 drivers/gpu/drm/i915/intel_lrc.c | 31 +++++++++++++++++++++++++------
 drivers/gpu/drm/i915/intel_lrc.h |  6 +++++-
 2 files changed, 30 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +25 -6
index 7670a0f..d9eaf2d 100644
@@ -534,7 +534,8 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring)
 
 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;
@@ -553,6 +554,21 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
 	req->ring = ring;
 	req->tail = tail;
 
+	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);
@@ -766,6 +782,7 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)
 			intel_lr_context_unpin(ring, ctx);
 		intel_runtime_pm_put(dev_priv);
 		i915_gem_context_unreference(req->ctx);
+		i915_gem_request_unreference(req->request);
 		list_del(&req->execlist_link);
 		kfree(req);
 	}
@@ -818,7 +835,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;
@@ -828,7 +846,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 intel_lr_context_pin(struct intel_engine_cs *ring,
@@ -972,7 +990,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
@@ -1310,7 +1328,8 @@ 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;
@@ -1332,7 +1351,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 +5 -1
index 960fcbd..7a82bc9 100644
@@ -39,7 +39,9 @@ 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.
@@ -110,6 +112,8 @@ struct intel_ctx_submit_request {
 	struct list_head execlist_link;
 
 	int elsp_submitted;
+
+	struct drm_i915_gem_request *request;
 };
 
 void intel_lrc_irq_handler(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
author
#2 lore raw

PATCH 2/4 drm/i915: Removed duplicate members from submit_request

In reply to Nick Hoath

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

v1: Rebase

---
 drivers/gpu/drm/i915/i915_debugfs.c |  4 ++--
 drivers/gpu/drm/i915/i915_gem.c     |  2 +-
 drivers/gpu/drm/i915/intel_lrc.c    | 20 +++++++++-----------
 drivers/gpu/drm/i915/intel_lrc.h    |  4 ----
 4 files changed, 12 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index e515aad..d4cc482 100644
@@ -1968,11 +1968,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
index 2b6ecfd..8782a4d 100644
@@ -2669,7 +2669,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 -11
index d9eaf2d..a18ea13 100644
@@ -417,7 +417,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;
@@ -433,9 +433,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)
@@ -455,7 +455,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");
@@ -551,9 +551,6 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
 	if (to != ring->default_context)
 		intel_lr_context_pin(ring, to);
 
-	req->ring = ring;
-	req->tail = tail;
-
 	if (!request) {
 		/*
 		 * If there isn't a request associated with this submission,
@@ -568,6 +565,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);
 
@@ -584,7 +582,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);
@@ -774,14 +772,14 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)
 	spin_unlock_irqrestore(&ring->execlist_lock, flags);
 
 	list_for_each_entry_safe(req, tmp, &retired_list, execlist_link) {
-		struct intel_context *ctx = req->ctx;
+		struct intel_context *ctx = req->request->ctx;
 		struct drm_i915_gem_object *ctx_obj =
 				ctx->engine[ring->id].state;
 
 		if (ctx_obj && (ctx != ring->default_context))
 			intel_lr_context_unpin(ring, ctx);
 		intel_runtime_pm_put(dev_priv);
-		i915_gem_context_unreference(req->ctx);
+		i915_gem_context_unreference(ctx);
 		i915_gem_request_unreference(req->request);
 		list_del(&req->execlist_link);
 		kfree(req);
drivers/gpu/drm/i915/intel_lrc.h +0 -4
index 7a82bc9..376c307 100644
@@ -105,10 +105,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;
 
 	int elsp_submitted;
Signature · 6 lines
2.1.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH 2/4] drm/i915: Removed duplicate members from submit_request

Quoted 77 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Nick Hoath
Sent: Monday, December 22, 2014 9:37 AM
To: [email protected]
Cc: [email protected]
Subject: [Intel-gfx] [PATCH 2/4] drm/i915: 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

v1: Rebase

---
 drivers/gpu/drm/i915/i915_debugfs.c |  4 ++--
 drivers/gpu/drm/i915/i915_gem.c     |  2 +-
 drivers/gpu/drm/i915/intel_lrc.c    | 20 +++++++++-----------
 drivers/gpu/drm/i915/intel_lrc.h    |  4 ----
 4 files changed, 12 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index e515aad..d4cc482 100644
@@ -1968,11 +1968,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);
 		}
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
 		seq_putc(m, '\n');
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem.c index 2b6ecfd..8782a4d 100644

drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2669,7 +2669,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/i915_gem.c +0 -0
 	}
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index d9eaf2d..a18ea13 100644
@@ -417,7 +417,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 */
drivers/gpu/drm/i915/intel_lrc.c +0 -0
 			cursor->elsp_submitted = req0->elsp_submitted;
@@ -433,9 +433,9 @@ static void execlists_context_unqueue(struct
 intel_engine_cs *ring)

drivers/gpu/drm/i915/intel_lrc.c static void execlists_context_unqueue(struct · line 440

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -3
 
 	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);

This substitution is wrong since the two tail values are not equal. Look at __i915_add_request() - the value to be assigned to drm_request.tail is sampled before the call to emit_request() or add_request() so doesn't include the commands written in those functions. Furthermore the assignment is done after the call to emit_request() so is not guaranteed to be available when execlists_context_unqueue() executes (e.g. when the execlist queue is empty).

Thomas.

Quoted 82 lines
drivers/gpu/drm/i915/intel_lrc.c +0 -0
 	req0->elsp_submitted++;
drivers/gpu/drm/i915/intel_lrc.c +1 -1
 	if (req1)
@@ -455,7 +455,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) {
drivers/gpu/drm/i915/intel_lrc.c +3 -4
 			WARN(head_req->elsp_submitted == 0,
 			     "Never submitted head request\n"); @@ -551,9
+551,6 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
 	if (to != ring->default_context)
 		intel_lr_context_pin(ring, to);
 
-	req->ring = ring;
-	req->tail = tail;
-
 	if (!request) {
 		/*
 		 * If there isn't a request associated with this submission,
@@ -568,6 +565,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);
@@ -584,7 +582,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");

drivers/gpu/drm/i915/intel_lrc.c +2 -2
 			list_del(&tail_req->execlist_link);
@@ -774,14 +772,14 @@ void intel_execlists_retire_requests(struct
 intel_engine_cs *ring)
 	spin_unlock_irqrestore(&ring->execlist_lock, flags);
 
 	list_for_each_entry_safe(req, tmp, &retired_list, execlist_link) {
-		struct intel_context *ctx = req->ctx;
+		struct intel_context *ctx = req->request->ctx;
 		struct drm_i915_gem_object *ctx_obj =
 				ctx->engine[ring->id].state;
 
 		if (ctx_obj && (ctx != ring->default_context))
 			intel_lr_context_unpin(ring, ctx);
 		intel_runtime_pm_put(dev_priv);
-		i915_gem_context_unreference(req->ctx);
+		i915_gem_context_unreference(ctx);
 		i915_gem_request_unreference(req->request);
 		list_del(&req->execlist_link);
drivers/gpu/drm/i915/intel_lrc.c +0 -0
 		kfree(req);
drivers/gpu/drm/i915/intel_lrc.h +0 -4
index 7a82bc9..376c307 100644
@@ -105,10 +105,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;
 

int elsp_submitted;
--
2.1.1

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#4 lore raw

PATCH 3/4 drm/i915: Remove FIXME_lrc_ctx backpointer

In reply to Nick Hoath

The 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.
v3: Rebase

---
 drivers/gpu/drm/i915/i915_gem.c         |  7 ++--
 drivers/gpu/drm/i915/intel_lrc.c        | 68 ++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_lrc.h        |  8 +++-
 drivers/gpu/drm/i915/intel_ringbuffer.h | 15 ++++----
 4 files changed, 57 insertions(+), 41 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -4
index 8782a4d..73c1a22 100644
@@ -2435,8 +2435,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;
 
@@ -2449,7 +2448,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 {
@@ -2466,7 +2465,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);
+		ret = ring->emit_request(ringbuf, request->ctx, request);
 		if (ret)
 			return ret;
 	} else {
drivers/gpu/drm/i915/intel_lrc.c +41 -27

270 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +6 -2
index 376c307..80a80ea 100644
@@ -38,9 +38,11 @@ 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
@@ -63,7 +65,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 +7 -8
index 6dbb6f4..cabf48f 100644
@@ -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 {
@@ -239,11 +234,15 @@ struct  intel_engine_cs {
 	struct list_head execlist_retired_req_list;
 	u8 next_context_status_buffer;
 	u32             irq_keep_mask; /* bitmask for interrupts that should not be masked */
-	int		(*emit_request)(struct intel_ringbuffer *ringbuf);
+	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
author
#5 lore raw

PATCH 4/4 drm/i915: Subsume intel_ctx_submit_request in to drm_i915_gem_request

In reply to Nick Hoath

Move all remaining elements that were unique to execlists queue items in to the associated request.

Issue: VIZ-4274

v2: Rebase. Fixed issue of overzealous freeing of request.
v3: Removed re-addition of cleanup work queue (found by Daniel Vetter)

---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 +++----
 drivers/gpu/drm/i915/i915_drv.h     | 21 ++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem.c     |  6 ++---
 drivers/gpu/drm/i915/intel_lrc.c    | 44 +++++++++++++++----------------------
 4 files changed, 46 insertions(+), 33 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
index d4cc482..b2dfac4 100644
@@ -1928,7 +1928,7 @@ static int i915_execlists(struct seq_file *m, void *data)
 	intel_runtime_pm_get(dev_priv);
 
 	for_each_ring(ring, dev_priv, ring_id) {
-		struct intel_ctx_submit_request *head_req = NULL;
+		struct drm_i915_gem_request *head_req = NULL;
 		int count = 0;
 		unsigned long flags;
 
@@ -1961,18 +1961,18 @@ static int i915_execlists(struct seq_file *m, void *data)
 		list_for_each(cursor, &ring->execlist_queue)
 			count++;
 		head_req = list_first_entry_or_null(&ring->execlist_queue,
-				struct intel_ctx_submit_request, execlist_link);
+				struct drm_i915_gem_request, execlist_link);
 		spin_unlock_irqrestore(&ring->execlist_lock, flags);
 
 		seq_printf(m, "\t%d requests in queue\n", count);
 		if (head_req) {
 			struct drm_i915_gem_object *ctx_obj;
 
-			ctx_obj = head_req->request->ctx->engine[ring_id].state;
+			ctx_obj = head_req->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->request->tail);
+				   head_req->tail);
 		}
 
 		seq_putc(m, '\n');
drivers/gpu/drm/i915/i915_drv.h +21 -0
index 921e4c5..3702073 100644
@@ -2078,6 +2078,27 @@ struct drm_i915_gem_request {
 	struct list_head client_list;
 
 	uint32_t uniq;
+
+	/**
+	 * The ELSP only accepts two elements at a time, so we queue
+	 * context/tail pairs on a given queue (ring->execlist_queue) until the
+	 * hardware is available. The queue serves a double purpose: we also use
+	 * it to keep track of the up to 2 contexts currently in the hardware
+	 * (usually one in execution and the other queued up by the GPU): We
+	 * only remove elements from the head
+	 * of the queue when the hardware informs us that an element has been
+	 * completed.
+	 *
+	 * All accesses to the queue are mediated by a spinlock
+	 * (ring->execlist_lock).
+	 */
+
+	/** Execlist link in the submission queue.*/
+	struct list_head execlist_link;
+
+	/** Execlists no. of times this request has been sent to the ELSP */
+	int elsp_submitted;
+
 };
 
 void i915_gem_request_free(struct kref *req_ref);
drivers/gpu/drm/i915/i915_gem.c +3 -3
index 73c1a22..f7f235c 100644
@@ -2661,14 +2661,14 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
 	 * pinned in place.
 	 */
 	while (!list_empty(&ring->execlist_queue)) {
-		struct intel_ctx_submit_request *submit_req;
+		struct drm_i915_gem_request *submit_req;
 
 		submit_req = list_first_entry(&ring->execlist_queue,
-				struct intel_ctx_submit_request,
+				struct drm_i915_gem_request,
 				execlist_link);
 		list_del(&submit_req->execlist_link);
 		intel_runtime_pm_put(dev_priv);
-		i915_gem_context_unreference(submit_req->request->ctx);
+		i915_gem_context_unreference(submit_req->ctx);
 		kfree(submit_req);
 	}
 
drivers/gpu/drm/i915/intel_lrc.c +18 -26

128 lines not on this page · raw message

Signature · 6 lines
2.1.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx