Lines Matching refs:slpc
10 static inline struct intel_guc *slpc_to_guc(struct intel_guc_slpc *slpc) in slpc_to_guc() argument
12 return container_of(slpc, struct intel_guc, slpc); in slpc_to_guc()
15 static inline struct intel_gt *slpc_to_gt(struct intel_guc_slpc *slpc) in slpc_to_gt() argument
17 return guc_to_gt(slpc_to_guc(slpc)); in slpc_to_gt()
20 static inline struct drm_i915_private *slpc_to_i915(struct intel_guc_slpc *slpc) in slpc_to_i915() argument
22 return slpc_to_gt(slpc)->i915; in slpc_to_i915()
40 void intel_guc_slpc_init_early(struct intel_guc_slpc *slpc) in intel_guc_slpc_init_early() argument
42 struct intel_guc *guc = slpc_to_guc(slpc); in intel_guc_slpc_init_early()
44 slpc->supported = __detect_slpc_supported(guc); in intel_guc_slpc_init_early()
45 slpc->selected = __guc_slpc_selected(guc); in intel_guc_slpc_init_early()
82 int intel_guc_slpc_init(struct intel_guc_slpc *slpc) in intel_guc_slpc_init() argument
84 struct intel_guc *guc = slpc_to_guc(slpc); in intel_guc_slpc_init()
85 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_init()
89 GEM_BUG_ON(slpc->vma); in intel_guc_slpc_init()
91 err = intel_guc_allocate_and_map_vma(guc, size, &slpc->vma, (void **)&slpc->vaddr); in intel_guc_slpc_init()
99 slpc->max_freq_softlimit = 0; in intel_guc_slpc_init()
100 slpc->min_freq_softlimit = 0; in intel_guc_slpc_init()
105 static u32 slpc_get_state(struct intel_guc_slpc *slpc) in slpc_get_state() argument
109 GEM_BUG_ON(!slpc->vma); in slpc_get_state()
111 drm_clflush_virt_range(slpc->vaddr, sizeof(u32)); in slpc_get_state()
112 data = slpc->vaddr; in slpc_get_state()
143 static bool slpc_is_running(struct intel_guc_slpc *slpc) in slpc_is_running() argument
145 return slpc_get_state(slpc) == SLPC_GLOBAL_STATE_RUNNING; in slpc_is_running()
163 static int slpc_query_task_state(struct intel_guc_slpc *slpc) in slpc_query_task_state() argument
165 struct intel_guc *guc = slpc_to_guc(slpc); in slpc_query_task_state()
166 struct drm_i915_private *i915 = slpc_to_i915(slpc); in slpc_query_task_state()
167 u32 offset = intel_guc_ggtt_offset(guc, slpc->vma); in slpc_query_task_state()
175 drm_clflush_virt_range(slpc->vaddr, SLPC_PAGE_SIZE_BYTES); in slpc_query_task_state()
180 static int slpc_set_param(struct intel_guc_slpc *slpc, u8 id, u32 value) in slpc_set_param() argument
182 struct intel_guc *guc = slpc_to_guc(slpc); in slpc_set_param()
183 struct drm_i915_private *i915 = slpc_to_i915(slpc); in slpc_set_param()
196 static int slpc_unset_param(struct intel_guc_slpc *slpc, in slpc_unset_param() argument
199 struct intel_guc *guc = slpc_to_guc(slpc); in slpc_unset_param()
226 static const char *slpc_get_state_string(struct intel_guc_slpc *slpc) in slpc_get_state_string() argument
228 return slpc_global_state_to_string(slpc_get_state(slpc)); in slpc_get_state_string()
246 static int slpc_reset(struct intel_guc_slpc *slpc) in slpc_reset() argument
248 struct drm_i915_private *i915 = slpc_to_i915(slpc); in slpc_reset()
249 struct intel_guc *guc = slpc_to_guc(slpc); in slpc_reset()
250 u32 offset = intel_guc_ggtt_offset(guc, slpc->vma); in slpc_reset()
262 if (wait_for(slpc_is_running(slpc), SLPC_RESET_TIMEOUT_MS)) { in slpc_reset()
264 slpc_get_state_string(slpc)); in slpc_reset()
272 static u32 slpc_decode_min_freq(struct intel_guc_slpc *slpc) in slpc_decode_min_freq() argument
274 struct slpc_shared_data *data = slpc->vaddr; in slpc_decode_min_freq()
276 GEM_BUG_ON(!slpc->vma); in slpc_decode_min_freq()
283 static u32 slpc_decode_max_freq(struct intel_guc_slpc *slpc) in slpc_decode_max_freq() argument
285 struct slpc_shared_data *data = slpc->vaddr; in slpc_decode_max_freq()
287 GEM_BUG_ON(!slpc->vma); in slpc_decode_max_freq()
321 int intel_guc_slpc_set_max_freq(struct intel_guc_slpc *slpc, u32 val) in intel_guc_slpc_set_max_freq() argument
323 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_set_max_freq()
327 if (val < slpc->min_freq || in intel_guc_slpc_set_max_freq()
328 val > slpc->rp0_freq || in intel_guc_slpc_set_max_freq()
329 val < slpc->min_freq_softlimit) in intel_guc_slpc_set_max_freq()
333 ret = slpc_set_param(slpc, in intel_guc_slpc_set_max_freq()
343 slpc->max_freq_softlimit = val; in intel_guc_slpc_set_max_freq()
358 int intel_guc_slpc_get_max_freq(struct intel_guc_slpc *slpc, u32 *val) in intel_guc_slpc_get_max_freq() argument
360 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_get_max_freq()
366 ret = slpc_query_task_state(slpc); in intel_guc_slpc_get_max_freq()
369 *val = slpc_decode_max_freq(slpc); in intel_guc_slpc_get_max_freq()
385 int intel_guc_slpc_set_min_freq(struct intel_guc_slpc *slpc, u32 val) in intel_guc_slpc_set_min_freq() argument
387 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_set_min_freq()
391 if (val < slpc->min_freq || in intel_guc_slpc_set_min_freq()
392 val > slpc->rp0_freq || in intel_guc_slpc_set_min_freq()
393 val > slpc->max_freq_softlimit) in intel_guc_slpc_set_min_freq()
397 ret = slpc_set_param(slpc, in intel_guc_slpc_set_min_freq()
407 slpc->min_freq_softlimit = val; in intel_guc_slpc_set_min_freq()
422 int intel_guc_slpc_get_min_freq(struct intel_guc_slpc *slpc, u32 *val) in intel_guc_slpc_get_min_freq() argument
424 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_get_min_freq()
430 ret = slpc_query_task_state(slpc); in intel_guc_slpc_get_min_freq()
433 *val = slpc_decode_min_freq(slpc); in intel_guc_slpc_get_min_freq()
454 static int slpc_set_softlimits(struct intel_guc_slpc *slpc) in slpc_set_softlimits() argument
463 if (!slpc->max_freq_softlimit) in slpc_set_softlimits()
464 slpc->max_freq_softlimit = slpc->rp0_freq; in slpc_set_softlimits()
465 else if (slpc->max_freq_softlimit != slpc->rp0_freq) in slpc_set_softlimits()
466 ret = intel_guc_slpc_set_max_freq(slpc, in slpc_set_softlimits()
467 slpc->max_freq_softlimit); in slpc_set_softlimits()
472 if (!slpc->min_freq_softlimit) in slpc_set_softlimits()
473 slpc->min_freq_softlimit = slpc->min_freq; in slpc_set_softlimits()
474 else if (slpc->min_freq_softlimit != slpc->min_freq) in slpc_set_softlimits()
475 return intel_guc_slpc_set_min_freq(slpc, in slpc_set_softlimits()
476 slpc->min_freq_softlimit); in slpc_set_softlimits()
481 static int slpc_ignore_eff_freq(struct intel_guc_slpc *slpc, bool ignore) in slpc_ignore_eff_freq() argument
486 ret = slpc_set_param(slpc, in slpc_ignore_eff_freq()
490 return slpc_set_param(slpc, in slpc_ignore_eff_freq()
492 slpc->min_freq); in slpc_ignore_eff_freq()
494 ret = slpc_unset_param(slpc, in slpc_ignore_eff_freq()
497 return slpc_unset_param(slpc, in slpc_ignore_eff_freq()
504 static int slpc_use_fused_rp0(struct intel_guc_slpc *slpc) in slpc_use_fused_rp0() argument
507 return slpc_set_param(slpc, in slpc_use_fused_rp0()
509 slpc->rp0_freq); in slpc_use_fused_rp0()
512 static void slpc_get_rp_values(struct intel_guc_slpc *slpc) in slpc_get_rp_values() argument
516 rp_state_cap = intel_uncore_read(slpc_to_gt(slpc)->uncore, in slpc_get_rp_values()
519 slpc->rp0_freq = REG_FIELD_GET(RP0_CAP_MASK, rp_state_cap) * in slpc_get_rp_values()
521 slpc->rp1_freq = REG_FIELD_GET(RP1_CAP_MASK, rp_state_cap) * in slpc_get_rp_values()
523 slpc->min_freq = REG_FIELD_GET(RPN_CAP_MASK, rp_state_cap) * in slpc_get_rp_values()
540 int intel_guc_slpc_enable(struct intel_guc_slpc *slpc) in intel_guc_slpc_enable() argument
542 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_enable()
545 GEM_BUG_ON(!slpc->vma); in intel_guc_slpc_enable()
547 slpc_shared_data_reset(slpc->vaddr); in intel_guc_slpc_enable()
549 ret = slpc_reset(slpc); in intel_guc_slpc_enable()
556 ret = slpc_query_task_state(slpc); in intel_guc_slpc_enable()
562 slpc_get_rp_values(slpc); in intel_guc_slpc_enable()
565 ret = slpc_ignore_eff_freq(slpc, true); in intel_guc_slpc_enable()
573 ret = slpc_use_fused_rp0(slpc); in intel_guc_slpc_enable()
581 ret = slpc_set_softlimits(slpc); in intel_guc_slpc_enable()
591 int intel_guc_slpc_print_info(struct intel_guc_slpc *slpc, struct drm_printer *p) in intel_guc_slpc_print_info() argument
593 struct drm_i915_private *i915 = slpc_to_i915(slpc); in intel_guc_slpc_print_info()
594 struct slpc_shared_data *data = slpc->vaddr; in intel_guc_slpc_print_info()
599 GEM_BUG_ON(!slpc->vma); in intel_guc_slpc_print_info()
602 ret = slpc_query_task_state(slpc); in intel_guc_slpc_print_info()
607 drm_printf(p, "\tSLPC state: %s\n", slpc_get_state_string(slpc)); in intel_guc_slpc_print_info()
611 slpc_decode_max_freq(slpc)); in intel_guc_slpc_print_info()
613 slpc_decode_min_freq(slpc)); in intel_guc_slpc_print_info()
620 void intel_guc_slpc_fini(struct intel_guc_slpc *slpc) in intel_guc_slpc_fini() argument
622 if (!slpc->vma) in intel_guc_slpc_fini()
625 i915_vma_unpin_and_release(&slpc->vma, I915_VMA_RELEASE_MAP); in intel_guc_slpc_fini()