diff mbox

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

Message ID 20180331104241.32169-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson March 31, 2018, 10:42 a.m. UTC
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!

Signed-off-by: Chris 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>
---
 drivers/gpu/drm/i915/intel_lrc.c        |  7 +++++--
 drivers/gpu/drm/i915/intel_ringbuffer.h | 13 +++++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

Comments

Daniele Ceraolo Spurio April 2, 2018, 4:15 p.m. UTC | #1
On 31/03/18 03:42, Chris Wilson wrote:
> 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!
> 
> Signed-off-by: Chris 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>
> ---
>   drivers/gpu/drm/i915/intel_lrc.c        |  7 +++++--
>   drivers/gpu/drm/i915/intel_ringbuffer.h | 13 +++++++++++--
>   2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index f60b61bf8b3b..48073987214f 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -183,7 +183,8 @@ static inline bool need_preempt(const struct intel_engine_cs *engine,
>   				const struct i915_request *last,
>   				int prio)
>   {
> -	return engine->i915->preempt_context && prio > max(rq_prio(last), 0);
> +	return (intel_engine_has_preemption(engine) &&
> +		prio > max(rq_prio(last), 0));

This is re-coded in guc_dequeue so we could either use 
intel_engine_has_preemption() over there as well or move
need_preempt() to a common header and call it from there. Apart from 
this the patch LGTM.

Daniele

>   }
>   
>   /**
> @@ -2089,11 +2090,13 @@ static void execlists_set_default_submission(struct intel_engine_cs *engine)
>   	engine->unpark = NULL;
>   
>   	engine->flags |= I915_ENGINE_SUPPORTS_STATS;
> +	if (engine->i915->preempt_context)
> +		engine->flags |= I915_ENGINE_HAS_PREEMPTION;
>   
>   	engine->i915->caps.scheduler =
>   		I915_SCHEDULER_CAP_ENABLED |
>   		I915_SCHEDULER_CAP_PRIORITY;
> -	if (engine->i915->preempt_context)
> +	if (intel_engine_has_preemption(engine))
>   		engine->i915->caps.scheduler |= I915_SCHEDULER_CAP_PREEMPTION;
>   }
>   
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
> index a02c7b3b9d55..1079254e6b89 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.h
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
> @@ -562,6 +562,7 @@ struct intel_engine_cs {
>   
>   #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0)
>   #define I915_ENGINE_SUPPORTS_STATS   BIT(1)
> +#define I915_ENGINE_HAS_PREEMPTION   BIT(2)
>   	unsigned int flags;
>   
>   	/*
> @@ -621,16 +622,24 @@ struct intel_engine_cs {
>   	} 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;
>   }
>   
> -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;
>   }
>   
> +static inline bool
> +intel_engine_has_preemption(const struct intel_engine_cs *engine)
> +{
> +	return engine->flags & I915_ENGINE_HAS_PREEMPTION;
> +}
> +
>   static inline void
>   execlists_set_active(struct intel_engine_execlists *execlists,
>   		     unsigned int bit)
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index f60b61bf8b3b..48073987214f 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -183,7 +183,8 @@  static inline bool need_preempt(const struct intel_engine_cs *engine,
 				const struct i915_request *last,
 				int prio)
 {
-	return engine->i915->preempt_context && prio > max(rq_prio(last), 0);
+	return (intel_engine_has_preemption(engine) &&
+		prio > max(rq_prio(last), 0));
 }
 
 /**
@@ -2089,11 +2090,13 @@  static void execlists_set_default_submission(struct intel_engine_cs *engine)
 	engine->unpark = NULL;
 
 	engine->flags |= I915_ENGINE_SUPPORTS_STATS;
+	if (engine->i915->preempt_context)
+		engine->flags |= I915_ENGINE_HAS_PREEMPTION;
 
 	engine->i915->caps.scheduler =
 		I915_SCHEDULER_CAP_ENABLED |
 		I915_SCHEDULER_CAP_PRIORITY;
-	if (engine->i915->preempt_context)
+	if (intel_engine_has_preemption(engine))
 		engine->i915->caps.scheduler |= I915_SCHEDULER_CAP_PREEMPTION;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index a02c7b3b9d55..1079254e6b89 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -562,6 +562,7 @@  struct intel_engine_cs {
 
 #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0)
 #define I915_ENGINE_SUPPORTS_STATS   BIT(1)
+#define I915_ENGINE_HAS_PREEMPTION   BIT(2)
 	unsigned int flags;
 
 	/*
@@ -621,16 +622,24 @@  struct intel_engine_cs {
 	} 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;
 }
 
-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;
 }
 
+static inline bool
+intel_engine_has_preemption(const struct intel_engine_cs *engine)
+{
+	return engine->flags & I915_ENGINE_HAS_PREEMPTION;
+}
+
 static inline void
 execlists_set_active(struct intel_engine_execlists *execlists,
 		     unsigned int bit)