drm/xe/pf: Adjust scheduling priority based on policy change
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 6 Nov 2024 15:13:01 +0000 (16:13 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 8 Nov 2024 12:31:18 +0000 (13:31 +0100)
Local values of scheduling priorities need to be adjusted when
changing the schedule_if_idle policy as those are related.

Disabling schedule_if_idle policy forces the low priority, and
enabling schedule_if_idle policy forces the normal priority.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Lukasz Laguna <lukasz.laguna@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241106151301.2079-6-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c

index fae5be5..c00fb35 100644 (file)
@@ -135,14 +135,33 @@ static int pf_update_policy_u32(struct xe_gt *gt, u16 key, u32 *policy, u32 valu
        return 0;
 }
 
+static void pf_bulk_reset_sched_priority(struct xe_gt *gt, u32 priority)
+{
+       unsigned int total_vfs = 1 + xe_gt_sriov_pf_get_totalvfs(gt);
+       unsigned int n;
+
+       xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
+       lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
+
+       for (n = 0; n < total_vfs; n++)
+               gt->sriov.pf.vfs[n].config.sched_priority = priority;
+}
+
 static int pf_provision_sched_if_idle(struct xe_gt *gt, bool enable)
 {
+       int err;
+
        xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
        lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
 
-       return pf_update_policy_bool(gt, GUC_KLV_VGT_POLICY_SCHED_IF_IDLE_KEY,
-                                    &gt->sriov.pf.policy.guc.sched_if_idle,
-                                    enable);
+       err = pf_update_policy_bool(gt, GUC_KLV_VGT_POLICY_SCHED_IF_IDLE_KEY,
+                                   &gt->sriov.pf.policy.guc.sched_if_idle,
+                                   enable);
+
+       if (!err)
+               pf_bulk_reset_sched_priority(gt, enable ? GUC_SCHED_PRIORITY_NORMAL :
+                                            GUC_SCHED_PRIORITY_LOW);
+       return err;
 }
 
 static int pf_reprovision_sched_if_idle(struct xe_gt *gt)