Commit 2a694feb authored by Chris Wilson's avatar Chris Wilson

drm/i915: Store preemption capability in engine->flags

Let's avoid having to delve down the pointer chain to see if the i915
device has support for preemption and store that on the engine, which
made the decision in the first place!

v2: Refactor common preemption policy between execlists/guc.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Tomasz Lis <tomasz.lis@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180403183537.5522-1-chris@chris-wilson.co.uk
parent f2605207
...@@ -657,6 +657,16 @@ static void port_assign(struct execlist_port *port, struct i915_request *rq) ...@@ -657,6 +657,16 @@ static void port_assign(struct execlist_port *port, struct i915_request *rq)
port_set(port, i915_request_get(rq)); port_set(port, i915_request_get(rq));
} }
static inline int rq_prio(const struct i915_request *rq)
{
return rq->priotree.priority;
}
static inline int port_prio(const struct execlist_port *port)
{
return rq_prio(port_request(port));
}
static void guc_dequeue(struct intel_engine_cs *engine) static void guc_dequeue(struct intel_engine_cs *engine)
{ {
struct intel_engine_execlists * const execlists = &engine->execlists; struct intel_engine_execlists * const execlists = &engine->execlists;
...@@ -672,12 +682,12 @@ static void guc_dequeue(struct intel_engine_cs *engine) ...@@ -672,12 +682,12 @@ static void guc_dequeue(struct intel_engine_cs *engine)
GEM_BUG_ON(rb_first(&execlists->queue) != rb); GEM_BUG_ON(rb_first(&execlists->queue) != rb);
if (port_isset(port)) { if (port_isset(port)) {
if (engine->i915->preempt_context) { if (intel_engine_has_preemption(engine)) {
struct guc_preempt_work *preempt_work = struct guc_preempt_work *preempt_work =
&engine->i915->guc.preempt_work[engine->id]; &engine->i915->guc.preempt_work[engine->id];
int prio = execlists->queue_priority;
if (execlists->queue_priority > if (__execlists_need_preempt(prio, port_prio(port))) {
max(port_request(port)->priotree.priority, 0)) {
execlists_set_active(execlists, execlists_set_active(execlists,
EXECLISTS_ACTIVE_PREEMPT); EXECLISTS_ACTIVE_PREEMPT);
queue_work(engine->i915->guc.preempt_wq, queue_work(engine->i915->guc.preempt_wq,
......
...@@ -183,7 +183,8 @@ static inline bool need_preempt(const struct intel_engine_cs *engine, ...@@ -183,7 +183,8 @@ static inline bool need_preempt(const struct intel_engine_cs *engine,
const struct i915_request *last, const struct i915_request *last,
int prio) int prio)
{ {
return engine->i915->preempt_context && prio > max(rq_prio(last), 0); return (intel_engine_has_preemption(engine) &&
__execlists_need_preempt(prio, rq_prio(last)));
} }
/** /**
...@@ -2117,11 +2118,13 @@ static void execlists_set_default_submission(struct intel_engine_cs *engine) ...@@ -2117,11 +2118,13 @@ static void execlists_set_default_submission(struct intel_engine_cs *engine)
engine->unpark = NULL; engine->unpark = NULL;
engine->flags |= I915_ENGINE_SUPPORTS_STATS; engine->flags |= I915_ENGINE_SUPPORTS_STATS;
if (engine->i915->preempt_context)
engine->flags |= I915_ENGINE_HAS_PREEMPTION;
engine->i915->caps.scheduler = engine->i915->caps.scheduler =
I915_SCHEDULER_CAP_ENABLED | I915_SCHEDULER_CAP_ENABLED |
I915_SCHEDULER_CAP_PRIORITY; I915_SCHEDULER_CAP_PRIORITY;
if (engine->i915->preempt_context) if (intel_engine_has_preemption(engine))
engine->i915->caps.scheduler |= I915_SCHEDULER_CAP_PREEMPTION; engine->i915->caps.scheduler |= I915_SCHEDULER_CAP_PREEMPTION;
} }
......
...@@ -562,6 +562,7 @@ struct intel_engine_cs { ...@@ -562,6 +562,7 @@ struct intel_engine_cs {
#define I915_ENGINE_NEEDS_CMD_PARSER BIT(0) #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0)
#define I915_ENGINE_SUPPORTS_STATS BIT(1) #define I915_ENGINE_SUPPORTS_STATS BIT(1)
#define I915_ENGINE_HAS_PREEMPTION BIT(2)
unsigned int flags; unsigned int flags;
/* /*
...@@ -621,16 +622,29 @@ struct intel_engine_cs { ...@@ -621,16 +622,29 @@ struct intel_engine_cs {
} stats; } stats;
}; };
static inline bool intel_engine_needs_cmd_parser(struct intel_engine_cs *engine) static inline bool
intel_engine_needs_cmd_parser(const struct intel_engine_cs *engine)
{ {
return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER; return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER;
} }
static inline bool intel_engine_supports_stats(struct intel_engine_cs *engine) static inline bool
intel_engine_supports_stats(const struct intel_engine_cs *engine)
{ {
return engine->flags & I915_ENGINE_SUPPORTS_STATS; return engine->flags & I915_ENGINE_SUPPORTS_STATS;
} }
static inline bool
intel_engine_has_preemption(const struct intel_engine_cs *engine)
{
return engine->flags & I915_ENGINE_HAS_PREEMPTION;
}
static inline bool __execlists_need_preempt(int prio, int last)
{
return prio > max(0, last);
}
static inline void static inline void
execlists_set_active(struct intel_engine_execlists *execlists, execlists_set_active(struct intel_engine_execlists *execlists,
unsigned int bit) unsigned int bit)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment