[Intel-gfx] [PATCH 8/8] drm/i915: Improve GuC request coalescing

Mika Kuoppala mika.kuoppala at linux.intel.com
Wed Sep 20 14:37:05 UTC 2017


Now that we can keep track of what ports we have
dequeued, coalesce only those ports instead of iterating
through all ports.

Cc: MichaƂ Winiarski <michal.winiarski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 31 +++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |  9 +++++++++
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index 359f57a59cba..1057a0fb9f27 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -485,11 +485,13 @@ static void guc_ring_doorbell(struct i915_guc_client *client)
 /**
  * i915_guc_submit() - Submit commands through GuC
  * @engine: engine associated with the commands
+ * @first: index of first execlist port to start coalescing from
  *
  * The only error here arises if the doorbell hardware isn't functioning
  * as expected, which really shouldn't happen.
  */
-static void i915_guc_submit(struct intel_engine_cs *engine)
+static void i915_guc_submit(struct intel_engine_cs *engine,
+			    const unsigned int first)
 {
 	struct drm_i915_private *dev_priv = engine->i915;
 	struct intel_guc *guc = &dev_priv->guc;
@@ -498,7 +500,7 @@ static void i915_guc_submit(struct intel_engine_cs *engine)
 	const unsigned int engine_id = engine->id;
 	unsigned int n;
 
-	for (n = 0; n < execlist_active_ports(el); n++) {
+	for (n = first; n < execlist_active_ports(el); n++) {
 		struct execlist_port *port;
 		struct drm_i915_gem_request *rq;
 		unsigned int count;
@@ -506,21 +508,22 @@ static void i915_guc_submit(struct intel_engine_cs *engine)
 		port = execlist_port_index(el, n);
 
 		rq = port_unpack(port, &count);
-		if (rq && count == 0) {
-			port_set(port, port_pack(rq, ++count));
+		GEM_BUG_ON(!rq);
+		GEM_BUG_ON(count);
 
-			if (i915_vma_is_map_and_fenceable(rq->ring->vma))
-				POSTING_READ_FW(GUC_STATUS);
+		port_set(port, port_pack(rq, ++count));
 
-			spin_lock(&client->wq_lock);
+		if (i915_vma_is_map_and_fenceable(rq->ring->vma))
+			POSTING_READ_FW(GUC_STATUS);
 
-			guc_wq_item_append(client, rq);
-			guc_ring_doorbell(client);
+		spin_lock(&client->wq_lock);
 
-			client->submissions[engine_id] += 1;
+		guc_wq_item_append(client, rq);
+		guc_ring_doorbell(client);
 
-			spin_unlock(&client->wq_lock);
-		}
+		client->submissions[engine_id] += 1;
+
+		spin_unlock(&client->wq_lock);
 	}
 }
 
@@ -566,6 +569,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
 	struct drm_i915_gem_request *last = NULL;
 	bool submit = false;
 	struct rb_node *rb;
+	unsigned int first_idx;
 
 	spin_lock_irq(&engine->timeline->lock);
 	rb = el->first;
@@ -575,6 +579,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
 		goto done;
 
 	port = execlist_request_port(el);
+	first_idx = execlist_get_port_index(el, port);
 
 	do {
 		struct i915_priolist *p = rb_entry(rb, typeof(*p), node);
@@ -614,7 +619,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
 	el->first = rb;
 	if (submit) {
 		port_assign(port, last);
-		i915_guc_submit(engine);
+		i915_guc_submit(engine, first_idx);
 	}
 	spin_unlock_irq(&engine->timeline->lock);
 }
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index efa5a8ea1ecb..f2eb32539300 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -556,6 +556,15 @@ execlist_port_index(struct intel_engine_execlist * const el,
 	return &el->port[__port_idx(el->port_head, n, el->port_mask)];
 }
 
+static inline unsigned int
+execlist_get_port_index(const struct intel_engine_execlist * const el,
+			const struct execlist_port * const port)
+{
+	const unsigned int n = port_index(port, el);
+
+	return __port_idx(n, -el->port_head, el->port_mask);
+}
+
 static inline struct execlist_port *
 execlist_port_head(struct intel_engine_execlist * const el)
 {
-- 
2.11.0



More information about the Intel-gfx mailing list