Skip to contentSkip to conversation

drm/i915: Remove misleading comment in request_alloc

PATCH Superseded Michał Winiarski 4 participants 10 messages May 18, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/i915: Remove misleading comment in request_alloc

Passing NULL ctx to request_alloc would lead to null-ptr-deref. Let's replace the comment with GEM_BUG_ON.

---
 drivers/gpu/drm/i915/i915_gem_request.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_request.c +1 -3
index 1ccf252..1352d3c 100644
@@ -538,9 +538,6 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
  *
  * @engine: engine that we wish to issue the request on.
  * @ctx: context that the request will be associated with.
- *       This can be NULL if the request is not directly related to
- *       any specific user context, in which case this function will
- *       choose an appropriate context to use.
  *
  * Returns a pointer to the allocated request if successful,
  * or an error code if not.
@@ -554,6 +551,7 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
 	struct intel_ring *ring;
 	int ret;
 
+	GEM_BUG_ON(!ctx);
 	lockdep_assert_held(&dev_priv->drm.struct_mutex);
 
 	/* ABI: Before userspace accesses the GPU (e.g. execbuffer), report
Signature · 6 lines
2.9.4

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

PATCH 2/6 drm/i915/guc: Submit GuC workitems containing coalesced requests

To create an upper bound on number of GuC workitems, we need to change the way that requests are being submitted. Rather than submitting each request as an individual workitem, we can do coalescing in a similar way we're handlig execlist submission ports. We also need to stop pretending that we're doing "lite-restore" in GuC submission (we would create a workitem each time we hit this condition).

Cc Chris Wilson <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Oscar Mateo <[email protected]>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 57 ++++++++++++++----------------
 1 file changed, 27 insertions(+), 30 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +27 -30
index b3da056..a930b03 100644
@@ -580,7 +580,7 @@ static int guc_ring_doorbell(struct i915_guc_client *client)
 }
 
 /**
- * __i915_guc_submit() - Submit commands through GuC
+ * i915_guc_submit() - Submit commands through GuC
  * @rq:		request associated with the commands
  *
  * The caller must have already called i915_guc_wq_reserve() above with
@@ -594,7 +594,7 @@ static int guc_ring_doorbell(struct i915_guc_client *client)
  * The only error here arises if the doorbell hardware isn't functioning
  * as expected, which really shouln't happen.
  */
-static void __i915_guc_submit(struct drm_i915_gem_request *rq)
+static void i915_guc_submit(struct drm_i915_gem_request *rq)
 {
 	struct drm_i915_private *dev_priv = rq->i915;
 	struct intel_engine_cs *engine = rq->engine;
@@ -624,12 +624,6 @@ static void __i915_guc_submit(struct drm_i915_gem_request *rq)
 	spin_unlock_irqrestore(&client->wq_lock, flags);
 }
 
-static void i915_guc_submit(struct drm_i915_gem_request *rq)
-{
-	__i915_gem_request_submit(rq);
-	__i915_guc_submit(rq);
-}
-
 static void nested_enable_signaling(struct drm_i915_gem_request *rq)
 {
 	/* If we use dma_fence_enable_sw_signaling() directly, lockdep
@@ -665,12 +659,15 @@ static void port_assign(struct execlist_port *port,
 	nested_enable_signaling(rq);
 }
 
-static bool i915_guc_dequeue(struct intel_engine_cs *engine)
+static void i915_guc_dequeue(struct intel_engine_cs *engine)
 {
 	struct execlist_port *port = engine->execlist_port;
-	struct drm_i915_gem_request *last = port_request(port);
-	struct rb_node *rb;
+	struct drm_i915_gem_request *last = NULL;
 	bool submit = false;
+	struct rb_node *rb;
+
+	if (port_request(port))
+		port++;
 
 	spin_lock_irq(&engine->timeline->lock);
 	rb = engine->execlist_first;
@@ -689,12 +686,16 @@ static bool i915_guc_dequeue(struct intel_engine_cs *engine)
 
 				port_assign(port, last);
 				port++;
+				if (submit) {
+					i915_guc_submit(last);
+					submit = false;
+				}
 			}
 
 			INIT_LIST_HEAD(&rq->priotree.link);
 			rq->priotree.priority = INT_MAX;
 
-			i915_guc_submit(rq);
+			__i915_gem_request_submit(rq);
 			trace_i915_gem_request_in(rq, port_index(port, engine));
 			last = rq;
 			submit = true;
@@ -708,11 +709,11 @@ static bool i915_guc_dequeue(struct intel_engine_cs *engine)
 	}
 done:
 	engine->execlist_first = rb;
-	if (submit)
+	if (submit) {
 		port_assign(port, last);
+		i915_guc_submit(last);
+	}
 	spin_unlock_irq(&engine->timeline->lock);
-
-	return submit;
 }
 
 static void i915_guc_irq_handler(unsigned long data)
@@ -720,24 +721,20 @@ static void i915_guc_irq_handler(unsigned long data)
 	struct intel_engine_cs *engine = (struct intel_engine_cs *)data;
 	struct execlist_port *port = engine->execlist_port;
 	struct drm_i915_gem_request *rq;
-	bool submit;
 
-	do {
-		rq = port_request(&port[0]);
-		while (rq && i915_gem_request_completed(rq)) {
-			trace_i915_gem_request_out(rq);
-			i915_gem_request_put(rq);
+	rq = port_request(&port[0]);
+	while (rq && i915_gem_request_completed(rq)) {
+		trace_i915_gem_request_out(rq);
+		i915_gem_request_put(rq);
 
-			port[0] = port[1];
-			memset(&port[1], 0, sizeof(port[1]));
+		port[0] = port[1];
+		memset(&port[1], 0, sizeof(port[1]));
 
-			rq = port_request(&port[0]);
-		}
+		rq = port_request(&port[0]);
+	}
 
-		submit = false;
-		if (!port_count(&port[1]))
-			submit = i915_guc_dequeue(engine);
-	} while (submit);
+	if (!port_isset(&port[1]))
+		i915_guc_dequeue(engine);
 }
 
 /*
@@ -1268,7 +1265,7 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
 		spin_lock_irq(&engine->timeline->lock);
 		list_for_each_entry(rq, &engine->timeline->requests, link) {
 			guc_client_update_wq_rsvd(client, wqi_size);
-			__i915_guc_submit(rq);
+			i915_guc_submit(rq);
 		}
 		spin_unlock_irq(&engine->timeline->lock);
 	}
Signature · 6 lines
2.9.4

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

PATCH 3/6 drm/i915/guc: Remove GuC wq reservation

In reply to Michał Winiarski

Now that we have an upper bound on the number of work items being sent to GuC, we can remove the reservation.

Cc Chris Wilson <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Michal Wajdeczko <[email protected]>
Cc Oscar Mateo <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c        |  1 -
 drivers/gpu/drm/i915/i915_guc_submission.c | 82 +++---------------------------
 drivers/gpu/drm/i915/intel_lrc.c           | 25 ++-------
 drivers/gpu/drm/i915/intel_uc.h            |  8 ---
 4 files changed, 10 insertions(+), 106 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -1
index 8abb939..19818da 100644
@@ -2481,7 +2481,6 @@ static void i915_guc_client_info(struct seq_file *m,
 	seq_printf(m, "\tWQ size %d, offset: 0x%x, tail %d\n",
 		client->wq_size, client->wq_offset, client->wq_tail);
 
-	seq_printf(m, "\tWork queue full: %u\n", client->no_wq_space);
 	seq_printf(m, "\tFailed doorbell: %u\n", client->b_fail);
 	seq_printf(m, "\tLast submission result: %d\n", client->retcode);
 
drivers/gpu/drm/i915/i915_guc_submission.c +7 -75

149 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.c +3 -22
index 014b30a..5d4f23c 100644
@@ -913,27 +913,14 @@ static int execlists_request_alloc(struct drm_i915_gem_request *request)
 	 */
 	request->reserved_space += EXECLISTS_REQUEST_SIZE;
 
-	if (i915.enable_guc_submission) {
-		/*
-		 * Check that the GuC has space for the request before
-		 * going any further, as the i915_add_request() call
-		 * later on mustn't fail ...
-		 */
-		ret = i915_guc_wq_reserve(request);
-		if (ret)
-			goto err;
-	}
-
 	cs = intel_ring_begin(request, 0);
-	if (IS_ERR(cs)) {
-		ret = PTR_ERR(cs);
-		goto err_unreserve;
-	}
+	if (IS_ERR(cs))
+		return PTR_ERR(cs);
 
 	if (!ce->initialised) {
 		ret = engine->init_context(request);
 		if (ret)
-			goto err_unreserve;
+			return ret;
 
 		ce->initialised = true;
 	}
@@ -947,12 +934,6 @@ static int execlists_request_alloc(struct drm_i915_gem_request *request)
 
 	request->reserved_space -= EXECLISTS_REQUEST_SIZE;
 	return 0;
-
-err_unreserve:
-	if (i915.enable_guc_submission)
-		i915_guc_wq_unreserve(request);
-err:
-	return ret;
 }
 
 /*
drivers/gpu/drm/i915/intel_uc.h +0 -8
index 7618b71..903cf51 100644
@@ -55,10 +55,6 @@ struct drm_i915_gem_request;
  *
  * We also keep a few statistics on failures. Ideally, these should all
  * be zero!
- *   no_wq_space: times that the submission pre-check found no space was
- *                available in the work queue (note, the queue is shared,
- *                not per-engine). It is OK for this to be nonzero, but
- *                it should not be huge!
  *   q_fail: failed to enqueue a work item. This should never happen,
  *           because we check for space beforehand.
  *   b_fail: failed to ring the doorbell. This should never happen, unless
@@ -85,8 +81,6 @@ struct i915_guc_client {
 	uint32_t wq_offset;
 	uint32_t wq_size;
 	uint32_t wq_tail;
-	uint32_t wq_rsvd;
-	uint32_t no_wq_space;
 	uint32_t b_fail;
 	int retcode;
 
@@ -260,8 +254,6 @@ u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
 /* i915_guc_submission.c */
 int i915_guc_submission_init(struct drm_i915_private *dev_priv);
 int i915_guc_submission_enable(struct drm_i915_private *dev_priv);
-int i915_guc_wq_reserve(struct drm_i915_gem_request *rq);
-void i915_guc_wq_unreserve(struct drm_i915_gem_request *request);
 void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
 void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
 struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
Signature · 6 lines
2.9.4

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

Re: [PATCH 3/6] drm/i915/guc: Remove GuC wq reservation

<snip>

drivers/gpu/drm/i915/i915_guc_submission.c int i915_guc_submission_enable(struct drm_i915_private *dev_priv) · line 1160

Quoted 9 lines

static void nested_enable_signaling(struct drm_i915_gem_request *rq)

drivers/gpu/drm/i915/i915_guc_submission.c +3 -0
@@ -1223,6 +1155,9 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
 	enum intel_engine_id id;
 	int err;
 
+	BUILD_BUG_ON(ARRAY_SIZE(engine->execlist_port) *
+		     sizeof(struct guc_wq_item) > GUC_WQ_SIZE);
+

I believe we also need to multiply by I915_NUM_ENGINES here since we share the WQ across all engines.

Quoted 12 lines
drivers/gpu/drm/i915/i915_guc_submission.c +0 -1
 	if (!client) {
 		client = guc_client_alloc(dev_priv,
 					  INTEL_INFO(dev_priv)->ring_mask,
@@ -1250,7 +1185,6 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
 	guc_interrupts_capture(dev_priv);
 
 	for_each_engine(engine, dev_priv, id) {
-		const int wqi_size = sizeof(struct guc_wq_item);
 		struct drm_i915_gem_request *rq;
 
 		/* The tasklet was initialised by execlists, and may be in

drivers/gpu/drm/i915/i915_guc_submission.c int i915_guc_submission_enable(struct drm_i915_private *dev_priv) · line 1201

Quoted 7 lines
drivers/gpu/drm/i915/i915_guc_submission.c +1 -2
@@ -1263,10 +1197,8 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
 
 		/* Replay the current set of previously submitted requests */
 		spin_lock_irq(&engine->timeline->lock);
-		list_for_each_entry(rq, &engine->timeline->requests, link) {
-			guc_client_update_wq_rsvd(client, wqi_size);
+		list_for_each_entry(rq, &engine->timeline->requests, link)
 			i915_guc_submit(rq);

Aren't we potentially sending requests that were squashed in i915_guc_dequeue on different wq items here, thus potentially (although unlikely) overflowing the wq?

Thanks,
Daniele

drivers/gpu/drm/i915/i915_guc_submission.c int i915_guc_submission_enable(struct drm_i915_private *dev_priv) · line 1204

Quoted 4 lines
drivers/gpu/drm/i915/i915_guc_submission.c +0 -1
-		}
 		spin_unlock_irq(&engine->timeline->lock);
 	}
 

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

#4 lore raw

PATCH 4/6 drm/i915/scheduler: Remember request priority throughout its lifetime

In reply to Michał Winiarski

Since request can be unsubmitted, we need to avoid overriding its priority during submission. Otherwise we won't be able to resubmit it with correct priority.

v2: Limit DFS by excluding completed requests (Chris)

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
---
 drivers/gpu/drm/i915/i915_guc_submission.c |  1 -
 drivers/gpu/drm/i915/intel_lrc.c           | 13 ++++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_guc_submission.c +0 -1
index 4c853fb7..e53d867 100644
@@ -625,7 +625,6 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
 			}
 
 			INIT_LIST_HEAD(&rq->priotree.link);
-			rq->priotree.priority = INT_MAX;
 
 			__i915_gem_request_submit(rq);
 			trace_i915_gem_request_in(rq, port_index(port, engine));
drivers/gpu/drm/i915/intel_lrc.c +10 -3
index 5d4f23c..1255724 100644
@@ -487,7 +487,6 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
 			}
 
 			INIT_LIST_HEAD(&rq->priotree.link);
-			rq->priotree.priority = INT_MAX;
 
 			__i915_gem_request_submit(rq);
 			trace_i915_gem_request_in(rq, port_index(port, engine));
@@ -771,9 +770,17 @@ static void execlists_schedule(struct drm_i915_gem_request *request, int prio)
 		 * engines.
 		 */
 		list_for_each_entry(p, &pt->signalers_list, signal_link) {
+			struct drm_i915_gem_request *s =
+				container_of(p->signaler, typeof(*s), priotree);
+
 			GEM_BUG_ON(p->signaler->priority < pt->priority);
-			if (prio > READ_ONCE(p->signaler->priority))
-				list_move_tail(&p->dfs_link, &dfs);
+			if (prio <= READ_ONCE(p->signaler->priority))
+				continue;
+
+			if (i915_gem_request_completed(s))
+				continue;
+
+			list_move_tail(&p->dfs_link, &dfs);
 		}
 
 		list_safe_reset_next(dep, p, dfs_link);
Signature · 6 lines
2.9.4

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

PATCH 5/6 drm/i915/scheduler: Split insert_request

In reply to Michał Winiarski

We'd like to reuse the priolist lookup in request resubmission path, let's split insert_request to make that happen.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
---
 drivers/gpu/drm/i915/intel_lrc.c | 65 ++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +39 -26
index 1255724..c43ca1b 100644
@@ -627,20 +627,15 @@ static void intel_lrc_irq_handler(unsigned long data)
 	intel_uncore_forcewake_put(dev_priv, engine->fw_domains);
 }
 
-static bool
-insert_request(struct intel_engine_cs *engine,
-	       struct i915_priotree *pt,
-	       int prio)
+static struct i915_priolist *
+priolist_lookup(struct intel_engine_cs *engine, int prio, bool *first)
 {
 	struct i915_priolist *p;
 	struct rb_node **parent, *rb;
-	bool first = true;
 
 	if (unlikely(engine->no_priolist))
 		prio = I915_PRIORITY_NORMAL;
-
-find_priolist:
-	/* most positive priority is scheduled first, equal priorities fifo */
+	*first = true;
 	rb = NULL;
 	parent = &engine->execlist_queue.rb_node;
 	while (*parent) {
@@ -650,10 +645,10 @@ insert_request(struct intel_engine_cs *engine,
 			parent = &rb->rb_left;
 		} else if (prio < p->priority) {
 			parent = &rb->rb_right;
-			first = false;
+			*first = false;
 		} else {
-			list_add_tail(&pt->link, &p->requests);
-			return false;
+			*first = false;
+			return p;
 		}
 	}
 
@@ -661,20 +656,10 @@ insert_request(struct intel_engine_cs *engine,
 		p = &engine->default_priolist;
 	} else {
 		p = kmem_cache_alloc(engine->i915->priorities, GFP_ATOMIC);
-		/* Convert an allocation failure to a priority bump */
+
 		if (unlikely(!p)) {
-			prio = I915_PRIORITY_NORMAL; /* recurses just once */
-
-			/* To maintain ordering with all rendering, after an
-			 * allocation failure we have to disable all scheduling.
-			 * Requests will then be executed in fifo, and schedule
-			 * will ensure that dependencies are emitted in fifo.
-			 * There will be still some reordering with existing
-			 * requests, so if userspace lied about their
-			 * dependencies that reordering may be visible.
-			 */
-			engine->no_priolist = true;
-			goto find_priolist;
+			*first = false;
+			return ERR_PTR(-ENOMEM);
 		}
 	}
 
@@ -683,11 +668,39 @@ insert_request(struct intel_engine_cs *engine,
 	rb_insert_color(&p->node, &engine->execlist_queue);
 
 	INIT_LIST_HEAD(&p->requests);
-	list_add_tail(&pt->link, &p->requests);
 
-	if (first)
+	if (*first)
 		engine->execlist_first = &p->node;
 
+	return p;
+}
+
+static bool
+insert_request(struct intel_engine_cs *engine,
+	       struct i915_priotree *pt,
+	       int prio)
+{
+	struct i915_priolist *p;
+	bool first = false;
+
+	p = priolist_lookup(engine, prio, &first);
+
+	if (unlikely(IS_ERR(p))) {
+		/* To maintain ordering with all rendering, after an
+		 * allocation failure we have to disable all scheduling.
+		 * Requests will then be executed in fifo, and schedule
+		 * will ensure that dependencies are emitted in fifo.
+		 * There will be still some reordering with existing
+		 * request, so if userspace lied about their
+		 * dependdencies that reordering may be visible.
+		 */
+		engine->no_priolist = true;
+		p = priolist_lookup(engine, I915_PRIORITY_NORMAL, &first);
+	}
+
+	/* most positive priority is scheduled first, equal priorities fifo */
+	list_add_tail(&pt->link, &p->requests);
+
 	return first;
 }
 
Signature · 6 lines
2.9.4

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

Re: [PATCH 5/6] drm/i915/scheduler: Split insert_request

Quoted 64 lines · Michał Winiarski

We'd like to reuse the priolist lookup in request resubmission path, let's split insert_request to make that happen.

Cc Chris Wilson <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
---
 drivers/gpu/drm/i915/intel_lrc.c | 65 ++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +7 -16
index 1255724..c43ca1b 100644
@@ -627,20 +627,15 @@ static void intel_lrc_irq_handler(unsigned long data)
 	intel_uncore_forcewake_put(dev_priv, engine->fw_domains);
 }
 
-static bool
-insert_request(struct intel_engine_cs *engine,
-	       struct i915_priotree *pt,
-	       int prio)
+static struct i915_priolist *
+priolist_lookup(struct intel_engine_cs *engine, int prio, bool *first)
 {
 	struct i915_priolist *p;
 	struct rb_node **parent, *rb;
-	bool first = true;
 
 	if (unlikely(engine->no_priolist))
 		prio = I915_PRIORITY_NORMAL;
-
-find_priolist:
-	/* most positive priority is scheduled first, equal priorities fifo */
+	*first = true;
 	rb = NULL;
 	parent = &engine->execlist_queue.rb_node;
 	while (*parent) {
@@ -650,10 +645,10 @@ insert_request(struct intel_engine_cs *engine,
 			parent = &rb->rb_left;
 		} else if (prio < p->priority) {
 			parent = &rb->rb_right;
-			first = false;
+			*first = false;
 		} else {
-			list_add_tail(&pt->link, &p->requests);
-			return false;
+			*first = false;
+			return p;
 		}
 	}
 
@@ -661,20 +656,10 @@ insert_request(struct intel_engine_cs *engine,
 		p = &engine->default_priolist;
 	} else {
 		p = kmem_cache_alloc(engine->i915->priorities, GFP_ATOMIC);
-		/* Convert an allocation failure to a priority bump */
+
 		if (unlikely(!p)) {
-			prio = I915_PRIORITY_NORMAL; /* recurses just once */
-
-			/* To maintain ordering with all rendering, after an
-			 * allocation failure we have to disable all scheduling.

drivers/gpu/drm/i915/intel_lrc.c insert_request(struct intel_engine_cs *engine, · line 662

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -8
-			 * Requests will then be executed in fifo, and schedule
-			 * will ensure that dependencies are emitted in fifo.
-			 * There will be still some reordering with existing
-			 * requests, so if userspace lied about their
-			 * dependencies that reordering may be visible.
-			 */
-			engine->no_priolist = true;
-			goto find_priolist;
+			*first = false;
+			return ERR_PTR(-ENOMEM);

You still have to handle the allocation failure on unsubmit, so keep the goto here.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 6/6 drm/i915/scheduler: Use priorities when resubmitting after reset

In reply to Michał Winiarski

Now that we're able to unsubmit requests, we can take advantage of it during reset. Rather than resubmitting the previous workload directly to GuC/ELSP, we can simply move the requests back to priority queue, submitting from the tasklet instead.

v2: Move the tasklet schedule out for legacy ringbuffer submission

Cc Chris Wilson <[email protected]>
Cc Michel Thierry <[email protected]>
Cc Mika Kuoppala <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c            |   6 +-
 drivers/gpu/drm/i915/i915_guc_submission.c |   9 --
 drivers/gpu/drm/i915/intel_lrc.c           | 149 ++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_lrc.h           |   1 +
 4 files changed, 95 insertions(+), 70 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -5
index 02adf82..3eeb061 100644
@@ -3019,15 +3019,11 @@ static void engine_set_wedged(struct intel_engine_cs *engine)
 	 */
 
 	if (i915.enable_execlists) {
-		struct execlist_port *port = engine->execlist_port;
 		unsigned long flags;
-		unsigned int n;
 
 		spin_lock_irqsave(&engine->timeline->lock, flags);
 
-		for (n = 0; n < ARRAY_SIZE(engine->execlist_port); n++)
-			i915_gem_request_put(port_request(&port[n]));
-		memset(engine->execlist_port, 0, sizeof(engine->execlist_port));
+		intel_lr_clear_execlist_ports(engine);
 		engine->execlist_queue = RB_ROOT;
 		engine->execlist_first = NULL;
 
drivers/gpu/drm/i915/i915_guc_submission.c +0 -9
index e53d867..73ed40d 100644
@@ -1184,21 +1184,12 @@ int i915_guc_submission_enable(struct drm_i915_private *dev_priv)
 	guc_interrupts_capture(dev_priv);
 
 	for_each_engine(engine, dev_priv, id) {
-		struct drm_i915_gem_request *rq;
-
 		/* The tasklet was initialised by execlists, and may be in
 		 * a state of flux (across a reset) and so we just want to
 		 * take over the callback without changing any other state
 		 * in the tasklet.
 		 */
 		engine->irq_tasklet.func = i915_guc_irq_handler;
-		clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
-
-		/* Replay the current set of previously submitted requests */
-		spin_lock_irq(&engine->timeline->lock);
-		list_for_each_entry(rq, &engine->timeline->requests, link)
-			i915_guc_submit(rq);
-		spin_unlock_irq(&engine->timeline->lock);
 	}
 
 	return 0;
drivers/gpu/drm/i915/intel_lrc.c +93 -56

192 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +1 -0
index 52b3a1f..8e1ef4d 100644
@@ -83,6 +83,7 @@ uint64_t intel_lr_context_descriptor(struct i915_gem_context *ctx,
 				     struct intel_engine_cs *engine);
 
 /* Execlists */
+void intel_lr_clear_execlist_ports(struct intel_engine_cs *engine);
 int intel_sanitize_enable_execlists(struct drm_i915_private *dev_priv,
 				    int enable_execlists);
 
Signature · 6 lines
2.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw
In reply to Michał Winiarski
Quoted 23 lines · Michał Winiarski

Passing NULL ctx to request_alloc would lead to null-ptr-deref. Let's replace the comment with GEM_BUG_ON.

---
 drivers/gpu/drm/i915/i915_gem_request.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_request.c +0 -3
index 1ccf252..1352d3c 100644
@@ -538,9 +538,6 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
  *
  * @engine: engine that we wish to issue the request on.
  * @ctx: context that the request will be associated with.
- *       This can be NULL if the request is not directly related to
- *       any specific user context, in which case this function will
- *       choose an appropriate context to use.
  *
  * Returns a pointer to the allocated request if successful,
  * or an error code if not.

drivers/gpu/drm/i915/i915_gem_request.c i915_gem_request_alloc(struct intel_engine_cs *engine, · line 554

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_request.c +1 -0
@@ -554,6 +551,7 @@ i915_gem_request_alloc(struct intel_engine_cs *engine,
 	struct intel_ring *ring;
 	int ret;
 
+	GEM_BUG_ON(!ctx);

We try not to use BUG_ON for NULL pointer protection, as the NULL pointer GPF is often enough to pinpoint the error. NULL function pointers tend to be the exception.

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_request.c +0 -0
 	lockdep_assert_held(&dev_priv->drm.struct_mutex);
 
 	/* ABI: Before userspace accesses the GPU (e.g. execbuffer), report
Signature · 6 lines
2.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915: Remove misleading comment in request_alloc

In reply to Michał Winiarski
== Series Details ==

== Series Details ==

Series: series starting with [1/6] drm/i915: Remove misleading comment in request_alloc
URL : https://patchwork.freedesktop.org/series/24632/
State : failure

== Summary ==

Series 24632v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/24632/revisions/1/mbox/

Test kms_pipe_crc_basic:

        Subgroup hang-read-crc-pipe-a:
                pass       -> INCOMPLETE (fi-bdw-5557u)
                pass       -> INCOMPLETE (fi-bdw-gvtdvm)
                pass       -> INCOMPLETE (fi-skl-6260u)
                pass       -> INCOMPLETE (fi-skl-6700hq)
                pass       -> INCOMPLETE (fi-skl-6700k)
                pass       -> INCOMPLETE (fi-skl-6770hq)
                pass       -> INCOMPLETE (fi-skl-gvtdvm)
                pass       -> INCOMPLETE (fi-bxt-j4205)
                pass       -> INCOMPLETE (fi-kbl-7500u)
        Subgroup hang-read-crc-pipe-c:
                pass       -> INCOMPLETE (fi-bsw-n3050)
fi-bdw-5557u     total:220  pass:211  dwarn:0   dfail:0   fail:0   skip:8  
fi-bdw-gvtdvm    total:220  pass:208  dwarn:2   dfail:0   fail:0   skip:9  
fi-bsw-n3050     total:222  pass:199  dwarn:0   dfail:0   fail:0   skip:22 
fi-bxt-j4205     total:220  pass:203  dwarn:0   dfail:0   fail:0   skip:16 
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:494s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:486s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:416s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:416s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:418s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:501s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:459s
fi-kbl-7500u     total:220  pass:202  dwarn:2   dfail:0   fail:0   skip:15 
fi-skl-6260u     total:220  pass:212  dwarn:0   dfail:0   fail:0   skip:7  
fi-skl-6700hq    total:220  pass:204  dwarn:0   dfail:0   fail:0   skip:15 
fi-skl-6700k     total:220  pass:204  dwarn:0   dfail:0   fail:0   skip:15 
fi-skl-6770hq    total:220  pass:212  dwarn:0   dfail:0   fail:0   skip:7  
fi-skl-gvtdvm    total:220  pass:211  dwarn:0   dfail:0   fail:0   skip:8  
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:534s
fi-snb-2600      total:278  pass:248  dwarn:0   dfail:0   fail:1   skip:29  time:408s

ab08cb2750e769d074b2f147c8298ccd0cd08340 drm-tip: 2017y-05m-18d-15h-36m-17s UTC integration manifest 3aecd4b drm/i915/scheduler: Use priorities when resubmitting after reset
265c955 drm/i915/scheduler: Split insert_request
bacb6c3 drm/i915/scheduler: Remember request priority throughout its lifetime d851994 drm/i915/guc: Remove GuC wq reservation
74794e3 drm/i915/guc: Submit GuC workitems containing coalesced requests
faf48d9 drm/i915: Remove misleading comment in request_alloc

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4741/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx