]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Mutual exclusivity between CCS-mode and PF
authorNareshkumar Gollakoti <naresh.kumar.g@intel.com>
Mon, 2 Feb 2026 17:08:13 +0000 (22:38 +0530)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 5 Feb 2026 21:03:59 +0000 (22:03 +0100)
Due to SLA agreement between PF and VFs, currently we block CCS
mode changes if driver is running as PF, even if there are no VFs
enabled yet. Use lockdown mechanism provided by the PF to relax
that limitation and still enforce above VFs related requirements.

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patch.msgid.link/20260202170810.1393147-6-naresh.kumar.g@intel.com
drivers/gpu/drm/xe/xe_gt_ccs_mode.c

index fe944687728cd80a05f6871891bb6c195ba1360e..b35be36b0eaa2bd9e6b102b3789263c1aa0ea51b 100644 (file)
@@ -13,6 +13,7 @@
 #include "xe_gt_sysfs.h"
 #include "xe_mmio.h"
 #include "xe_sriov.h"
+#include "xe_sriov_pf.h"
 
 static void __xe_gt_apply_ccs_mode(struct xe_gt *gt, u32 num_engines)
 {
@@ -88,6 +89,11 @@ void xe_gt_apply_ccs_mode(struct xe_gt *gt)
        __xe_gt_apply_ccs_mode(gt, gt->ccs_mode);
 }
 
+static bool gt_ccs_mode_default(struct xe_gt *gt)
+{
+       return gt->ccs_mode == 1;
+}
+
 static ssize_t
 num_cslices_show(struct device *kdev,
                 struct device_attribute *attr, char *buf)
@@ -117,12 +123,6 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
        u32 num_engines, num_slices;
        int ret;
 
-       if (IS_SRIOV(xe)) {
-               xe_gt_dbg(gt, "Can't change compute mode when running as %s\n",
-                         xe_sriov_mode_to_string(xe_device_sriov_mode(xe)));
-               return -EOPNOTSUPP;
-       }
-
        ret = kstrtou32(buff, 0, &num_engines);
        if (ret)
                return ret;
@@ -139,21 +139,35 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
        }
 
        /* CCS mode can only be updated when there are no drm clients */
-       mutex_lock(&xe->drm.filelist_mutex);
+       guard(mutex)(&xe->drm.filelist_mutex);
        if (!list_empty(&xe->drm.filelist)) {
-               mutex_unlock(&xe->drm.filelist_mutex);
                xe_gt_dbg(gt, "Rejecting compute mode change as there are active drm clients\n");
                return -EBUSY;
        }
 
-       if (gt->ccs_mode != num_engines) {
-               xe_gt_info(gt, "Setting compute mode to %d\n", num_engines);
-               gt->ccs_mode = num_engines;
-               xe_gt_record_user_engines(gt);
-               xe_gt_reset(gt);
+       if (gt->ccs_mode == num_engines)
+               return count;
+
+       /*
+        * Changing default CCS mode is only allowed when there
+        * are no VFs. Try to lockdown PF to find out.
+        */
+       if (gt_ccs_mode_default(gt) && IS_SRIOV_PF(xe)) {
+               ret = xe_sriov_pf_lockdown(xe);
+               if (ret) {
+                       xe_gt_dbg(gt, "Can't change CCS Mode: VFs are enabled\n");
+                       return ret;
+               }
        }
 
-       mutex_unlock(&xe->drm.filelist_mutex);
+       xe_gt_info(gt, "Setting compute mode to %d\n", num_engines);
+       gt->ccs_mode = num_engines;
+       xe_gt_record_user_engines(gt);
+       xe_gt_reset(gt);
+
+       /* We may end PF lockdown once CCS mode is default again */
+       if (gt_ccs_mode_default(gt) && IS_SRIOV_PF(xe))
+               xe_sriov_pf_end_lockdown(xe);
 
        return count;
 }