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

Chris Wilson chris at chris-wilson.co.uk
Thu Mar 29 01:17:56 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  | 3 +++
 drivers/gpu/drm/i915/intel_lrc.c        | 7 +++++++
 drivers/gpu/drm/i915/intel_ringbuffer.h | 9 +++++++++
 3 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index 12486d8f534b..d895049933d0 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -488,6 +488,7 @@ static void intel_engine_init_execlist(struct intel_engine_cs *engine)
 	BUILD_BUG_ON_NOT_POWER_OF_2(execlists_num_ports(execlists));
 	GEM_BUG_ON(execlists_num_ports(execlists) > EXECLIST_MAX_PORTS);
 
+	execlists->current_priority = INT_MIN;
 	execlists->queue_priority = INT_MIN;
 	execlists->queue = RB_ROOT;
 	execlists->first = NULL;
@@ -1990,6 +1991,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 4ff2b086fcf3..e0c6bec7de70 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -378,12 +378,18 @@ static inline void
 execlists_user_begin(struct intel_engine_execlists *execlists,
 		     const 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_user_end(struct intel_engine_execlists *execlists)
 {
+	execlists->current_priority = INT_MIN;
+
 	execlists_clear_active(execlists, EXECLISTS_ACTIVE_USER);
 }
 
@@ -881,6 +887,7 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine)
 	execlists->queue = RB_ROOT;
 	execlists->first = NULL;
 	GEM_BUG_ON(port_isset(execlists->port));
+	GEM_BUG_ON(execlists->current_priority != INT_MIN);
 
 	spin_unlock(&engine->timeline->lock);
 
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 15d624925594..febb3d0c5d1c 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