Skip to contentSkip to conversation

Dynamic EU configuration of Slice/Subslice/EU.

PATCH Superseded Ankit Navik 5 participants 17 messages Dec 11, 2018 – Mar 14, 2019

Subsystems (2)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover Dynamic EU configuration of Slice/Subslice/EU.

drm/i915: Context aware user agnostic EU/Slice/Sub-slice control within kernel

Current GPU configuration code for i915 does not allow us to change EU/Slice/Sub-slice configuration dynamically. Its done only once while context is created.

While particular graphics application is running, if we examine the command requests from user space, we observe that command density is not consistent. It means there is scope to change the graphics configuration dynamically even while context is running actively. This patch series proposes the solution to find the active pending load for all active context at given time and based on that, dynamically perform graphics configuration for each context.

We use a hr (high resolution) timer with i915 driver in kernel to get a callback every few milliseconds (this timer value can be configured through debugfs, default is '0' indicating timer is in disabled state i.e. original system without any intervention).In the timer callback, we examine pending commands for a context in the queue, essentially, we intercept them before they are executed by GPU and we update context with required number of EUs.

Two questions, how did we arrive at right timer value? and what's the right number of EUs? For the prior one, empirical data to achieve best performance in least power was considered. For the later one, we roughly categorized number of EUs logically based on platform. Now we compare number of pending commands with a particular threshold and then set number of EUs accordingly with update context. That threshold is also based on experiments & findings. If GPU is able to catch up with CPU, typically there are no pending commands, the EU config would remain unchanged there. In case there are more pending commands we reprogram context with higher number of EUs. Please note, here we are changing EUs even while context is running by examining pending commands every 'x' milliseconds.

With this solution in place, on KBL-GT3 + Android we saw following pnp benefits, power numbers mentioned here are system power.

App /KPI               | % Power |
                       | Benefit |
                       |  (mW)   |
---------------------------------|
3D Mark (Ice storm)    | 2.30%   |
TRex On screen         | 2.49%   |
TRex Off screen        | 1.32%   |
ManhattanOn screen     | 3.11%   |
Manhattan Off screen   | 0.89%   |
AnTuTu  6.1.4          | 3.42%   |
SynMark2               | 1.70%   |

Note - For KBL (GEN9) we cannot control at sub-slice level, it was always a constraint.
We always controlled number of EUs rather than sub-slices/slices. We have also observed GPU core residencies improves by 1.03%.

Praveen Diwakar (4):
drm/i915: Get active pending request for given context drm/i915: Update render power clock state configuration for given
context
drm/i915: set optimum eu/slice/sub-slice configuration based on load
type
drm/i915: Predictive governor to control eu/slice/subslice

 drivers/gpu/drm/i915/i915_debugfs.c      | 90 +++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_drv.c          |  4 ++
 drivers/gpu/drm/i915/i915_drv.h          |  9 ++++
 drivers/gpu/drm/i915/i915_gem_context.c  | 23 ++++++++
 drivers/gpu/drm/i915/i915_gem_context.h  | 39 ++++++++++++++
 drivers/gpu/drm/i915/i915_request.c      |  2 +
 drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++-
 drivers/gpu/drm/i915/intel_lrc.c         | 16 +++++-
 8 files changed, 226 insertions(+), 4 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v3 1/4 drm/i915: Get active pending request for given context

From: Praveen Diwakar <[email protected]>

This patch gives us the active pending request count which is yet to be submitted to the GPU

V2:
* Change 64-bit to atomic for request count. (Tvrtko Ursulin)

V3:
* Remove mutex for request count.
* Rebase.
* Fixes hitting underflow for predictive request. (Tvrtko Ursulin)

Cc Aravindan Muthukumar <[email protected]>
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 1 +
 drivers/gpu/drm/i915/i915_gem_context.h | 5 +++++
 drivers/gpu/drm/i915/i915_request.c     | 2 ++
 drivers/gpu/drm/i915/intel_lrc.c        | 2 ++
 4 files changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_gem_context.c +1 -0
index b10770c..0bcbe32 100644
@@ -387,6 +387,7 @@ i915_gem_create_context(struct drm_i915_private *dev_priv,
 	}
 
 	trace_i915_context_create(ctx);
+	atomic_set(&ctx->req_cnt, 0);
 
 	return ctx;
 }
drivers/gpu/drm/i915/i915_gem_context.h +5 -0
index b116e49..e824b15 100644
@@ -194,6 +194,11 @@ struct i915_gem_context {
 	 * context close.
 	 */
 	struct list_head handles_list;
+
+	/** req_cnt: tracks the pending commands, based on which we decide to
+	 * go for low/medium/high load configuration of the GPU.
+	 */
+	atomic_t req_cnt;
 };
 
 static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
drivers/gpu/drm/i915/i915_request.c +2 -0
index 5c2c93c..b90795a 100644
@@ -1113,6 +1113,8 @@ void i915_request_add(struct i915_request *request)
 	}
 	request->emitted_jiffies = jiffies;
 
+	atomic_inc(&request->gem_context->req_cnt);
+
 	/*
 	 * Let the backend know a new request has arrived that may need
 	 * to adjust the existing execution schedule due to a high priority
drivers/gpu/drm/i915/intel_lrc.c +2 -0
index 1744792..d33f5ac 100644
@@ -1127,6 +1127,8 @@ static void execlists_submit_request(struct i915_request *request)
 	submit_queue(engine, rq_prio(request));
 
 	spin_unlock_irqrestore(&engine->timeline.lock, flags);
+
+	atomic_dec(&request->gem_context->req_cnt);
 }
 
 static struct i915_request *sched_to_request(struct i915_sched_node *node)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH v3 1/4] drm/i915: Get active pending request for given context

Quoted 13 lines · Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch gives us the active pending request count which is yet to be submitted to the GPU

V2:
* Change 64-bit to atomic for request count. (Tvrtko Ursulin)

V3:
* Remove mutex for request count.
* Rebase.
* Fixes hitting underflow for predictive request. (Tvrtko Ursulin)

Quoted 4 lines
Cc Aravindan Muthukumar <[email protected]>
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>

No, I did not tag this with r-b and you are not allowed to do this!!

Quoted 56 lines
---
  drivers/gpu/drm/i915/i915_gem_context.c | 1 +
  drivers/gpu/drm/i915/i915_gem_context.h | 5 +++++
  drivers/gpu/drm/i915/i915_request.c     | 2 ++
  drivers/gpu/drm/i915/intel_lrc.c        | 2 ++
  4 files changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_gem_context.c +1 -0
index b10770c..0bcbe32 100644
@@ -387,6 +387,7 @@ i915_gem_create_context(struct drm_i915_private *dev_priv,
  	}
 
  	trace_i915_context_create(ctx);
+	atomic_set(&ctx->req_cnt, 0);
 
  	return ctx;
  }
drivers/gpu/drm/i915/i915_gem_context.h +5 -0
index b116e49..e824b15 100644
@@ -194,6 +194,11 @@ struct i915_gem_context {
  	 * context close.
  	 */
  	struct list_head handles_list;
+
+	/** req_cnt: tracks the pending commands, based on which we decide to
+	 * go for low/medium/high load configuration of the GPU.
+	 */
+	atomic_t req_cnt;
  };
 
  static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
drivers/gpu/drm/i915/i915_request.c +2 -0
index 5c2c93c..b90795a 100644
@@ -1113,6 +1113,8 @@ void i915_request_add(struct i915_request *request)
  	}
  	request->emitted_jiffies = jiffies;
 
+	atomic_inc(&request->gem_context->req_cnt);
+
  	/*
  	 * Let the backend know a new request has arrived that may need
  	 * to adjust the existing execution schedule due to a high priority
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index 1744792..d33f5ac 100644

drivers/gpu/drm/i915/intel_lrc.c static void execlists_submit_request(struct i915_request *request) · line 1134

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
@@ -1127,6 +1127,8 @@ static void execlists_submit_request(struct i915_request *request)
  	submit_queue(engine, rq_prio(request));
 
  	spin_unlock_irqrestore(&engine->timeline.lock, flags);
+
+	atomic_dec(&request->gem_context->req_cnt);
  }
 
  static struct i915_request *sched_to_request(struct i915_sched_node *node)

With such placement of accounting you are only considering requests which are not yet runnable (due fences and implicit dependencies). If on the contrary everything is runnable, and there is a lot of it waiting for the GPU to execute it, this counter will show zero. And you'll decide to run in a reduced slice/EU configuration. There has to be some benchmarks which shows the adverse effect of this, you just haven't found it yet I guess.

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

PATCH v3 2/4 drm/i915: Update render power clock state configuration for given context

In reply to Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch will update power clock state register at runtime base on the flag which can set by any governor which computes load and want to update rpcs register.
subsequent patches will have a timer based governor which computes pending load/request.

V2:
* Reuse make_rpcs to get rpcs config. (Tvrtko Ursulin)

V3:
* Rebase.

Cc Aravindan Muthukumar <[email protected]>
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_context.c |  4 ++++
 drivers/gpu/drm/i915/i915_gem_context.h |  9 +++++++++
 drivers/gpu/drm/i915/intel_lrc.c        | 12 +++++++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
index 0bcbe32..d040858 100644
@@ -388,6 +388,10 @@ i915_gem_create_context(struct drm_i915_private *dev_priv,
 
 	trace_i915_context_create(ctx);
 	atomic_set(&ctx->req_cnt, 0);
+	ctx->slice_cnt = hweight8(INTEL_INFO(dev_priv)->sseu.slice_mask);
+	ctx->subslice_cnt = hweight8(
+			INTEL_INFO(dev_priv)->sseu.subslice_mask[0]);
+	ctx->eu_cnt = INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
 
 	return ctx;
 }
drivers/gpu/drm/i915/i915_gem_context.h +9 -0
index e824b15..e000530 100644
@@ -199,6 +199,15 @@ struct i915_gem_context {
 	 * go for low/medium/high load configuration of the GPU.
 	 */
 	atomic_t req_cnt;
+
+	/** slice_cnt: used to set the # of slices to be enabled. */
+	u8 slice_cnt;
+
+	/** subslice_cnt: used to set the # of subslices to be enabled. */
+	u8 subslice_cnt;
+
+	/** eu_cnt: used to set the # of eu to be enabled. */
+	u8 eu_cnt;
 };
 
 static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
drivers/gpu/drm/i915/intel_lrc.c +11 -1
index d33f5ac..a17f676 100644
@@ -171,6 +171,7 @@ static void execlists_init_reg_state(u32 *reg_state,
 				     struct i915_gem_context *ctx,
 				     struct intel_engine_cs *engine,
 				     struct intel_ring *ring);
+static u32 make_rpcs(struct drm_i915_private *dev_priv);
 
 static inline struct i915_priolist *to_priolist(struct rb_node *rb)
 {
@@ -417,12 +418,21 @@ execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state)
 
 static u64 execlists_update_context(struct i915_request *rq)
 {
+	u32 rpcs_config = 0;
 	struct intel_context *ce = rq->hw_context;
+	u32 *reg_state = ce->lrc_reg_state;
+	struct i915_gem_context *ctx = rq->gem_context;
 	struct i915_hw_ppgtt *ppgtt =
 		rq->gem_context->ppgtt ?: rq->i915->mm.aliasing_ppgtt;
-	u32 *reg_state = ce->lrc_reg_state;
 
 	reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail);
+	/* FIXME: To avoid stale rpcs config, move it to context_pin */
+	if (ctx->pid && ctx->name && (rq->engine->id == RCS)) {
+		rpcs_config = make_rpcs(ctx->i915);
+		reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
+		CTX_REG(reg_state, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
+				rpcs_config);
+	}
 
 	/* True 32b PPGTT with dynamic page allocation: update PDP
 	 * registers and point the unallocated PDPs to scratch page.
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [PATCH v3 2/4] drm/i915: Update render power clock state configuration for given context

Quoted 11 lines · Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch will update power clock state register at runtime base on the flag which can set by any governor which computes load and want to update rpcs register.
subsequent patches will have a timer based governor which computes pending load/request.

V2:
* Reuse make_rpcs to get rpcs config. (Tvrtko Ursulin)

Quoted 7 lines

V3:
* Rebase.

Cc Aravindan Muthukumar <[email protected]>
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>

Again, I did not give an r-b for this!

Quoted 56 lines
---
  drivers/gpu/drm/i915/i915_gem_context.c |  4 ++++
  drivers/gpu/drm/i915/i915_gem_context.h |  9 +++++++++
  drivers/gpu/drm/i915/intel_lrc.c        | 12 +++++++++++-
  3 files changed, 24 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
index 0bcbe32..d040858 100644
@@ -388,6 +388,10 @@ i915_gem_create_context(struct drm_i915_private *dev_priv,
 
  	trace_i915_context_create(ctx);
  	atomic_set(&ctx->req_cnt, 0);
+	ctx->slice_cnt = hweight8(INTEL_INFO(dev_priv)->sseu.slice_mask);
+	ctx->subslice_cnt = hweight8(
+			INTEL_INFO(dev_priv)->sseu.subslice_mask[0]);
+	ctx->eu_cnt = INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
 
  	return ctx;
  }
drivers/gpu/drm/i915/i915_gem_context.h +9 -0
index e824b15..e000530 100644
@@ -199,6 +199,15 @@ struct i915_gem_context {
  	 * go for low/medium/high load configuration of the GPU.
  	 */
  	atomic_t req_cnt;
+
+	/** slice_cnt: used to set the # of slices to be enabled. */
+	u8 slice_cnt;
+
+	/** subslice_cnt: used to set the # of subslices to be enabled. */
+	u8 subslice_cnt;
+
+	/** eu_cnt: used to set the # of eu to be enabled. */
+	u8 eu_cnt;
  };
 
  static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
drivers/gpu/drm/i915/intel_lrc.c +1 -0
index d33f5ac..a17f676 100644
@@ -171,6 +171,7 @@ static void execlists_init_reg_state(u32 *reg_state,
  				     struct i915_gem_context *ctx,
  				     struct intel_engine_cs *engine,
  				     struct intel_ring *ring);
+static u32 make_rpcs(struct drm_i915_private *dev_priv);
 
  static inline struct i915_priolist *to_priolist(struct rb_node *rb)
  {

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 421

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
@@ -417,12 +418,21 @@ execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state)
 
  static u64 execlists_update_context(struct i915_request *rq)
  {
+	u32 rpcs_config = 0;

Move to if block where it is used.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 423

Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
  	struct intel_context *ce = rq->hw_context;
+	u32 *reg_state = ce->lrc_reg_state;

No need to touch this.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 424

Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+	struct i915_gem_context *ctx = rq->gem_context;

Can go under the if block as well.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 429

Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
  	struct i915_hw_ppgtt *ppgtt =
  		rq->gem_context->ppgtt ?: rq->i915->mm.aliasing_ppgtt;
-	u32 *reg_state = ce->lrc_reg_state;
 
  	reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail);
+	/* FIXME: To avoid stale rpcs config, move it to context_pin */

This FIXME remains unresolved by the whole series, so that really cannot be like that.

I suggest you add https://patchwork.freedesktop.org/patch/261560/ to your series and rebase this on top.

Which would actually make this patch not do very much and you should probably squash it with the one which actually uses the added fields.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 430

Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+	if (ctx->pid && ctx->name && (rq->engine->id == RCS)) {

Why name and pid? You are using them as proxy for something.. but for what and why? The answer may hold a hint to the proper solution.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 438

Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +5 -0
+		rpcs_config = make_rpcs(ctx->i915);
+		reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
+		CTX_REG(reg_state, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
+				rpcs_config);
+	}
 
  	/* True 32b PPGTT with dynamic page allocation: update PDP
  	 * registers and point the unallocated PDPs to scratch page.

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

Re: [PATCH v3 2/4] drm/i915: Update render power clock state configuration for given context

Hi Tvrtko,

Quoted 110 lines · Tvrtko Ursulin
Quoted 6 lines · Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch will update power clock state register at runtime base on the flag which can set by any governor which computes load and want to update rpcs register.
subsequent patches will have a timer based governor which computes

pending

Quoted 5 lines

load/request.

V2:
* Reuse make_rpcs to get rpcs config. (Tvrtko Ursulin)

Quoted 7 lines

V3:
* Rebase.

Cc Aravindan Muthukumar <[email protected]>
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>

Again, I did not give an r-b for this!

Review

Quoted 9 lines
---
  drivers/gpu/drm/i915/i915_gem_context.c |  4 ++++
  drivers/gpu/drm/i915/i915_gem_context.h |  9 +++++++++
  drivers/gpu/drm/i915/intel_lrc.c        | 12 +++++++++++-
  3 files changed, 24 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem_context.c

drivers/gpu/drm/i915/i915_gem_context.c i915_gem_create_context(struct drm_i915_private

Quoted 4 lines

index 0bcbe32..d040858 100644

drivers/gpu/drm/i915/i915_gem_context.c +0 -0
@@ -388,6 +388,10 @@ i915_gem_create_context(struct drm_i915_private

*dev_priv,

Review

Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_context.c +4 -0
      trace_i915_context_create(ctx);
      atomic_set(&ctx->req_cnt, 0);
+     ctx->slice_cnt = hweight8(INTEL_INFO(dev_priv)->sseu.slice_mask);
+     ctx->subslice_cnt = hweight8(
+                     INTEL_INFO(dev_priv)->sseu.subslice_mask[0]);
+     ctx->eu_cnt = INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
 
      return ctx;
  }
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem_context.h

Quoted 9 lines

index e824b15..e000530 100644

drivers/gpu/drm/i915/i915_gem_context.h +2 -0
@@ -199,6 +199,15 @@ struct i915_gem_context {
       * go for low/medium/high load configuration of the GPU.
       */
      atomic_t req_cnt;
+
+     /** slice_cnt: used to set the # of slices to be enabled. */

drivers/gpu/drm/i915/i915_gem_context.h struct i915_gem_context { · line 213

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.h +7 -0
+     u8 slice_cnt;
+
+     /** subslice_cnt: used to set the # of subslices to be enabled. */
+     u8 subslice_cnt;
+
+     /** eu_cnt: used to set the # of eu to be enabled. */
+     u8 eu_cnt;
  };
 
  static inline bool i915_gem_context_is_closed(const struct

i915_gem_context *ctx)

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/intel_lrc.c

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt

Quoted 12 lines

index d33f5ac..a17f676 100644

drivers/gpu/drm/i915/intel_lrc.c +1 -0
@@ -171,6 +171,7 @@ static void execlists_init_reg_state(u32 *reg_state,
                                   struct i915_gem_context *ctx,
                                   struct intel_engine_cs *engine,
                                   struct intel_ring *ring);
+static u32 make_rpcs(struct drm_i915_private *dev_priv);
 
  static inline struct i915_priolist *to_priolist(struct rb_node *rb)
  {
@@ -417,12 +418,21 @@ execlists_update_context_pdps(struct i915_hw_ppgtt

*ppgtt, u32 *reg_state)

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 421

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
  static u64 execlists_update_context(struct i915_request *rq)
  {
+     u32 rpcs_config = 0;

Move to if block where it is used.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 423

Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
      struct intel_context *ce = rq->hw_context;
+     u32 *reg_state = ce->lrc_reg_state;

No need to touch this.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 424

Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+     struct i915_gem_context *ctx = rq->gem_context;

Can go under the if block as well.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state)

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +0 -1
      struct i915_hw_ppgtt *ppgtt =
              rq->gem_context->ppgtt ?: rq->i915->mm.aliasing_ppgtt;
-     u32 *reg_state = ce->lrc_reg_state;
 
      reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring,

rq->tail);

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 429

Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+     /* FIXME: To avoid stale rpcs config, move it to context_pin */
Quoted 9 lines

This FIXME remains unresolved by the whole series, so that really cannot be like that.

I suggest you add https://patchwork.freedesktop.org/patch/261560/ to your series and rebase this on top.

Which would actually make this patch not do very much and you should probably squash it with the one which actually uses the added fields.

submitted v4 patch and reverted to previous function i.e., get_context_rpcs_config as make_rpcs is changed in mainline.

Regards, Ankit

Quoted 17 lines

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state) · line 430

Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+     if (ctx->pid && ctx->name && (rq->engine->id == RCS)) {

Why name and pid? You are using them as proxy for something.. but for what and why? The answer may hold a hint to the proper solution.

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state)

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+             rpcs_config = make_rpcs(ctx->i915);
+             reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
+             CTX_REG(reg_state, CTX_R_PWR_CLK_STATE,

GEN8_R_PWR_CLK_STATE,

drivers/gpu/drm/i915/intel_lrc.c execlists_update_context_pdps(struct i915_hw_ppgtt *ppgtt, u32 *reg_state)

Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
+                             rpcs_config);
+     }
 
      /* True 32b PPGTT with dynamic page allocation: update PDP
       * registers and point the unallocated PDPs to scratch page.
 
Quoted 8 lines

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

PATCH v3 3/4 drm/i915: set optimum eu/slice/sub-slice configuration based on load type

In reply to Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch will select optimum eu/slice/sub-slice configuration based on type of load (low, medium, high) as input.
Based on our readings and experiments we have predefined set of optimum configuration for each platform(CHT, KBL). i915_gem_context_set_load_type will select optimum configuration from pre-defined optimum configuration table(opt_config).

It also introduce flag update_render_config which can set by any governor.

v2:
* Move static optimum_config to device init time.
* Rename function to appropriate name, fix data types and patch ordering.
* Rename prev_load_type to pending_load_type. (Tvrtko Ursulin)

v3:
* Add safe guard check in i915_gem_context_set_load_type.
* Rename struct from optimum_config to i915_sseu_optimum_config to avoid namespace clashes.
* Reduces memcpy for space efficient.
* Rebase.
* Improved commit message. (Tvrtko Ursulin)

---
 drivers/gpu/drm/i915/i915_drv.h          |  3 ++
 drivers/gpu/drm/i915/i915_gem_context.c  | 18 ++++++++++++
 drivers/gpu/drm/i915/i915_gem_context.h  | 25 +++++++++++++++++
 drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_lrc.c         |  4 ++-
 5 files changed, 94 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 4aca534..4b9a8c5 100644
@@ -1681,6 +1681,9 @@ struct drm_i915_private {
 	struct drm_i915_fence_reg fence_regs[I915_MAX_NUM_FENCES]; /* assume 965 */
 	int num_fence_regs; /* 8 on pre-965, 16 otherwise */
 
+	/* optimal slice/subslice/EU configration state */
+	struct i915_sseu_optimum_config opt_config[LOAD_TYPE_LAST];
+
 	unsigned int fsb_freq, mem_freq, is_ddr3;
 	unsigned int skl_preferred_vco_freq;
 	unsigned int max_cdclk_freq;
drivers/gpu/drm/i915/i915_gem_context.c +18 -0
index d040858..c0ced72 100644
@@ -392,10 +392,28 @@ i915_gem_create_context(struct drm_i915_private *dev_priv,
 	ctx->subslice_cnt = hweight8(
 			INTEL_INFO(dev_priv)->sseu.subslice_mask[0]);
 	ctx->eu_cnt = INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
+	ctx->load_type = 0;
+	ctx->pending_load_type = 0;
 
 	return ctx;
 }
 
+
+void i915_gem_context_set_load_type(struct i915_gem_context *ctx,
+		enum gem_load_type type)
+{
+	struct drm_i915_private *dev_priv = ctx->i915;
+
+	if (GEM_WARN_ON(type > LOAD_TYPE_LAST))
+		return;
+
+	/* Call opt_config to get correct configuration for eu,slice,subslice */
+	ctx->slice_cnt = dev_priv->opt_config[type].slice;
+	ctx->subslice_cnt = dev_priv->opt_config[type].subslice;
+	ctx->eu_cnt = dev_priv->opt_config[type].eu;
+	ctx->pending_load_type = type;
+}
+
 /**
  * i915_gem_context_create_gvt - create a GVT GEM context
  * @dev: drm device *
drivers/gpu/drm/i915/i915_gem_context.h +25 -0
index e000530..a0db13c 100644
@@ -53,6 +53,19 @@ struct intel_context_ops {
 	void (*destroy)(struct intel_context *ce);
 };
 
+enum gem_load_type {
+	LOAD_TYPE_LOW,
+	LOAD_TYPE_MEDIUM,
+	LOAD_TYPE_HIGH,
+	LOAD_TYPE_LAST
+};
+
+struct i915_sseu_optimum_config {
+	u8 slice;
+	u8 subslice;
+	u8 eu;
+};
+
 /**
  * struct i915_gem_context - client state
  *
@@ -208,6 +221,16 @@ struct i915_gem_context {
 
 	/** eu_cnt: used to set the # of eu to be enabled. */
 	u8 eu_cnt;
+
+	/** load_type: The designated load_type (high/medium/low) for a given
+	 * number of pending commands in the command queue.
+	 */
+	enum gem_load_type load_type;
+
+	/** pending_load_type: The earlier load type that the GPU was configured
+	 * for (high/medium/low).
+	 */
+	enum gem_load_type pending_load_type;
 };
 
 static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
@@ -336,6 +359,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
 				    struct drm_file *file_priv);
 int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data,
 				       struct drm_file *file);
+void i915_gem_context_set_load_type(struct i915_gem_context *ctx,
+		enum gem_load_type type);
 
 struct i915_gem_context *
 i915_gem_context_create_kernel(struct drm_i915_private *i915, int prio);
drivers/gpu/drm/i915/intel_device_info.c +45 -2

68 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.c +3 -1
index a17f676..7fb9cd2 100644
@@ -427,11 +427,13 @@ static u64 execlists_update_context(struct i915_request *rq)
 
 	reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail);
 	/* FIXME: To avoid stale rpcs config, move it to context_pin */
-	if (ctx->pid && ctx->name && (rq->engine->id == RCS)) {
+	if (ctx->pid && ctx->name && (rq->engine->id == RCS) &&
+			(ctx->load_type != ctx->pending_load_type)) {
 		rpcs_config = make_rpcs(ctx->i915);
 		reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
 		CTX_REG(reg_state, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
 				rpcs_config);
+		ctx->load_type = ctx->pending_load_type;
 	}
 
 	/* True 32b PPGTT with dynamic page allocation: update PDP
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH v3 3/4] drm/i915: set optimum eu/slice/sub-slice configuration based on load type

Quoted 24 lines · Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch will select optimum eu/slice/sub-slice configuration based on type of load (low, medium, high) as input.
Based on our readings and experiments we have predefined set of optimum configuration for each platform(CHT, KBL). i915_gem_context_set_load_type will select optimum configuration from pre-defined optimum configuration table(opt_config).

It also introduce flag update_render_config which can set by any governor.

v2:
* Move static optimum_config to device init time.
* Rename function to appropriate name, fix data types and patch ordering.
* Rename prev_load_type to pending_load_type. (Tvrtko Ursulin)

v3:
* Add safe guard check in i915_gem_context_set_load_type.
* Rename struct from optimum_config to i915_sseu_optimum_config to avoid namespace clashes.
* Reduces memcpy for space efficient.
* Rebase.
* Improved commit message. (Tvrtko Ursulin)

Quoted 3 lines
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>

Again for the record no, I did not r-b this.

Quoted 16 lines
---
  drivers/gpu/drm/i915/i915_drv.h          |  3 ++
  drivers/gpu/drm/i915/i915_gem_context.c  | 18 ++++++++++++
  drivers/gpu/drm/i915/i915_gem_context.h  | 25 +++++++++++++++++
  drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++++++++++++++++--
  drivers/gpu/drm/i915/intel_lrc.c         |  4 ++-
  5 files changed, 94 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 4aca534..4b9a8c5 100644

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 1685

Quoted 5 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -1681,6 +1681,9 @@ struct drm_i915_private {
  	struct drm_i915_fence_reg fence_regs[I915_MAX_NUM_FENCES]; /* assume 965 */
  	int num_fence_regs; /* 8 on pre-965, 16 otherwise */
 
+	/* optimal slice/subslice/EU configration state */
+	struct i915_sseu_optimum_config opt_config[LOAD_TYPE_LAST];

Make it a pointer to struct i915_sseu_optimum_config.

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
+
  	unsigned int fsb_freq, mem_freq, is_ddr3;
  	unsigned int skl_preferred_vco_freq;
  	unsigned int max_cdclk_freq;
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index d040858..c0ced72 100644

drivers/gpu/drm/i915/i915_gem_context.c i915_gem_create_context(struct drm_i915_private *dev_priv, · line 396

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c +2 -0
@@ -392,10 +392,28 @@ i915_gem_create_context(struct drm_i915_private *dev_priv,
  	ctx->subslice_cnt = hweight8(
  			INTEL_INFO(dev_priv)->sseu.subslice_mask[0]);
  	ctx->eu_cnt = INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
+	ctx->load_type = 0;
+	ctx->pending_load_type = 0;

Not needed because we zero the allocation and probably depend on untouched fields being zero elsewhere.

Quoted 92 lines
drivers/gpu/drm/i915/i915_gem_context.c +16 -0
  	return ctx;
  }
 
+
+void i915_gem_context_set_load_type(struct i915_gem_context *ctx,
+		enum gem_load_type type)
+{
+	struct drm_i915_private *dev_priv = ctx->i915;
+
+	if (GEM_WARN_ON(type > LOAD_TYPE_LAST))
+		return;
+
+	/* Call opt_config to get correct configuration for eu,slice,subslice */
+	ctx->slice_cnt = dev_priv->opt_config[type].slice;
+	ctx->subslice_cnt = dev_priv->opt_config[type].subslice;
+	ctx->eu_cnt = dev_priv->opt_config[type].eu;
+	ctx->pending_load_type = type;
+}
+
  /**
   * i915_gem_context_create_gvt - create a GVT GEM context
   * @dev: drm device *
drivers/gpu/drm/i915/i915_gem_context.h +25 -0
index e000530..a0db13c 100644
@@ -53,6 +53,19 @@ struct intel_context_ops {
  	void (*destroy)(struct intel_context *ce);
  };
 
+enum gem_load_type {
+	LOAD_TYPE_LOW,
+	LOAD_TYPE_MEDIUM,
+	LOAD_TYPE_HIGH,
+	LOAD_TYPE_LAST
+};
+
+struct i915_sseu_optimum_config {
+	u8 slice;
+	u8 subslice;
+	u8 eu;
+};
+
  /**
   * struct i915_gem_context - client state
   *
@@ -208,6 +221,16 @@ struct i915_gem_context {
 
  	/** eu_cnt: used to set the # of eu to be enabled. */
  	u8 eu_cnt;
+
+	/** load_type: The designated load_type (high/medium/low) for a given
+	 * number of pending commands in the command queue.
+	 */
+	enum gem_load_type load_type;
+
+	/** pending_load_type: The earlier load type that the GPU was configured
+	 * for (high/medium/low).
+	 */
+	enum gem_load_type pending_load_type;
  };
 
  static inline bool i915_gem_context_is_closed(const struct i915_gem_context *ctx)
@@ -336,6 +359,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
  				    struct drm_file *file_priv);
  int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data,
  				       struct drm_file *file);
+void i915_gem_context_set_load_type(struct i915_gem_context *ctx,
+		enum gem_load_type type);
 
  struct i915_gem_context *
  i915_gem_context_create_kernel(struct drm_i915_private *i915, int prio);
drivers/gpu/drm/i915/intel_device_info.c +11 -0
index 0ef0c64..33c6310 100644
@@ -741,6 +741,28 @@ void intel_device_info_runtime_init(struct intel_device_info *info)
  		container_of(info, struct drm_i915_private, info);
  	enum pipe pipe;
 
+	struct i915_sseu_optimum_config *opt_config = NULL;
+	/* static table of slice/subslice/EU for Cherryview */
+	struct i915_sseu_optimum_config chv_config[LOAD_TYPE_LAST] = {
+		{1, 1, 4},	/* Low */
+		{1, 1, 6},	/* Medium */
+		{1, 2, 6}	/* High */
+	};
+
+	/* static table of slice/subslice/EU for KBL GT2 */
+	struct i915_sseu_optimum_config kbl_gt2_config[LOAD_TYPE_LAST] = {
+		{1, 3, 2},	/* Low */

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 764

Quoted 10 lines
drivers/gpu/drm/i915/intel_device_info.c +10 -0
+		{1, 3, 4},	/* Medium */
+		{1, 3, 8}	/* High */
+	};
+
+	/* static table of slice/subslice/EU for KBL GT3 */
+	struct i915_sseu_optimum_config kbl_gt3_config[LOAD_TYPE_LAST] = {
+		{2, 3, 4},	/* Low */
+		{2, 3, 6},	/* Medium */
+		{2, 3, 8}	/* High */
+	};

Move these to file scope as static const.

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 867

Quoted 12 lines
drivers/gpu/drm/i915/intel_device_info.c +3 -1
+
  	if (INTEL_GEN(dev_priv) >= 10) {
  		for_each_pipe(dev_priv, pipe)
  			info->num_scalers[pipe] = 2;
@@ -840,17 +862,38 @@ void intel_device_info_runtime_init(struct intel_device_info *info)
  	/* Initialize slice/subslice/EU info */
  	if (IS_HASWELL(dev_priv))
  		haswell_sseu_info_init(dev_priv);
-	else if (IS_CHERRYVIEW(dev_priv))
+	else if (IS_CHERRYVIEW(dev_priv)) {
  		cherryview_sseu_info_init(dev_priv);
+		opt_config = chv_config;

For my idea to work here and below add:

BUILD_BUG_ON(ARRAY_SIZE(chv_config) != LOAD_TYPE_LAST);

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 877

Quoted 11 lines
drivers/gpu/drm/i915/intel_device_info.c +7 -1
+	}
  	else if (IS_BROADWELL(dev_priv))
  		broadwell_sseu_info_init(dev_priv);
-	else if (INTEL_GEN(dev_priv) == 9)
+	else if (INTEL_GEN(dev_priv) == 9) {
  		gen9_sseu_info_init(dev_priv);
+
+		if (IS_KABYLAKE(dev_priv)) {
+			switch (info->gt) {
+			default:
+				MISSING_CASE(info->gt);

This should probably be silent since absence of sseu tuning is not an error on other platforms.

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 883

Quoted 6 lines
drivers/gpu/drm/i915/intel_device_info.c +6 -0
+				/* fall through */
+			case 2:
+				opt_config = kbl_gt2_config;
+			break;
+			case 3:
+				opt_config = kbl_gt3_config;

Would Kabylake table work for other Gen9 platforms?

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 895

Quoted 12 lines
drivers/gpu/drm/i915/intel_device_info.c +7 -0
+			break;
+			}
+		}
+	}
  	else if (INTEL_GEN(dev_priv) == 10)
  		gen10_sseu_info_init(dev_priv);
  	else if (INTEL_GEN(dev_priv) >= 11)
  		gen11_sseu_info_init(dev_priv);
 
+	if (opt_config)
+		memcpy(dev_priv->opt_config, opt_config, LOAD_TYPE_LAST *
+			sizeof(struct i915_sseu_optimum_config));

And if you agree with my other suggestions then you can replace a copy with:

	dev_priv->opt_config = opt_config;

Or in fact, even do it directly on assignment sites above.

Quoted 14 lines
drivers/gpu/drm/i915/intel_device_info.c +1 -0
+
  	/* Initialize command stream timestamp frequency */
  	info->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv);
  }
drivers/gpu/drm/i915/intel_lrc.c +0 -1
index a17f676..7fb9cd2 100644
@@ -427,11 +427,13 @@ static u64 execlists_update_context(struct i915_request *rq)
 
  	reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail);
  	/* FIXME: To avoid stale rpcs config, move it to context_pin */
-	if (ctx->pid && ctx->name && (rq->engine->id == RCS)) {

drivers/gpu/drm/i915/intel_lrc.c static u64 execlists_update_context(struct i915_request *rq) · line 439

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+	if (ctx->pid && ctx->name && (rq->engine->id == RCS) &&
+			(ctx->load_type != ctx->pending_load_type)) {
  		rpcs_config = make_rpcs(ctx->i915);
  		reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
  		CTX_REG(reg_state, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
  				rpcs_config);
+		ctx->load_type = ctx->pending_load_type;
  	}
 
  	/* True 32b PPGTT with dynamic page allocation: update PDP

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH v3 3/4] drm/i915: set optimum eu/slice/sub-slice configuration based on load type

Hi Tvrtko,

Quoted 28 lines · Tvrtko Ursulin
Quoted 24 lines · Ankit Navik

From: Praveen Diwakar <[email protected]>

This patch will select optimum eu/slice/sub-slice configuration based on type of load (low, medium, high) as input.
Based on our readings and experiments we have predefined set of optimum configuration for each platform(CHT, KBL). i915_gem_context_set_load_type will select optimum configuration from pre-defined optimum configuration table(opt_config).

It also introduce flag update_render_config which can set by any governor.

v2:
* Move static optimum_config to device init time.
* Rename function to appropriate name, fix data types and patch ordering.
* Rename prev_load_type to pending_load_type. (Tvrtko Ursulin)

v3:
* Add safe guard check in i915_gem_context_set_load_type.
* Rename struct from optimum_config to i915_sseu_optimum_config to avoid namespace clashes.
* Reduces memcpy for space efficient.
* Rebase.
* Improved commit message. (Tvrtko Ursulin)

Quoted 5 lines
Quoted 3 lines
Cc Kedar J Karanje <[email protected]>
Cc Yogesh Marathe <[email protected]>

Again for the record no, I did not r-b this.

Sorry, I wasn't aware that r-b has to be added by reviewer. Will take care in next patch sets.

Quoted 20 lines
Quoted 9 lines
---
  drivers/gpu/drm/i915/i915_drv.h          |  3 ++
  drivers/gpu/drm/i915/i915_gem_context.c  | 18 ++++++++++++
  drivers/gpu/drm/i915/i915_gem_context.h  | 25 +++++++++++++++++
  drivers/gpu/drm/i915/intel_device_info.c | 47

++++++++++++++++++++++++++++++--

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 1681

Quoted 9 lines
  drivers/gpu/drm/i915/intel_lrc.c         |  4 ++-
  5 files changed, 94 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 4aca534..4b9a8c5 100644

drivers/gpu/drm/i915/i915_drv.h +0 -0
@@ -1681,6 +1681,9 @@ struct drm_i915_private {
  	struct drm_i915_fence_reg fence_regs[I915_MAX_NUM_FENCES]; /*

assume 965 */

Quoted 6 lines

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 1685

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
  	int num_fence_regs; /* 8 on pre-965, 16 otherwise */
 
+	/* optimal slice/subslice/EU configration state */
+	struct i915_sseu_optimum_config opt_config[LOAD_TYPE_LAST];

Make it a pointer to struct i915_sseu_optimum_config.

Will incorporate this and other reviews in next patch.

Quoted 164 lines

drivers/gpu/drm/i915/i915_gem_context.c i915_gem_create_context(struct drm_i915_private

Quoted 11 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
+
  	unsigned int fsb_freq, mem_freq, is_ddr3;
  	unsigned int skl_preferred_vco_freq;
  	unsigned int max_cdclk_freq;
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index d040858..c0ced72 100644
@@ -392,10 +392,28 @@ i915_gem_create_context(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/i915_gem_context.c i915_gem_create_context(struct drm_i915_private *dev_priv, · line 396

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c +2 -0
  	ctx->subslice_cnt = hweight8(
  			INTEL_INFO(dev_priv)->sseu.subslice_mask[0]);
  	ctx->eu_cnt = INTEL_INFO(dev_priv)->sseu.eu_per_subslice;
+	ctx->load_type = 0;
+	ctx->pending_load_type = 0;

Not needed because we zero the allocation and probably depend on untouched fields being zero elsewhere.

Quoted 49 lines
drivers/gpu/drm/i915/i915_gem_context.c +16 -0
  	return ctx;
  }
 
+
+void i915_gem_context_set_load_type(struct i915_gem_context *ctx,
+		enum gem_load_type type)
+{
+	struct drm_i915_private *dev_priv = ctx->i915;
+
+	if (GEM_WARN_ON(type > LOAD_TYPE_LAST))
+		return;
+
+	/* Call opt_config to get correct configuration for eu,slice,subslice */
+	ctx->slice_cnt = dev_priv->opt_config[type].slice;
+	ctx->subslice_cnt = dev_priv->opt_config[type].subslice;
+	ctx->eu_cnt = dev_priv->opt_config[type].eu;
+	ctx->pending_load_type = type;
+}
+
  /**
   * i915_gem_context_create_gvt - create a GVT GEM context
   * @dev: drm device *
drivers/gpu/drm/i915/i915_gem_context.h +13 -0
index e000530..a0db13c 100644
@@ -53,6 +53,19 @@ struct intel_context_ops {
  	void (*destroy)(struct intel_context *ce);
  };
 
+enum gem_load_type {
+	LOAD_TYPE_LOW,
+	LOAD_TYPE_MEDIUM,
+	LOAD_TYPE_HIGH,
+	LOAD_TYPE_LAST
+};
+
+struct i915_sseu_optimum_config {
+	u8 slice;
+	u8 subslice;
+	u8 eu;
+};
+
  /**
   * struct i915_gem_context - client state
   *

drivers/gpu/drm/i915/i915_gem_context.h struct i915_gem_context { · line 230

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.h +7 -0
@@ -208,6 +221,16 @@ struct i915_gem_context {
 
  	/** eu_cnt: used to set the # of eu to be enabled. */
  	u8 eu_cnt;
+
+	/** load_type: The designated load_type (high/medium/low) for a given
+	 * number of pending commands in the command queue.
+	 */
+	enum gem_load_type load_type;
+
+	/** pending_load_type: The earlier load type that the GPU was

configured

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_context.h +3 -0
+	 * for (high/medium/low).
+	 */
+	enum gem_load_type pending_load_type;
  };
 
  static inline bool i915_gem_context_is_closed(const struct

i915_gem_context *ctx) @@ -336,6 +359,8 @@ int

i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct

Quoted 14 lines

struct drm_file *file_priv);
int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data,
struct drm_file *file);

drivers/gpu/drm/i915/i915_gem_context.h +2 -0
+void i915_gem_context_set_load_type(struct i915_gem_context *ctx,
+		enum gem_load_type type);
 
  struct i915_gem_context *
  i915_gem_context_create_kernel(struct drm_i915_private *i915, int

prio); diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index 0ef0c64..33c6310 100644

drivers/gpu/drm/i915/intel_device_info.c +0 -0
@@ -741,6 +741,28 @@ void intel_device_info_runtime_init(struct

intel_device_info *info)

Quoted 14 lines
drivers/gpu/drm/i915/intel_device_info.c +11 -0
  		container_of(info, struct drm_i915_private, info);
  	enum pipe pipe;
 
+	struct i915_sseu_optimum_config *opt_config = NULL;
+	/* static table of slice/subslice/EU for Cherryview */
+	struct i915_sseu_optimum_config chv_config[LOAD_TYPE_LAST] = {
+		{1, 1, 4},	/* Low */
+		{1, 1, 6},	/* Medium */
+		{1, 2, 6}	/* High */
+	};
+
+	/* static table of slice/subslice/EU for KBL GT2 */
+	struct i915_sseu_optimum_config kbl_gt2_config[LOAD_TYPE_LAST] = {
+		{1, 3, 2},	/* Low */

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 764

Quoted 10 lines
drivers/gpu/drm/i915/intel_device_info.c +10 -0
+		{1, 3, 4},	/* Medium */
+		{1, 3, 8}	/* High */
+	};
+
+	/* static table of slice/subslice/EU for KBL GT3 */
+	struct i915_sseu_optimum_config kbl_gt3_config[LOAD_TYPE_LAST] = {
+		{2, 3, 4},	/* Low */
+		{2, 3, 6},	/* Medium */
+		{2, 3, 8}	/* High */
+	};

Move these to file scope as static const.

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct

Quoted 5 lines
drivers/gpu/drm/i915/intel_device_info.c +1 -0
+
  	if (INTEL_GEN(dev_priv) >= 10) {
  		for_each_pipe(dev_priv, pipe)
  			info->num_scalers[pipe] = 2;
@@ -840,17 +862,38 @@ void intel_device_info_runtime_init(struct

intel_device_info *info)

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 867

Quoted 7 lines
drivers/gpu/drm/i915/intel_device_info.c +2 -1
  	/* Initialize slice/subslice/EU info */
  	if (IS_HASWELL(dev_priv))
  		haswell_sseu_info_init(dev_priv);
-	else if (IS_CHERRYVIEW(dev_priv))
+	else if (IS_CHERRYVIEW(dev_priv)) {
  		cherryview_sseu_info_init(dev_priv);
+		opt_config = chv_config;

For my idea to work here and below add:

BUILD_BUG_ON(ARRAY_SIZE(chv_config) != LOAD_TYPE_LAST);

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 877

Quoted 11 lines
drivers/gpu/drm/i915/intel_device_info.c +7 -1
+	}
  	else if (IS_BROADWELL(dev_priv))
  		broadwell_sseu_info_init(dev_priv);
-	else if (INTEL_GEN(dev_priv) == 9)
+	else if (INTEL_GEN(dev_priv) == 9) {
  		gen9_sseu_info_init(dev_priv);
+
+		if (IS_KABYLAKE(dev_priv)) {
+			switch (info->gt) {
+			default:
+				MISSING_CASE(info->gt);

This should probably be silent since absence of sseu tuning is not an error on other platforms.

Quoted 8 lines

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 883

Quoted 6 lines
drivers/gpu/drm/i915/intel_device_info.c +6 -0
+				/* fall through */
+			case 2:
+				opt_config = kbl_gt2_config;
+			break;
+			case 3:
+				opt_config = kbl_gt3_config;

Would Kabylake table work for other Gen9 platforms?

The table is designed from heuristic data (collected data from gen9 GT3 based). It should work ideally for other platform which is having 48 EUs (2-slices, 3-sub-slices, 8-EUs); but I haven't verified on other gen9 config. I will check and update further in next patch set.

Thank you for your valuable feedback!

Regards, Ankit

Quoted 46 lines

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info) · line 895

Quoted 13 lines
drivers/gpu/drm/i915/intel_device_info.c +7 -0
+			break;
+			}
+		}
+	}
  	else if (INTEL_GEN(dev_priv) == 10)
  		gen10_sseu_info_init(dev_priv);
  	else if (INTEL_GEN(dev_priv) >= 11)
  		gen11_sseu_info_init(dev_priv);
 
+	if (opt_config)
+		memcpy(dev_priv->opt_config, opt_config, LOAD_TYPE_LAST *
+			sizeof(struct i915_sseu_optimum_config));

And if you agree with my other suggestions then you can replace a copy with:

	dev_priv->opt_config = opt_config;

Or in fact, even do it directly on assignment sites above.

drivers/gpu/drm/i915/intel_device_info.c void intel_device_info_runtime_init(struct intel_device_info *info)

Quoted 3 lines
drivers/gpu/drm/i915/intel_device_info.c +1 -0
+
  	/* Initialize command stream timestamp frequency */
  	info->cs_timestamp_frequency_khz =

read_timestamp_frequency(dev_priv);

Quoted 7 lines
drivers/gpu/drm/i915/intel_device_info.c +0 -0
  }
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index a17f676..7fb9cd2 100644

drivers/gpu/drm/i915/intel_lrc.c static u64 execlists_update_context(struct · line 435

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -1
@@ -427,11 +427,13 @@ static u64 execlists_update_context(struct
 i915_request *rq)
 
  	reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail);
  	/* FIXME: To avoid stale rpcs config, move it to context_pin */
-	if (ctx->pid && ctx->name && (rq->engine->id == RCS)) {
+	if (ctx->pid && ctx->name && (rq->engine->id == RCS) &&
+			(ctx->load_type != ctx->pending_load_type)) {
  		rpcs_config = make_rpcs(ctx->i915);
  		reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
  		CTX_REG(reg_state, CTX_R_PWR_CLK_STATE,

GEN8_R_PWR_CLK_STATE,

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
  				rpcs_config);
+		ctx->load_type = ctx->pending_load_type;
  	}
 
Quoted 6 lines
Quoted 2 lines

/* True 32b PPGTT with dynamic page allocation: update PDP

Regards,

Tvrtko

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

PATCH v3 4/4 drm/i915: Predictive governor to control eu/slice/subslice

In reply to Ankit Navik

From: Praveen Diwakar <[email protected]>

High resolution timer is used for predictive governor to control eu/slice/subslice based on workloads.

Debugfs is provided to enable/disable/update timer configuration

V2:
* Fix code style.
* Move predictive_load_timer into a drm_i915_private structure.
* Make generic function to set optimum config. (Tvrtko Ursulin)

V3:
* Rebase.
* Fix race condition for predictive load set.
* Add slack to start hrtimer for more power efficient. (Tvrtko Ursulin)

---
 drivers/gpu/drm/i915/i915_debugfs.c | 90 ++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_drv.c     |  4 ++
 drivers/gpu/drm/i915/i915_drv.h     |  6 +++
 3 files changed, 99 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +89 -1
index f9ce35d..861f3c1 100644
@@ -4740,6 +4740,92 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_drrs_status", i915_drrs_status, 0},
 	{"i915_rps_boost_info", i915_rps_boost_info, 0},
 };
+
+#define PENDING_REQ_0	0	/* No active request pending */
+
+/*
+ * Anything above threshold is considered as HIGH load, less is considered
+ * as LOW load and equal is considered as MEDIUM load.
+ *
+ * The threshold value of three active requests pending.
+ */
+#define PENDING_THRESHOLD_MEDIUM 3
+
+#define SLACK_TIMER_NSEC 1000000 /* Timer range in nano second */
+
+enum hrtimer_restart predictive_load_cb(struct hrtimer *hrtimer)
+{
+	struct drm_i915_private *dev_priv =
+			container_of(hrtimer, typeof(*dev_priv), pred_timer);
+	struct i915_gem_context *ctx;
+	enum gem_load_type load_type;
+	unsigned long req_pending;
+
+	list_for_each_entry(ctx, &dev_priv->contexts.list, link) {
+
+		/* Check for in-valid context */
+		if (!ctx->name)
+			continue;
+
+		req_pending = atomic_read(&ctx->req_cnt);
+
+		/*
+		 * Transitioning to low state whenever pending request is zero
+		 * would cause vacillation between low and high state.
+		 */
+		if (req_pending == PENDING_REQ_0)
+			continue;
+
+		if (req_pending > PENDING_THRESHOLD_MEDIUM)
+			load_type = LOAD_TYPE_HIGH;
+		else if (req_pending == PENDING_THRESHOLD_MEDIUM)
+			load_type = LOAD_TYPE_MEDIUM;
+		else
+			load_type = LOAD_TYPE_LOW;
+
+		i915_gem_context_set_load_type(ctx, load_type);
+	}
+
+	hrtimer_forward_now(hrtimer,
+			ms_to_ktime(dev_priv->predictive_load_enable));
+
+	return HRTIMER_RESTART;
+}
+
+static int i915_predictive_load_get(void *data, u64 *val)
+{
+	struct drm_i915_private *dev_priv = data;
+
+	*val = dev_priv->predictive_load_enable;
+	return 0;
+}
+
+static int i915_predictive_load_set(void *data, u64 val)
+{
+	struct drm_i915_private *dev_priv = data;
+
+	mutex_lock(&dev_priv->pred_mutex);
+
+	dev_priv->predictive_load_enable = val;
+
+	if (dev_priv->predictive_load_enable) {
+		if (!hrtimer_active(&dev_priv->pred_timer))
+			hrtimer_start_range_ns(&dev_priv->pred_timer,
+			ms_to_ktime(dev_priv->predictive_load_enable),
+			SLACK_TIMER_NSEC,
+			HRTIMER_MODE_REL_PINNED);
+	} else {
+		hrtimer_cancel(&dev_priv->pred_timer);
+	}
+
+	mutex_unlock(&dev_priv->pred_mutex);
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(i915_predictive_load_ctl,
+			i915_predictive_load_get, i915_predictive_load_set,
+			"%llu\n");
+
 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
 
 static const struct i915_debugfs_files {
@@ -4769,7 +4855,9 @@ static const struct i915_debugfs_files {
 	{"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops},
 	{"i915_ipc_status", &i915_ipc_status_fops},
 	{"i915_drrs_ctl", &i915_drrs_ctl_fops},
-	{"i915_edp_psr_debug", &i915_edp_psr_debug_fops}
+	{"i915_edp_psr_debug", &i915_edp_psr_debug_fops},
+	/* FIXME: When feature will become real, move to sysfs */
+	{"i915_predictive_load_ctl", &i915_predictive_load_ctl}
 };
 
 int i915_debugfs_register(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_drv.c +4 -0
index f8cfd16..79f4df5 100644
@@ -1397,6 +1397,10 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret < 0)
 		goto out_cleanup_hw;
 
+	/* Timer initialization for predictive load */
+	hrtimer_init(&dev_priv->pred_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	dev_priv->pred_timer.function = predictive_load_cb;
+
 	i915_driver_register(dev_priv);
 
 	intel_runtime_pm_enable(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +6 -0
index 4b9a8c5..a78fdbc 100644
@@ -1684,6 +1684,11 @@ struct drm_i915_private {
 	/* optimal slice/subslice/EU configration state */
 	struct i915_sseu_optimum_config opt_config[LOAD_TYPE_LAST];
 
+	/* protects predictive load state */
+	struct mutex pred_mutex;
+	struct hrtimer pred_timer;
+	int predictive_load_enable;
+
 	unsigned int fsb_freq, mem_freq, is_ddr3;
 	unsigned int skl_preferred_vco_freq;
 	unsigned int max_cdclk_freq;
@@ -2730,6 +2735,7 @@ extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv);
 extern unsigned long i915_mch_val(struct drm_i915_private *dev_priv);
 extern unsigned long i915_gfx_val(struct drm_i915_private *dev_priv);
 extern void i915_update_gfx_val(struct drm_i915_private *dev_priv);
+extern enum hrtimer_restart predictive_load_cb(struct hrtimer *hrtimer);
 int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool on);
 
 int intel_engines_init_mmio(struct drm_i915_private *dev_priv);
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

Re: [PATCH v3 4/4] drm/i915: Predictive governor to control eu/slice/subslice

Quoted 13 lines · Ankit Navik

From: Praveen Diwakar <[email protected]>

High resolution timer is used for predictive governor to control eu/slice/subslice based on workloads.

Debugfs is provided to enable/disable/update timer configuration

V2:
* Fix code style.
* Move predictive_load_timer into a drm_i915_private structure.
* Make generic function to set optimum config. (Tvrtko Ursulin)

Quoted 8 lines

V3:
* Rebase.
* Fix race condition for predictive load set.
* Add slack to start hrtimer for more power efficient. (Tvrtko Ursulin)

Cc Aravindan Muthukumar <[email protected]>
Cc Yogesh Marathe <[email protected]>

For the record - no, I did not r-b this. Please remove all false r-b tags.

Quoted 14 lines
---
  drivers/gpu/drm/i915/i915_debugfs.c | 90 ++++++++++++++++++++++++++++++++++++-
  drivers/gpu/drm/i915/i915_drv.c     |  4 ++
  drivers/gpu/drm/i915/i915_drv.h     |  6 +++
  3 files changed, 99 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -0
index f9ce35d..861f3c1 100644

drivers/gpu/drm/i915/i915_debugfs.c static const struct drm_info_list i915_debugfs_list[] = { · line 4744

Quoted 5 lines
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
@@ -4740,6 +4740,92 @@ static const struct drm_info_list i915_debugfs_list[] = {
  	{"i915_drrs_status", i915_drrs_status, 0},
  	{"i915_rps_boost_info", i915_rps_boost_info, 0},
  };
+
+#define PENDING_REQ_0	0	/* No active request pending */

Still seems silly - what is the benefit of adding a define with zero in it's name, which evaluates to zero? Just remove it.

Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +8 -0
+
+/*
+ * Anything above threshold is considered as HIGH load, less is considered
+ * as LOW load and equal is considered as MEDIUM load.
+ *
+ * The threshold value of three active requests pending.
+ */
+#define PENDING_THRESHOLD_MEDIUM 3

drivers/gpu/drm/i915/i915_debugfs.c static const struct drm_info_list i915_debugfs_list[] = { · line 4762

Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +10 -0
+
+#define SLACK_TIMER_NSEC 1000000 /* Timer range in nano second */
+
+enum hrtimer_restart predictive_load_cb(struct hrtimer *hrtimer)
+{
+	struct drm_i915_private *dev_priv =
+			container_of(hrtimer, typeof(*dev_priv), pred_timer);
+	struct i915_gem_context *ctx;
+	enum gem_load_type load_type;
+	unsigned long req_pending;

unsigned int is enough to hold atomic_t.

drivers/gpu/drm/i915/i915_debugfs.c static const struct drm_info_list i915_debugfs_list[] = { · line 4768

Quoted 6 lines
drivers/gpu/drm/i915/i915_debugfs.c +6 -0
+
+	list_for_each_entry(ctx, &dev_priv->contexts.list, link) {
+
+		/* Check for in-valid context */
+		if (!ctx->name)
+			continue;

What kind of contexts are these invalid ones? :)

Quoted 33 lines
drivers/gpu/drm/i915/i915_debugfs.c +33 -0
+
+		req_pending = atomic_read(&ctx->req_cnt);
+
+		/*
+		 * Transitioning to low state whenever pending request is zero
+		 * would cause vacillation between low and high state.
+		 */
+		if (req_pending == PENDING_REQ_0)
+			continue;
+
+		if (req_pending > PENDING_THRESHOLD_MEDIUM)
+			load_type = LOAD_TYPE_HIGH;
+		else if (req_pending == PENDING_THRESHOLD_MEDIUM)
+			load_type = LOAD_TYPE_MEDIUM;
+		else
+			load_type = LOAD_TYPE_LOW;
+
+		i915_gem_context_set_load_type(ctx, load_type);
+	}
+
+	hrtimer_forward_now(hrtimer,
+			ms_to_ktime(dev_priv->predictive_load_enable));
+
+	return HRTIMER_RESTART;
+}
+
+static int i915_predictive_load_get(void *data, u64 *val)
+{
+	struct drm_i915_private *dev_priv = data;
+
+	*val = dev_priv->predictive_load_enable;
+	return 0;
+}

drivers/gpu/drm/i915/i915_debugfs.c static const struct drm_info_list i915_debugfs_list[] = { · line 4811

Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +10 -0
+
+static int i915_predictive_load_set(void *data, u64 val)
+{
+	struct drm_i915_private *dev_priv = data;
+
+	mutex_lock(&dev_priv->pred_mutex);
+
+	dev_priv->predictive_load_enable = val;
+
+	if (dev_priv->predictive_load_enable) {

The period change applies after the current timer expires, okay.

Quoted 36 lines
drivers/gpu/drm/i915/i915_debugfs.c +20 -1
+		if (!hrtimer_active(&dev_priv->pred_timer))
+			hrtimer_start_range_ns(&dev_priv->pred_timer,
+			ms_to_ktime(dev_priv->predictive_load_enable),
+			SLACK_TIMER_NSEC,
+			HRTIMER_MODE_REL_PINNED);
+	} else {
+		hrtimer_cancel(&dev_priv->pred_timer);
+	}
+
+	mutex_unlock(&dev_priv->pred_mutex);
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(i915_predictive_load_ctl,
+			i915_predictive_load_get, i915_predictive_load_set,
+			"%llu\n");
+
  #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
 
  static const struct i915_debugfs_files {
@@ -4769,7 +4855,9 @@ static const struct i915_debugfs_files {
  	{"i915_hpd_storm_ctl", &i915_hpd_storm_ctl_fops},
  	{"i915_ipc_status", &i915_ipc_status_fops},
  	{"i915_drrs_ctl", &i915_drrs_ctl_fops},
-	{"i915_edp_psr_debug", &i915_edp_psr_debug_fops}
+	{"i915_edp_psr_debug", &i915_edp_psr_debug_fops},
+	/* FIXME: When feature will become real, move to sysfs */
+	{"i915_predictive_load_ctl", &i915_predictive_load_ctl}
  };
 
  int i915_debugfs_register(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_drv.c +0 -0
index f8cfd16..79f4df5 100644

drivers/gpu/drm/i915/i915_drv.c int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) · line 1402

Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.c +3 -0
@@ -1397,6 +1397,10 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
  	if (ret < 0)
  		goto out_cleanup_hw;
 
+	/* Timer initialization for predictive load */
+	hrtimer_init(&dev_priv->pred_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	dev_priv->pred_timer.function = predictive_load_cb;

mutex_init(&dev_priv->pred_mutex) is missing.

And please move this whole block to i915_gem_init_early.

Quoted 22 lines
drivers/gpu/drm/i915/i915_drv.c +1 -0
+
  	i915_driver_register(dev_priv);
 
  	intel_runtime_pm_enable(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +5 -0
index 4b9a8c5..a78fdbc 100644
@@ -1684,6 +1684,11 @@ struct drm_i915_private {
  	/* optimal slice/subslice/EU configration state */
  	struct i915_sseu_optimum_config opt_config[LOAD_TYPE_LAST];
 
+	/* protects predictive load state */
+	struct mutex pred_mutex;
+	struct hrtimer pred_timer;
+	int predictive_load_enable;
+
  	unsigned int fsb_freq, mem_freq, is_ddr3;
  	unsigned int skl_preferred_vco_freq;
  	unsigned int max_cdclk_freq;

drivers/gpu/drm/i915/i915_drv.h extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv); · line 2741

Quoted 7 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2730,6 +2735,7 @@ extern unsigned long i915_chipset_val(struct drm_i915_private *dev_priv);
  extern unsigned long i915_mch_val(struct drm_i915_private *dev_priv);
  extern unsigned long i915_gfx_val(struct drm_i915_private *dev_priv);
  extern void i915_update_gfx_val(struct drm_i915_private *dev_priv);
+extern enum hrtimer_restart predictive_load_cb(struct hrtimer *hrtimer);
  int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool on);
 
  int intel_engines_init_mmio(struct drm_i915_private *dev_priv);

Looking smaller and better, right?

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw

✗ Fi.CI.BAT: failure for Dynamic EU configuration of Slice/Subslice/EU.

In reply to Ankit Navik
== Series Details ==

== Series Details ==

Series: Dynamic EU configuration of Slice/Subslice/EU.
URL : https://patchwork.freedesktop.org/series/53876/
State : failure

== Summary ==

Applying: drm/i915: Get active pending request for given context
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_gem_context.c
M drivers/gpu/drm/i915/i915_gem_context.h
M drivers/gpu/drm/i915/i915_request.c
M drivers/gpu/drm/i915/intel_lrc.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_lrc.c
Auto-merging drivers/gpu/drm/i915/i915_request.c
Auto-merging drivers/gpu/drm/i915/i915_gem_context.h
Auto-merging drivers/gpu/drm/i915/i915_gem_context.c
Applying: drm/i915: Update render power clock state configuration for given context Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_gem_context.c
M drivers/gpu/drm/i915/i915_gem_context.h
M drivers/gpu/drm/i915/intel_lrc.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_lrc.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/intel_lrc.c Auto-merging drivers/gpu/drm/i915/i915_gem_context.h
Auto-merging drivers/gpu/drm/i915/i915_gem_context.c
error: Failed to merge in the changes.
Patch failed at 0002 drm/i915: Update render power clock state configuration for given context Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

Re: ✗ Fi.CI.BAT: failure for Dynamic EU configuration of Slice/Subslice/EU.

Quoted 27 lines · Patchwork

== Series Details ==

Series: Dynamic EU configuration of Slice/Subslice/EU.
URL : https://patchwork.freedesktop.org/series/53876/
State : failure

== Summary ==

Applying: drm/i915: Get active pending request for given context
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_gem_context.c
M drivers/gpu/drm/i915/i915_gem_context.h
M drivers/gpu/drm/i915/i915_request.c
M drivers/gpu/drm/i915/intel_lrc.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_lrc.c
Auto-merging drivers/gpu/drm/i915/i915_request.c
Auto-merging drivers/gpu/drm/i915/i915_gem_context.h
Auto-merging drivers/gpu/drm/i915/i915_gem_context.c
Applying: drm/i915: Update render power clock state configuration for given context Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_gem_context.c
M drivers/gpu/drm/i915/i915_gem_context.h
M drivers/gpu/drm/i915/intel_lrc.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_lrc.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/intel_lrc.c

Quoted 8 lines

Auto-merging drivers/gpu/drm/i915/i915_gem_context.h
Auto-merging drivers/gpu/drm/i915/i915_gem_context.c
error: Failed to merge in the changes.
Patch failed at 0002 drm/i915: Update render power clock state configuration for given context Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Always rebase before sending if you are not sure since drm-tip can be pretty dynamic.

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#13 lore raw
In reply to Ankit Navik
Quoted 36 lines · Ankit Navik

drm/i915: Context aware user agnostic EU/Slice/Sub-slice control within kernel

Current GPU configuration code for i915 does not allow us to change EU/Slice/Sub-slice configuration dynamically. Its done only once while context is created.

While particular graphics application is running, if we examine the command requests from user space, we observe that command density is not consistent. It means there is scope to change the graphics configuration dynamically even while context is running actively. This patch series proposes the solution to find the active pending load for all active context at given time and based on that, dynamically perform graphics configuration for each context.

We use a hr (high resolution) timer with i915 driver in kernel to get a callback every few milliseconds (this timer value can be configured through debugfs, default is '0' indicating timer is in disabled state i.e. original system without any intervention).In the timer callback, we examine pending commands for a context in the queue, essentially, we intercept them before they are executed by GPU and we update context with required number of EUs.

Two questions, how did we arrive at right timer value? and what's the right number of EUs? For the prior one, empirical data to achieve best performance in least power was considered. For the later one, we roughly categorized number of EUs logically based on platform. Now we compare number of pending commands with a particular threshold and then set number of EUs accordingly with update context. That threshold is also based on experiments & findings. If GPU is able to catch up with CPU, typically there are no pending commands, the EU config would remain unchanged there. In case there are more pending commands we reprogram context with higher number of EUs. Please note, here we are changing EUs even while context is running by examining pending commands every 'x' milliseconds.

With this solution in place, on KBL-GT3 + Android we saw following pnp benefits, power numbers mentioned here are system power.

App /KPI | % Power |

Quoted 10 lines
                        | Benefit |
                        |  (mW)   |
---------------------------------|
3D Mark (Ice storm)    | 2.30%   |
TRex On screen         | 2.49%   |
TRex Off screen        | 1.32%   |
ManhattanOn screen     | 3.11%   |
Manhattan Off screen   | 0.89%   |
AnTuTu  6.1.4          | 3.42%   |
SynMark2               | 1.70%   |

Is this the aggregated SynMark2 result, like all sub-tests averaged or something?

I suggest you do want to list much more detail here, all individual sub-tests, different platforms, etc. The change you are proposing is quite big and the amount of research that you must demonstrate for people to take this seriously has to be equally exhaustive.

Regards,

Tvrtko

Quoted 14 lines

Note - For KBL (GEN9) we cannot control at sub-slice level, it was always a constraint.
We always controlled number of EUs rather than sub-slices/slices. We have also observed GPU core residencies improves by 1.03%.

Praveen Diwakar (4):
drm/i915: Get active pending request for given context drm/i915: Update render power clock state configuration for given
context
drm/i915: set optimum eu/slice/sub-slice configuration based on load
type
drm/i915: Predictive governor to control eu/slice/subslice

Quoted 10 lines
  drivers/gpu/drm/i915/i915_debugfs.c      | 90 +++++++++++++++++++++++++++++++-
  drivers/gpu/drm/i915/i915_drv.c          |  4 ++
  drivers/gpu/drm/i915/i915_drv.h          |  9 ++++
  drivers/gpu/drm/i915/i915_gem_context.c  | 23 ++++++++
  drivers/gpu/drm/i915/i915_gem_context.h  | 39 ++++++++++++++
  drivers/gpu/drm/i915/i915_request.c      |  2 +
  drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++-
  drivers/gpu/drm/i915/intel_lrc.c         | 16 +++++-
  8 files changed, 226 insertions(+), 4 deletions(-)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

Hi Tvrtko,

Quoted 56 lines · Tvrtko Ursulin
Quoted 9 lines · Ankit Navik

drm/i915: Context aware user agnostic EU/Slice/Sub-slice control within kernel

Current GPU configuration code for i915 does not allow us to change EU/Slice/Sub-slice configuration dynamically. Its done only once while context is created.

While particular graphics application is running, if we examine the command requests from user space, we observe that command density is not

consistent.

Quoted 4 lines

It means there is scope to change the graphics configuration dynamically even while context is running actively. This patch series proposes the solution to find the active pending load for all active context at given time and based on that, dynamically perform graphics

configuration for each context.

Quoted 7 lines

We use a hr (high resolution) timer with i915 driver in kernel to get a callback every few milliseconds (this timer value can be configured through debugfs, default is '0' indicating timer is in disabled state i.e. original system without any intervention).In the timer callback, we examine pending commands for a context in the queue, essentially, we intercept them before they are executed by GPU and we update context

with required number of EUs.

Quoted 11 lines

Two questions, how did we arrive at right timer value? and what's the right number of EUs? For the prior one, empirical data to achieve best performance in least power was considered. For the later one, we roughly categorized number of EUs logically based on platform. Now we compare number of pending commands with a particular threshold and then set number of EUs accordingly with update context. That threshold is also based on experiments & findings. If GPU is able to catch up with CPU, typically there are no pending commands, the EU config would remain unchanged there. In case there are more pending commands we reprogram context with higher number of EUs. Please note, here we are

changing EUs even while context is running by examining pending commands every 'x'

Quoted 6 lines

milliseconds.

With this solution in place, on KBL-GT3 + Android we saw following pnp benefits, power numbers mentioned here are system power.

App /KPI | % Power |

Quoted 10 lines
                        | Benefit |
                        |  (mW)   |
---------------------------------|
3D Mark (Ice storm)    | 2.30%   |
TRex On screen         | 2.49%   |
TRex Off screen        | 1.32%   |
ManhattanOn screen     | 3.11%   |
Manhattan Off screen   | 0.89%   |
AnTuTu  6.1.4          | 3.42%   |
SynMark2               | 1.70%   |
Quoted 1 line

Is this the aggregated SynMark2 result, like all sub-tests averaged or something?

Yes, It is averaged result covering all the test cases.

Quoted 5 lines

I suggest you do want to list much more detail here, all individual sub-tests, different platforms, etc. The change you are proposing is quite big and the amount of research that you must demonstrate for people to take this seriously has to be equally exhaustive.

I will verify and add more details covering various platform and sub-tests.

Regards, Ankit

Quoted 19 lines

Regards,

Tvrtko

Quoted 14 lines

Note - For KBL (GEN9) we cannot control at sub-slice level, it was always a constraint.
We always controlled number of EUs rather than sub-slices/slices. We have also observed GPU core residencies improves by 1.03%.

Praveen Diwakar (4):
drm/i915: Get active pending request for given context drm/i915: Update render power clock state configuration for given
context
drm/i915: set optimum eu/slice/sub-slice configuration based on load
type
drm/i915: Predictive governor to control eu/slice/subslice

Quoted 11 lines
Quoted 1 line
  drivers/gpu/drm/i915/i915_debugfs.c      | 90

+++++++++++++++++++++++++++++++-

Quoted 9 lines
  drivers/gpu/drm/i915/i915_drv.c          |  4 ++
  drivers/gpu/drm/i915/i915_drv.h          |  9 ++++
  drivers/gpu/drm/i915/i915_gem_context.c  | 23 ++++++++
  drivers/gpu/drm/i915/i915_gem_context.h  | 39 ++++++++++++++
  drivers/gpu/drm/i915/i915_request.c      |  2 +
  drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++-
  drivers/gpu/drm/i915/intel_lrc.c         | 16 +++++-
  8 files changed, 226 insertions(+), 4 deletions(-)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#15 lore raw
In reply to Ankit Navik

Quoting Ankit Navik (2018-12-11 12:14:17)

Quoted 20 lines

drm/i915: Context aware user agnostic EU/Slice/Sub-slice control within kernel

Current GPU configuration code for i915 does not allow us to change EU/Slice/Sub-slice configuration dynamically. Its done only once while context is created.

While particular graphics application is running, if we examine the command requests from user space, we observe that command density is not consistent. It means there is scope to change the graphics configuration dynamically even while context is running actively. This patch series proposes the solution to find the active pending load for all active context at given time and based on that, dynamically perform graphics configuration for each context.

We use a hr (high resolution) timer with i915 driver in kernel to get a callback every few milliseconds (this timer value can be configured through debugfs, default is '0' indicating timer is in disabled state i.e. original system without any intervention).In the timer callback, we examine pending commands for a context in the queue, essentially, we intercept them before they are executed by GPU and we update context with required number of EUs.

Quoted 11 lines

Two questions, how did we arrive at right timer value? and what's the right number of EUs? For the prior one, empirical data to achieve best performance in least power was considered. For the later one, we roughly categorized number of EUs logically based on platform. Now we compare number of pending commands with a particular threshold and then set number of EUs accordingly with update context. That threshold is also based on experiments & findings. If GPU is able to catch up with CPU, typically there are no pending commands, the EU config would remain unchanged there. In case there are more pending commands we reprogram context with higher number of EUs. Please note, here we are changing EUs even while context is running by examining pending commands every 'x' milliseconds.

On the overall strategy. This will be unsuitable to be merged as a debugfs interface. So is the idea to evolve into a sysfs interface? As this seems to require tuning for each specific workload, I don't think that would scale too well if you consider a desktop distro?

Also, there's the patch series to to enable/disable subslices with VME hardware (the other dynamic slice shutdown/SSEU series) depending on the type of load being run. Certain workloads would hang the system if they're executed with full subslice configuration. In that light, it would make more sense if the applications would be the ones reporting their optimal running configuration.

Quoted 4 lines

With this solution in place, on KBL-GT3 + Android we saw following pnp benefits, power numbers mentioned here are system power.

Quoted 11 lines
App /KPI               | % Power |
                       | Benefit |
                       |  (mW)   |
---------------------------------|
3D Mark (Ice storm)    | 2.30%   |
TRex On screen         | 2.49%   |
TRex Off screen        | 1.32%   |
ManhattanOn screen     | 3.11%   |
Manhattan Off screen   | 0.89%   |
AnTuTu  6.1.4          | 3.42%   |
SynMark2               | 1.70%   |

Just to verify, these numbers are true while there's no negative effect on the benchmark scores?

Regards, Joonas

Quoted 13 lines

Note - For KBL (GEN9) we cannot control at sub-slice level, it was always a constraint.
We always controlled number of EUs rather than sub-slices/slices. We have also observed GPU core residencies improves by 1.03%.

Praveen Diwakar (4):
drm/i915: Get active pending request for given context drm/i915: Update render power clock state configuration for given
context
drm/i915: set optimum eu/slice/sub-slice configuration based on load
type
drm/i915: Predictive governor to control eu/slice/subslice

Quoted 17 lines
 drivers/gpu/drm/i915/i915_debugfs.c      | 90 +++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_drv.c          |  4 ++
 drivers/gpu/drm/i915/i915_drv.h          |  9 ++++
 drivers/gpu/drm/i915/i915_gem_context.c  | 23 ++++++++
 drivers/gpu/drm/i915/i915_gem_context.h  | 39 ++++++++++++++
 drivers/gpu/drm/i915/i915_request.c      |  2 +
 drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++-
 drivers/gpu/drm/i915/intel_lrc.c         | 16 +++++-
 8 files changed, 226 insertions(+), 4 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw

Hi Joonas,

Quoted 36 lines · Joonas Lahtinen

Quoting Ankit Navik (2018-12-11 12:14:17)

Quoted 9 lines

drm/i915: Context aware user agnostic EU/Slice/Sub-slice control within kernel

Current GPU configuration code for i915 does not allow us to change EU/Slice/Sub-slice configuration dynamically. Its done only once while context is created.

While particular graphics application is running, if we examine the command requests from user space, we observe that command density is not

consistent.

Quoted 4 lines

It means there is scope to change the graphics configuration dynamically even while context is running actively. This patch series proposes the solution to find the active pending load for all active context at given time and based on that, dynamically perform graphics

configuration for each context.

Quoted 7 lines

We use a hr (high resolution) timer with i915 driver in kernel to get a callback every few milliseconds (this timer value can be configured through debugfs, default is '0' indicating timer is in disabled state i.e. original system without any intervention).In the timer callback, we examine pending commands for a context in the queue, essentially, we intercept them before they are executed by GPU and we update context

with required number of EUs.

Quoted 11 lines

Two questions, how did we arrive at right timer value? and what's the right number of EUs? For the prior one, empirical data to achieve best performance in least power was considered. For the later one, we roughly categorized number of EUs logically based on platform. Now we compare number of pending commands with a particular threshold and then set number of EUs accordingly with update context. That threshold is also based on experiments & findings. If GPU is able to catch up with CPU, typically there are no pending commands, the EU config would remain unchanged there. In case there are more pending commands we reprogram context with higher number of EUs. Please note, here we are

Quoted 8 lines

changing EUs even while context is running by examining pending commands every 'x'

Quoted 1 line

milliseconds.

On the overall strategy. This will be unsuitable to be merged as a debugfs interface. So is the idea to evolve into a sysfs interface? As this seems to require tuning for each specific workload, I don't think that would scale too well if you consider a desktop distro?

We started initially as debugfs interface. I have added the comment to move the functionality into sysfs interface. Yes, I will consider the desktop distro and share the detail results.

Quoted 6 lines

Also, there's the patch series to to enable/disable subslices with VME hardware (the other dynamic slice shutdown/SSEU series) depending on the type of load being run. Certain workloads would hang the system if they're executed with full subslice configuration. In that light, it would make more sense if the applications would be the ones reporting their optimal running configuration.

I think, the series expose rpcs for gen 11 only for VME use case.
The patch I have tested on KBL (Gen 9). I will consider other gen 9 platform as well.

Quoted 17 lines
Quoted 5 lines

With this solution in place, on KBL-GT3 + Android we saw following pnp benefits, power numbers mentioned here are system power.

Quoted 11 lines
App /KPI               | % Power |
                       | Benefit |
                       |  (mW)   |
---------------------------------|
3D Mark (Ice storm)    | 2.30%   |
TRex On screen         | 2.49%   |
TRex Off screen        | 1.32%   |
ManhattanOn screen     | 3.11%   |
Manhattan Off screen   | 0.89%   |
AnTuTu  6.1.4          | 3.42%   |
SynMark2               | 1.70%   |
Quoted 2 lines

Just to verify, these numbers are true while there's no negative effect on the benchmark scores?

Yes, There is no impact on the benchmark scores.
Thank you Joonas for your valuable feedback.

Regards, Ankit

Quoted 16 lines

Regards, Joonas

Quoted 13 lines

Note - For KBL (GEN9) we cannot control at sub-slice level, it was always a constraint.
We always controlled number of EUs rather than sub-slices/slices. We have also observed GPU core residencies improves by 1.03%.

Praveen Diwakar (4):
drm/i915: Get active pending request for given context drm/i915: Update render power clock state configuration for given
context
drm/i915: set optimum eu/slice/sub-slice configuration based on load
type
drm/i915: Predictive governor to control eu/slice/subslice

Quoted 18 lines
Quoted 1 line
 drivers/gpu/drm/i915/i915_debugfs.c      | 90

+++++++++++++++++++++++++++++++-

Quoted 16 lines
 drivers/gpu/drm/i915/i915_drv.c          |  4 ++
 drivers/gpu/drm/i915/i915_drv.h          |  9 ++++
 drivers/gpu/drm/i915/i915_gem_context.c  | 23 ++++++++
drivers/gpu/drm/i915/i915_gem_context.h  | 39 ++++++++++++++
 drivers/gpu/drm/i915/i915_request.c      |  2 +
 drivers/gpu/drm/i915/intel_device_info.c | 47 ++++++++++++++++-
 drivers/gpu/drm/i915/intel_lrc.c         | 16 +++++-
 8 files changed, 226 insertions(+), 4 deletions(-)

--
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx