]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Allow to change sched_if_idle policy under lock
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 2 Apr 2026 19:17:22 +0000 (21:17 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Sun, 12 Apr 2026 08:32:53 +0000 (10:32 +0200)
In upcoming patch we will need to update sched_if_idle policy when
we already hold the provisioning mutex. Split existing function
into two variants to allow that.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://patch.msgid.link/20260402191726.4932-10-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c
drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.h

index 63e6326d45f845ab99c4977f13ca6197d982f4e6..e8458d63742ddea77e5f1fa2f120d192b996de49 100644 (file)
@@ -192,7 +192,7 @@ static void pf_sanitize_sched_if_idle(struct xe_gt *gt)
 }
 
 /**
- * xe_gt_sriov_pf_policy_set_sched_if_idle - Control the 'sched_if_idle' policy.
+ * xe_gt_sriov_pf_policy_set_sched_if_idle_locked() - Control the 'sched_if_idle' policy.
  * @gt: the &xe_gt where to apply the policy
  * @enable: the value of the 'sched_if_idle' policy
  *
@@ -200,12 +200,12 @@ static void pf_sanitize_sched_if_idle(struct xe_gt *gt)
  *
  * Return: 0 on success or a negative error code on failure.
  */
-int xe_gt_sriov_pf_policy_set_sched_if_idle(struct xe_gt *gt, bool enable)
+int xe_gt_sriov_pf_policy_set_sched_if_idle_locked(struct xe_gt *gt, bool enable)
 {
        u32 priority;
        int err;
 
-       guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
+       lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
 
        err = pf_provision_sched_if_idle(gt, enable);
        if (err)
@@ -223,6 +223,23 @@ int xe_gt_sriov_pf_policy_set_sched_if_idle(struct xe_gt *gt, bool enable)
        return 0;
 }
 
+/**
+ * xe_gt_sriov_pf_policy_set_sched_if_idle() - Control the 'sched_if_idle' policy.
+ * @gt: the &xe_gt where to apply the policy
+ * @enable: the value of the 'sched_if_idle' policy
+ *
+ * This function can only be called on PF.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_gt_sriov_pf_policy_set_sched_if_idle(struct xe_gt *gt, bool enable)
+{
+       xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
+       guard(mutex)(xe_gt_sriov_pf_master_mutex(gt));
+
+       return xe_gt_sriov_pf_policy_set_sched_if_idle_locked(gt, enable);
+}
+
 /**
  * xe_gt_sriov_pf_policy_get_sched_if_idle_locked() - Retrieve value of 'sched_if_idle' policy.
  * @gt: the &xe_gt where to read the policy from
index f437dc1f5e909aed47f7d35f1774f1824086eb79..d667d66897b10d29a11df6538a58b3c8491e91ab 100644 (file)
@@ -14,6 +14,7 @@ struct drm_printer;
 struct xe_gt;
 
 int xe_gt_sriov_pf_policy_set_sched_if_idle(struct xe_gt *gt, bool enable);
+int xe_gt_sriov_pf_policy_set_sched_if_idle_locked(struct xe_gt *gt, bool enable);
 bool xe_gt_sriov_pf_policy_get_sched_if_idle(struct xe_gt *gt);
 bool xe_gt_sriov_pf_policy_get_sched_if_idle_locked(struct xe_gt *gt);
 int xe_gt_sriov_pf_policy_set_reset_engine(struct xe_gt *gt, bool enable);