Lines Matching full:gt
37 static int pf_send_policy_klvs(struct xe_gt *gt, const u32 *klvs, u32 num_dwords) in pf_send_policy_klvs() argument
40 struct xe_tile *tile = gt_to_tile(gt); in pf_send_policy_klvs()
42 struct xe_guc *guc = >->uc.guc; in pf_send_policy_klvs()
67 static int pf_push_policy_klvs(struct xe_gt *gt, u32 num_klvs, in pf_push_policy_klvs() argument
72 xe_gt_assert(gt, num_klvs == xe_guc_klv_count(klvs, num_dwords)); in pf_push_policy_klvs()
74 ret = pf_send_policy_klvs(gt, klvs, num_dwords); in pf_push_policy_klvs()
78 struct drm_printer p = xe_gt_info_printer(gt); in pf_push_policy_klvs()
80 xe_gt_sriov_notice(gt, "Failed to push %u policy KLV%s (%pe)\n", in pf_push_policy_klvs()
89 static int pf_push_policy_u32(struct xe_gt *gt, u16 key, u32 value) in pf_push_policy_u32() argument
96 return pf_push_policy_klvs(gt, 1, klv, ARRAY_SIZE(klv)); in pf_push_policy_u32()
99 static int pf_update_policy_bool(struct xe_gt *gt, u16 key, bool *policy, bool value) in pf_update_policy_bool() argument
103 err = pf_push_policy_u32(gt, key, value); in pf_update_policy_bool()
105 xe_gt_sriov_notice(gt, "Failed to update policy %#x '%s' to '%s' (%pe)\n", in pf_update_policy_bool()
111 xe_gt_sriov_dbg(gt, "policy key %#x '%s' updated to '%s'\n", in pf_update_policy_bool()
119 static int pf_update_policy_u32(struct xe_gt *gt, u16 key, u32 *policy, u32 value) in pf_update_policy_u32() argument
123 err = pf_push_policy_u32(gt, key, value); in pf_update_policy_u32()
125 xe_gt_sriov_notice(gt, "Failed to update policy %#x '%s' to '%s' (%pe)\n", in pf_update_policy_u32()
131 xe_gt_sriov_dbg(gt, "policy key %#x '%s' updated to %u\n", in pf_update_policy_u32()
138 static int pf_provision_sched_if_idle(struct xe_gt *gt, bool enable) in pf_provision_sched_if_idle() argument
140 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_provision_sched_if_idle()
141 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_provision_sched_if_idle()
143 return pf_update_policy_bool(gt, GUC_KLV_VGT_POLICY_SCHED_IF_IDLE_KEY, in pf_provision_sched_if_idle()
144 >->sriov.pf.policy.guc.sched_if_idle, in pf_provision_sched_if_idle()
148 static int pf_reprovision_sched_if_idle(struct xe_gt *gt) in pf_reprovision_sched_if_idle() argument
150 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_reprovision_sched_if_idle()
151 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_reprovision_sched_if_idle()
153 return pf_provision_sched_if_idle(gt, gt->sriov.pf.policy.guc.sched_if_idle); in pf_reprovision_sched_if_idle()
156 static void pf_sanitize_sched_if_idle(struct xe_gt *gt) in pf_sanitize_sched_if_idle() argument
158 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_sanitize_sched_if_idle()
159 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_sanitize_sched_if_idle()
161 gt->sriov.pf.policy.guc.sched_if_idle = false; in pf_sanitize_sched_if_idle()
166 * @gt: the &xe_gt where to apply the policy
173 int xe_gt_sriov_pf_policy_set_sched_if_idle(struct xe_gt *gt, bool enable) in xe_gt_sriov_pf_policy_set_sched_if_idle() argument
177 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_set_sched_if_idle()
178 err = pf_provision_sched_if_idle(gt, enable); in xe_gt_sriov_pf_policy_set_sched_if_idle()
179 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_set_sched_if_idle()
186 * @gt: the &xe_gt where to read the policy from
192 bool xe_gt_sriov_pf_policy_get_sched_if_idle(struct xe_gt *gt) in xe_gt_sriov_pf_policy_get_sched_if_idle() argument
196 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in xe_gt_sriov_pf_policy_get_sched_if_idle()
198 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_get_sched_if_idle()
199 enable = gt->sriov.pf.policy.guc.sched_if_idle; in xe_gt_sriov_pf_policy_get_sched_if_idle()
200 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_get_sched_if_idle()
205 static int pf_provision_reset_engine(struct xe_gt *gt, bool enable) in pf_provision_reset_engine() argument
207 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_provision_reset_engine()
208 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_provision_reset_engine()
210 return pf_update_policy_bool(gt, GUC_KLV_VGT_POLICY_RESET_AFTER_VF_SWITCH_KEY, in pf_provision_reset_engine()
211 >->sriov.pf.policy.guc.reset_engine, enable); in pf_provision_reset_engine()
214 static int pf_reprovision_reset_engine(struct xe_gt *gt) in pf_reprovision_reset_engine() argument
216 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_reprovision_reset_engine()
217 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_reprovision_reset_engine()
219 return pf_provision_reset_engine(gt, gt->sriov.pf.policy.guc.reset_engine); in pf_reprovision_reset_engine()
222 static void pf_sanitize_reset_engine(struct xe_gt *gt) in pf_sanitize_reset_engine() argument
224 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_sanitize_reset_engine()
225 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_sanitize_reset_engine()
227 gt->sriov.pf.policy.guc.reset_engine = false; in pf_sanitize_reset_engine()
232 * @gt: the &xe_gt where to apply the policy
239 int xe_gt_sriov_pf_policy_set_reset_engine(struct xe_gt *gt, bool enable) in xe_gt_sriov_pf_policy_set_reset_engine() argument
243 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_set_reset_engine()
244 err = pf_provision_reset_engine(gt, enable); in xe_gt_sriov_pf_policy_set_reset_engine()
245 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_set_reset_engine()
252 * @gt: the &xe_gt where to read the policy from
258 bool xe_gt_sriov_pf_policy_get_reset_engine(struct xe_gt *gt) in xe_gt_sriov_pf_policy_get_reset_engine() argument
262 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in xe_gt_sriov_pf_policy_get_reset_engine()
264 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_get_reset_engine()
265 enable = gt->sriov.pf.policy.guc.reset_engine; in xe_gt_sriov_pf_policy_get_reset_engine()
266 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_get_reset_engine()
271 static int pf_provision_sample_period(struct xe_gt *gt, u32 value) in pf_provision_sample_period() argument
273 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_provision_sample_period()
274 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_provision_sample_period()
276 return pf_update_policy_u32(gt, GUC_KLV_VGT_POLICY_ADVERSE_SAMPLE_PERIOD_KEY, in pf_provision_sample_period()
277 >->sriov.pf.policy.guc.sample_period, value); in pf_provision_sample_period()
280 static int pf_reprovision_sample_period(struct xe_gt *gt) in pf_reprovision_sample_period() argument
282 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_reprovision_sample_period()
283 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_reprovision_sample_period()
285 return pf_provision_sample_period(gt, gt->sriov.pf.policy.guc.sample_period); in pf_reprovision_sample_period()
288 static void pf_sanitize_sample_period(struct xe_gt *gt) in pf_sanitize_sample_period() argument
290 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in pf_sanitize_sample_period()
291 lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt)); in pf_sanitize_sample_period()
293 gt->sriov.pf.policy.guc.sample_period = 0; in pf_sanitize_sample_period()
298 * @gt: the &xe_gt where to apply the policy
305 int xe_gt_sriov_pf_policy_set_sample_period(struct xe_gt *gt, u32 value) in xe_gt_sriov_pf_policy_set_sample_period() argument
309 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_set_sample_period()
310 err = pf_provision_sample_period(gt, value); in xe_gt_sriov_pf_policy_set_sample_period()
311 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_set_sample_period()
318 * @gt: the &xe_gt where to read the policy from
324 u32 xe_gt_sriov_pf_policy_get_sample_period(struct xe_gt *gt) in xe_gt_sriov_pf_policy_get_sample_period() argument
328 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in xe_gt_sriov_pf_policy_get_sample_period()
330 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_get_sample_period()
331 value = gt->sriov.pf.policy.guc.sample_period; in xe_gt_sriov_pf_policy_get_sample_period()
332 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_get_sample_period()
337 static void pf_sanitize_guc_policies(struct xe_gt *gt) in pf_sanitize_guc_policies() argument
339 pf_sanitize_sched_if_idle(gt); in pf_sanitize_guc_policies()
340 pf_sanitize_reset_engine(gt); in pf_sanitize_guc_policies()
341 pf_sanitize_sample_period(gt); in pf_sanitize_guc_policies()
346 * @gt: the &xe_gt
352 void xe_gt_sriov_pf_policy_sanitize(struct xe_gt *gt) in xe_gt_sriov_pf_policy_sanitize() argument
354 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_sanitize()
355 pf_sanitize_guc_policies(gt); in xe_gt_sriov_pf_policy_sanitize()
356 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_sanitize()
361 * @gt: the &xe_gt
368 int xe_gt_sriov_pf_policy_reprovision(struct xe_gt *gt, bool reset) in xe_gt_sriov_pf_policy_reprovision() argument
372 xe_pm_runtime_get_noresume(gt_to_xe(gt)); in xe_gt_sriov_pf_policy_reprovision()
374 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_reprovision()
376 pf_sanitize_guc_policies(gt); in xe_gt_sriov_pf_policy_reprovision()
377 err |= pf_reprovision_sched_if_idle(gt); in xe_gt_sriov_pf_policy_reprovision()
378 err |= pf_reprovision_reset_engine(gt); in xe_gt_sriov_pf_policy_reprovision()
379 err |= pf_reprovision_sample_period(gt); in xe_gt_sriov_pf_policy_reprovision()
380 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_reprovision()
382 xe_pm_runtime_put(gt_to_xe(gt)); in xe_gt_sriov_pf_policy_reprovision()
402 * @gt: the &xe_gt where to read the policy from
409 int xe_gt_sriov_pf_policy_print(struct xe_gt *gt, struct drm_printer *p) in xe_gt_sriov_pf_policy_print() argument
411 xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); in xe_gt_sriov_pf_policy_print()
413 mutex_lock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_print()
414 print_guc_policies(p, >->sriov.pf.policy.guc); in xe_gt_sriov_pf_policy_print()
415 mutex_unlock(xe_gt_sriov_pf_master_mutex(gt)); in xe_gt_sriov_pf_policy_print()