[PATCH 64/77] drm/i915: Priority boost switching to an idle ring
Chris Wilson
chris at chris-wilson.co.uk
Thu May 10 13:23:11 UTC 2018
In order to maximise concurrency between engines, if we queue a request
to a current idle ring, reorder its dependencies to execute that request
as early as possible and ideally improve occupancy of multiple engines
simultaneously.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_request.c | 9 ++++++---
drivers/gpu/drm/i915/i915_scheduler.h | 5 +++--
drivers/gpu/drm/i915/intel_ringbuffer.h | 6 ++++++
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 496895623021..d3e5127333b6 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1114,7 +1114,8 @@ void __i915_request_add(struct i915_request *request, bool flush_caches)
local_bh_disable();
rcu_read_lock(); /* RCU serialisation for set-wedged protection */
if (engine->schedule) {
- struct i915_sched_attr attr = request->gem_context->sched;
+ struct i915_gem_context *ctx = request->gem_context;
+ struct i915_sched_attr attr = ctx->sched;
/*
* Boost priorities to new clients (new request flows).
@@ -1125,8 +1126,10 @@ void __i915_request_add(struct i915_request *request, bool flush_caches)
if (!prev || i915_request_completed(prev))
attr.priority |= I915_PRIORITY_NEWCLIENT;
- engine->schedule(request,
- &attr, request->gem_context->preempt_timeout);
+ if (intel_engine_queue_is_empty(engine))
+ attr.priority |= I915_PRIORITY_STALL;
+
+ engine->schedule(request, &attr, ctx->preempt_timeout);
}
rcu_read_unlock();
i915_sw_fence_commit(&request->submit);
diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
index 099b43730ac9..5752dcea6bc2 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.h
+++ b/drivers/gpu/drm/i915/i915_scheduler.h
@@ -19,11 +19,12 @@ enum {
I915_PRIORITY_INVALID = INT_MIN
};
-#define I915_USER_PRIORITY_SHIFT 1
+#define I915_USER_PRIORITY_SHIFT 2
#define I915_PRIORITY_MASK (-BIT(I915_USER_PRIORITY_SHIFT))
#define I915_USER_PRIORITY(x) ((x) << I915_USER_PRIORITY_SHIFT)
-#define I915_PRIORITY_NEWCLIENT BIT(0)
+#define I915_PRIORITY_NEWCLIENT BIT(1)
+#define I915_PRIORITY_STALL BIT(0)
struct i915_sched_attr {
/**
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 7ffff62d41ee..f34d24945bf0 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -1055,6 +1055,12 @@ gen8_emit_ggtt_write(u32 *cs, u32 value, u32 gtt_offset)
return cs;
}
+static inline bool
+intel_engine_queue_is_empty(const struct intel_engine_cs *engine)
+{
+ return RB_EMPTY_ROOT(&engine->execlists.queue.rb_root);
+}
+
bool intel_engine_is_idle(struct intel_engine_cs *engine);
bool intel_engines_are_idle(struct drm_i915_private *dev_priv);
--
2.17.0
More information about the Intel-gfx-trybot
mailing list