From: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: michal.wajdeczko@intel.com,
Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
Subject: [V8 PATCH] drm/xe: Mutual exclusivity between CCS-mode and PF
Date: Thu, 27 Nov 2025 17:08:47 +0530 [thread overview]
Message-ID: <20251127113846.2749261-2-naresh.kumar.g@intel.com> (raw)
In-Reply-To: <20250915143331.3269895-2-naresh.kumar.g@intel.com>
Due to SLA agreement between PF and VFs,the alternate CCS-mode
cannot be changed when VFs are already enabled.
Similarly, enabling VFs is not permitted when the alternate
CCS-mode is active. Additionally, the sysfs entry for
CCS-mode is not created for SR-IOV VF mode.
Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
---
v2:
- function xe_device_is_vf_enabled has been refactored to
xe_sriov_pf_has_vfs_enabled and moved to xe_sriov_pf_helper.h.
- The code now distinctly checks for SR-IOV VF mode and
SR-IOV PF with VFs enabled.
- Log messages have been updated to explicitly state the current mode.
- The function xe_multi_ccs_mode_enabled is moved to xe_device.h
v3: Described missed arg documentation for xe_sriov_pf_has_vfs_enabled
v4:
- sysfs interface for CCS mode is not initialized
when operating in SRIOV VF Mode.
- xe_sriov_pf_has_vfs_enabled() check is sufficient while CCS mode
enablement.
- remove unnecessary comments as flow is self explanatory.
v5:(review comments from Michal)
- Add xe device level CCS mode block with mutex lock and CCS mode state
- necessesary functions to manage ccs mode state to provide strict mutual
exclusive support b/w CCS mode & SRIOV VF enabling
v6:
- Re modeled implementation based on lockdown the PF using custom guard
supported functions by Michal
v7:
- Corrected patch style as message written as subject
- Used public PF lockdown functions instead internal funcions(Michal)
- Creating CCS Mode entries only on PF Mode
v8:(Michal)
- updated short subject and few comments
- used guard for mutex
- Add a check of PF Mode to ensure use of xe_sriov_pf_lockdown only in
PF Mode
- Added default CCS mode check to xe_gt_ccs_mode_default(gt) function
---
drivers/gpu/drm/xe/xe_gt_ccs_mode.c | 57 ++++++++++++++++++++++++-----
drivers/gpu/drm/xe/xe_gt_ccs_mode.h | 1 +
2 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_gt_ccs_mode.c b/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
index 50fffc9ebf62..957ae6586b9d 100644
--- a/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
+++ b/drivers/gpu/drm/xe/xe_gt_ccs_mode.c
@@ -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)
{
@@ -108,6 +109,45 @@ ccs_mode_show(struct device *kdev,
return sysfs_emit(buf, "%u\n", gt->ccs_mode);
}
+bool xe_gt_ccs_mode_default(struct xe_gt *gt)
+{
+ return gt->ccs_mode == 1;
+}
+
+static int gt_prepare_ccs_mode_enabling(struct xe_gt *gt)
+{
+ struct xe_device *xe = gt_to_xe(gt);
+
+ /*
+ * Ensure the system is operating in PF Mode before invoking
+ * the xe_sriov_pf_lockdown function.
+ * if not in PF Mode,return 0,as its Non-SRIOV Mode
+ */
+ if (!IS_SRIOV_PF(xe))
+ return 0;
+
+ /*
+ * We can't change CCS-mode when VFs are already enabled
+ * and we must prevent enabling VFs when alternate
+ * CCS-mode is active
+ */
+ if (xe_gt_ccs_mode_default(gt))
+ return xe_sriov_pf_lockdown(xe);
+
+ return 0;
+}
+
+static void gt_finish_ccs_mode_enabling(struct xe_gt *gt)
+{
+ struct xe_device *xe = gt_to_xe(gt);
+
+ if (IS_SRIOV_PF(xe)) {
+ /* Allow enabling VFs, if CCS-mode changed to default mode */
+ if (xe_gt_ccs_mode_default(gt))
+ xe_sriov_pf_end_lockdown(xe);
+ }
+}
+
static ssize_t
ccs_mode_store(struct device *kdev, struct device_attribute *attr,
const char *buff, size_t count)
@@ -117,12 +157,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,13 +173,16 @@ 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;
}
+ ret = gt_prepare_ccs_mode_enabling(gt);
+ if (ret)
+ return ret;
+
if (gt->ccs_mode != num_engines) {
xe_gt_info(gt, "Setting compute mode to %d\n", num_engines);
gt->ccs_mode = num_engines;
@@ -153,7 +190,7 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
xe_gt_reset(gt);
}
- mutex_unlock(&xe->drm.filelist_mutex);
+ gt_finish_ccs_mode_enabling(gt);
return count;
}
@@ -191,7 +228,7 @@ int xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt)
struct xe_device *xe = gt_to_xe(gt);
int err;
- if (!xe_gt_ccs_mode_enabled(gt))
+ if (!xe_gt_ccs_mode_enabled(gt) || IS_SRIOV_VF(xe))
return 0;
err = sysfs_create_files(gt->sysfs, gt_ccs_mode_attrs);
diff --git a/drivers/gpu/drm/xe/xe_gt_ccs_mode.h b/drivers/gpu/drm/xe/xe_gt_ccs_mode.h
index f8779852cf0d..224bd553e9dc 100644
--- a/drivers/gpu/drm/xe/xe_gt_ccs_mode.h
+++ b/drivers/gpu/drm/xe/xe_gt_ccs_mode.h
@@ -13,6 +13,7 @@
void xe_gt_apply_ccs_mode(struct xe_gt *gt);
int xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt);
+bool xe_gt_ccs_mode_default(struct xe_gt *gt);
static inline bool xe_gt_ccs_mode_enabled(const struct xe_gt *gt)
{
--
2.43.0
next prev parent reply other threads:[~2025-11-27 11:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 14:33 [PATCH] drm/xe/: Mutual Exclusivity b/w Multi CCS Mode & SRIOV VF Provisioning Nareshkumar Gollakoti
2025-09-15 15:42 ` ✓ CI.KUnit: success for " Patchwork
2025-09-15 16:18 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-15 20:17 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-17 6:37 ` [PATCH] " Varun Gupta
2025-09-22 17:42 ` Michal Wajdeczko
2025-11-27 11:38 ` Nareshkumar Gollakoti [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-25 16:57 [V7 PATCH] drm/xe/xe_gt_ccs_mode:Mutual " Nareshkumar Gollakoti
2025-11-27 16:10 ` [V8 PATCH] drm/xe: Mutual exclusivity between CCS-mode and PF Nareshkumar Gollakoti
2025-11-27 17:02 ` Michal Wajdeczko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251127113846.2749261-2-naresh.kumar.g@intel.com \
--to=naresh.kumar.g@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox