drm/i915: Get active pending request for given context
Subsystems (2)
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)
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v3 2/4 drm/i915: Update render power clock state configuration for given context
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.
--- 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
@@ -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
@@ -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
@@ -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
PATCH v3 3/4 drm/i915: set optimum eu/slice/sub-slice configuration based on load type
In reply to Ankit NavikFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v3 4/4 drm/i915: Predictive governor to control eu/slice/subslice
In reply to Ankit NavikFrom: 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
@@ -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
@@ -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
@@ -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
Patchwork
CI✗ Fi.CI.BAT: failure for series starting with [v3,1/4] drm/i915: Get active pending request for given context
In reply to Ankit Navik== Series Details ==
== Series Details ==
Series: series starting with [v3,1/4] drm/i915: Get active pending request for given context
URL : https://patchwork.freedesktop.org/series/53872/
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