[PATCH 02/19] drm/i915/execlists: Snapshot executing context priority

Chris Wilson chris at chris-wilson.co.uk
Thu Mar 29 00:17:12 UTC 2018


When promoting a context to port 0, i.e. execution on HW, take a
snapshot of its priority (strictly, the last request executing from that
context which will be the lowest priority of the batch). We can then use
this value later for a quick estimate as to whether we will need to
preempt the context in order to execute a new request.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_engine_cs.c  | 2 ++
 drivers/gpu/drm/i915/intel_lrc.c        | 5 +++++
 drivers/gpu/drm/i915/intel_ringbuffer.h | 9 +++++++++
 3 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index 12486d8f534b..68d413c9d209 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1990,6 +1990,8 @@ void intel_engine_dump(struct intel_engine_cs *engine,
 	spin_lock_irq(&engine->timeline->lock);
 	list_for_each_entry(rq, &engine->timeline->requests, link)
 		print_request(m, rq, "\t\tE ");
+	drm_printf(m, "\t\tCurrent priority: %d\n",
+		   READ_ONCE(execlists->current_priority));
 	drm_printf(m, "\t\tQueue priority: %d\n", execlists->queue_priority);
 	for (rb = execlists->first; rb; rb = rb_next(rb)) {
 		struct i915_priolist *p =
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 8289e16aad70..ae17fb913a27 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -378,12 +378,16 @@ static inline void
 execlists_begin(struct intel_engine_execlists *execlists,
 		struct execlist_port *port)
 {
+	struct i915_request *rq = port_request (port);
+
 	execlists_set_active_once(execlists, EXECLISTS_ACTIVE_USER);
+	execlists->current_priority = rq_prio(rq);
 }
 
 static inline void
 execlists_end(struct intel_engine_execlists *execlists)
 {
+	execlists->current_priority = INT_MIN;
 	execlists_clear_active(execlists, EXECLISTS_ACTIVE_USER);
 }
 
@@ -867,6 +871,7 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine)
 
 	/* Remaining _unready_ requests will be nop'ed when submitted */
 
+	execlists->current_priority = INT_MIN;
 	execlists->queue_priority = INT_MIN;
 	execlists->queue = RB_ROOT;
 	execlists->first = NULL;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 2e20627e254b..fe5ac2d59d83 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -274,6 +274,15 @@ struct intel_engine_execlists {
 	 */
 	unsigned int port_mask;
 
+	/**
+	 * @current_priority: Current priority executing on port 0
+	 *
+	 * We take a snapshot of the context priority when it is promoted to
+	 * port 0 (i.e. actually running on the HW) and reset to INT_MIN upon
+	 * completion of the last execlists port.
+	 */
+	int current_priority;
+
 	/**
 	 * @queue_priority: Highest pending priority.
 	 *
-- 
2.16.3



More information about the Intel-gfx-trybot mailing list