Lines Matching +full:- +full:gt
1 // SPDX-License-Identifier: MIT
21 * DOC: Xe GT Idle
23 * Contains functions that init GT idle features like C6
25 * device/gt#/gtidle/name - name of the state
26 * device/gt#/gtidle/idle_residency_ms - Provides residency of the idle state in ms
27 * device/gt#/gtidle/idle_status - Provides current idle state
32 struct kobject *kobj = &dev->kobj; in dev_to_gtidle()
34 return &kobj_to_gt(kobj->parent)->gtidle; in dev_to_gtidle()
44 return >idle_to_gt(gtidle)->uc.guc.pc; in gtidle_to_pc()
51 struct xe_gt *gt = container_of(guc, struct xe_gt, uc.guc); in pc_to_xe() local
53 return gt_to_xe(gt); in pc_to_xe()
60 return "gt-c0"; in gt_idle_state_to_string()
62 return "gt-c6"; in gt_idle_state_to_string()
72 lockdep_assert_held(>idle->lock); in get_residency_ms()
78 * Store previous hw counter values for counter wrap-around handling in get_residency_ms()
81 prev_residency = gtidle->prev_residency; in get_residency_ms()
82 gtidle->prev_residency = cur_residency; in get_residency_ms()
86 delta = cur_residency - prev_residency; in get_residency_ms()
88 delta = cur_residency + (overflow_residency - prev_residency); in get_residency_ms()
91 cur_residency = gtidle->cur_residency + delta; in get_residency_ms()
92 gtidle->cur_residency = cur_residency; in get_residency_ms()
95 cur_residency = mul_u64_u32_div(cur_residency, gtidle->residency_multiplier, 1e6); in get_residency_ms()
100 void xe_gt_idle_enable_pg(struct xe_gt *gt) in xe_gt_idle_enable_pg() argument
102 struct xe_device *xe = gt_to_xe(gt); in xe_gt_idle_enable_pg()
103 struct xe_gt_idle *gtidle = >->gtidle; in xe_gt_idle_enable_pg()
104 struct xe_mmio *mmio = >->mmio; in xe_gt_idle_enable_pg()
113 if (xe->info.platform == XE_PVC) in xe_gt_idle_enable_pg()
116 xe_device_assert_mem_access(gt_to_xe(gt)); in xe_gt_idle_enable_pg()
118 vcs_mask = xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_VIDEO_DECODE); in xe_gt_idle_enable_pg()
119 vecs_mask = xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_VIDEO_ENHANCE); in xe_gt_idle_enable_pg()
122 gtidle->powergate_enable = MEDIA_POWERGATE_ENABLE; in xe_gt_idle_enable_pg()
124 if (xe_gt_is_main_type(gt)) in xe_gt_idle_enable_pg()
125 gtidle->powergate_enable |= RENDER_POWERGATE_ENABLE; in xe_gt_idle_enable_pg()
128 gtidle->powergate_enable |= MEDIA_SAMPLERS_POWERGATE_ENABLE; in xe_gt_idle_enable_pg()
130 if (xe->info.platform != XE_DG1) { in xe_gt_idle_enable_pg()
132 if ((gt->info.engine_mask & BIT(i))) in xe_gt_idle_enable_pg()
133 gtidle->powergate_enable |= (VDN_HCP_POWERGATE_ENABLE(j) | in xe_gt_idle_enable_pg()
138 fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_idle_enable_pg()
139 if (xe->info.skip_guc_pc) { in xe_gt_idle_enable_pg()
148 xe_mmio_write32(mmio, POWERGATE_ENABLE, gtidle->powergate_enable); in xe_gt_idle_enable_pg()
149 xe_force_wake_put(gt_to_fw(gt), fw_ref); in xe_gt_idle_enable_pg()
152 void xe_gt_idle_disable_pg(struct xe_gt *gt) in xe_gt_idle_disable_pg() argument
154 struct xe_gt_idle *gtidle = >->gtidle; in xe_gt_idle_disable_pg()
157 if (IS_SRIOV_VF(gt_to_xe(gt))) in xe_gt_idle_disable_pg()
160 xe_device_assert_mem_access(gt_to_xe(gt)); in xe_gt_idle_disable_pg()
161 gtidle->powergate_enable = 0; in xe_gt_idle_disable_pg()
163 fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_idle_disable_pg()
164 xe_mmio_write32(>->mmio, POWERGATE_ENABLE, gtidle->powergate_enable); in xe_gt_idle_disable_pg()
165 xe_force_wake_put(gt_to_fw(gt), fw_ref); in xe_gt_idle_disable_pg()
169 * xe_gt_idle_pg_print - Xe powergating info
170 * @gt: GT object
177 int xe_gt_idle_pg_print(struct xe_gt *gt, struct drm_printer *p) in xe_gt_idle_pg_print() argument
179 struct xe_gt_idle *gtidle = >->gtidle; in xe_gt_idle_pg_print()
180 struct xe_device *xe = gt_to_xe(gt); in xe_gt_idle_pg_print()
211 if (xe->info.platform == XE_PVC) { in xe_gt_idle_pg_print()
216 state = gtidle->idle_status(gtidle_to_pc(gtidle)); in xe_gt_idle_pg_print()
217 pg_enabled = gtidle->powergate_enable; in xe_gt_idle_pg_print()
219 /* Do not wake the GT to read powergating status */ in xe_gt_idle_pg_print()
221 fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_idle_pg_print()
223 return -ETIMEDOUT; in xe_gt_idle_pg_print()
225 pg_enabled = xe_mmio_read32(>->mmio, POWERGATE_ENABLE); in xe_gt_idle_pg_print()
226 pg_status = xe_mmio_read32(>->mmio, POWERGATE_DOMAIN_STATUS); in xe_gt_idle_pg_print()
228 xe_force_wake_put(gt_to_fw(gt), fw_ref); in xe_gt_idle_pg_print()
231 if (gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK) { in xe_gt_idle_pg_print()
239 vcs_mask = xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_VIDEO_DECODE); in xe_gt_idle_pg_print()
240 vecs_mask = xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_VIDEO_ENHANCE); in xe_gt_idle_pg_print()
248 if (gt->info.engine_mask & media_slices[n].engines) in xe_gt_idle_pg_print()
269 ret = sysfs_emit(buff, "%s\n", gtidle->name); in name_show()
285 state = gtidle->idle_status(pc); in idle_status_show()
298 raw_spin_lock_irqsave(>idle->lock, flags); in xe_gt_idle_residency_msec()
299 residency = get_residency_ms(gtidle, gtidle->idle_residency(pc)); in xe_gt_idle_residency_msec()
300 raw_spin_unlock_irqrestore(>idle->lock, flags); in xe_gt_idle_residency_msec()
332 struct xe_gt *gt = kobj_to_gt(kobj->parent); in gt_idle_fini() local
334 xe_gt_idle_disable_pg(gt); in gt_idle_fini()
336 if (gt_to_xe(gt)->info.skip_guc_pc) in gt_idle_fini()
337 xe_gt_idle_disable_c6(gt); in gt_idle_fini()
345 struct xe_gt *gt = gtidle_to_gt(gtidle); in xe_gt_idle_init() local
346 struct xe_device *xe = gt_to_xe(gt); in xe_gt_idle_init()
353 kobj = kobject_create_and_add("gtidle", gt->sysfs); in xe_gt_idle_init()
355 return -ENOMEM; in xe_gt_idle_init()
357 raw_spin_lock_init(>idle->lock); in xe_gt_idle_init()
359 if (xe_gt_is_media_type(gt)) { in xe_gt_idle_init()
360 snprintf(gtidle->name, sizeof(gtidle->name), "gt%d-mc", gt->info.id); in xe_gt_idle_init()
361 gtidle->idle_residency = xe_guc_pc_mc6_residency; in xe_gt_idle_init()
363 snprintf(gtidle->name, sizeof(gtidle->name), "gt%d-rc", gt->info.id); in xe_gt_idle_init()
364 gtidle->idle_residency = xe_guc_pc_rc6_residency; in xe_gt_idle_init()
368 gtidle->residency_multiplier = 1280; in xe_gt_idle_init()
369 gtidle->idle_status = xe_guc_pc_c_status; in xe_gt_idle_init()
377 xe_gt_idle_enable_pg(gt); in xe_gt_idle_init()
379 return devm_add_action_or_reset(xe->drm.dev, gt_idle_fini, kobj); in xe_gt_idle_init()
382 void xe_gt_idle_enable_c6(struct xe_gt *gt) in xe_gt_idle_enable_c6() argument
384 xe_device_assert_mem_access(gt_to_xe(gt)); in xe_gt_idle_enable_c6()
385 xe_force_wake_assert_held(gt_to_fw(gt), XE_FW_GT); in xe_gt_idle_enable_c6()
387 if (IS_SRIOV_VF(gt_to_xe(gt))) in xe_gt_idle_enable_c6()
391 xe_mmio_write32(>->mmio, RC_IDLE_HYSTERSIS, 0x3B9ACA); in xe_gt_idle_enable_c6()
393 xe_mmio_write32(>->mmio, RC_CONTROL, in xe_gt_idle_enable_c6()
397 int xe_gt_idle_disable_c6(struct xe_gt *gt) in xe_gt_idle_disable_c6() argument
401 xe_device_assert_mem_access(gt_to_xe(gt)); in xe_gt_idle_disable_c6()
403 if (IS_SRIOV_VF(gt_to_xe(gt))) in xe_gt_idle_disable_c6()
406 fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT); in xe_gt_idle_disable_c6()
408 return -ETIMEDOUT; in xe_gt_idle_disable_c6()
410 xe_mmio_write32(>->mmio, RC_CONTROL, 0); in xe_gt_idle_disable_c6()
411 xe_mmio_write32(>->mmio, RC_STATE, 0); in xe_gt_idle_disable_c6()
413 xe_force_wake_put(gt_to_fw(gt), fw_ref); in xe_gt_idle_disable_c6()