[PATCH 14/15] drm/xe: Implement SR-IOV and eudebug exclusivity
Mika Kuoppala
mika.kuoppala at linux.intel.com
Fri Aug 8 10:43:49 UTC 2025
From: Christoph Manszewski <christoph.manszewski at intel.com>
EU debug functionality relies on access to specific mmio registers.
Since VFs don't have access to those registers and in order to avoid
interference with VFs, make SR-IOV and eudebug functionality exclusive.
I.e. don't allow to enable eudebug in VF mode and don't allow to enable
eudebug when any VFs are provisioned. Likewise, don't allow to provision
VFs when eudebug is enabled.
Signed-off-by: Christoph Manszewski <christoph.manszewski at intel.com>
Signed-off-by: Maciej Patelczyk <maciej.patelczyk at intel.com>
---
drivers/gpu/drm/xe/tests/xe_eudebug.c | 6 +++++
drivers/gpu/drm/xe/xe_eudebug.c | 33 +++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_eudebug.h | 6 +++++
drivers/gpu/drm/xe/xe_exec_queue.c | 3 +++
drivers/gpu/drm/xe/xe_gt.c | 1 +
drivers/gpu/drm/xe/xe_pci_sriov.c | 10 ++++++++
6 files changed, 59 insertions(+)
diff --git a/drivers/gpu/drm/xe/tests/xe_eudebug.c b/drivers/gpu/drm/xe/tests/xe_eudebug.c
index f839fb292b9b..c1e5eb091fc4 100644
--- a/drivers/gpu/drm/xe/tests/xe_eudebug.c
+++ b/drivers/gpu/drm/xe/tests/xe_eudebug.c
@@ -147,6 +147,12 @@ static int toggle_reg_value(struct xe_device *xe)
struct kunit *test = kunit_get_current_test();
bool enable_eudebug = xe_eudebug_is_enabled(xe);
+ if (IS_SRIOV_VF(xe))
+ kunit_skip(test, "eudebug not available in SR-IOV VF mode\n");
+
+ if (xe->eudebug.state == XE_EUDEBUG_NOT_SUPPORTED)
+ kunit_skip(test, "eudebug not supported\n");
+
kunit_printk(KERN_DEBUG, test, "Test eudebug WAs for graphics version: %u\n",
GRAPHICS_VERx100(xe));
diff --git a/drivers/gpu/drm/xe/xe_eudebug.c b/drivers/gpu/drm/xe/xe_eudebug.c
index 2426bb92792e..8f98233f06f2 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.c
+++ b/drivers/gpu/drm/xe/xe_eudebug.c
@@ -2124,6 +2124,34 @@ bool xe_eudebug_is_enabled(struct xe_device *xe)
return READ_ONCE(xe->eudebug.state) == XE_EUDEBUG_ENABLED;
}
+static int __xe_eudebug_toggle_support(struct xe_device *xe,
+ bool support_enable)
+{
+ mutex_lock(&xe->eudebug.lock);
+
+ if (xe_eudebug_is_enabled(xe)) {
+ mutex_unlock(&xe->eudebug.lock);
+ return -EPERM;
+ }
+
+ xe->eudebug.state = support_enable ?
+ XE_EUDEBUG_DISABLED : XE_EUDEBUG_NOT_SUPPORTED;
+
+ mutex_unlock(&xe->eudebug.lock);
+
+ return 0;
+}
+
+void xe_eudebug_support_enable(struct xe_device *xe)
+{
+ __xe_eudebug_toggle_support(xe, true);
+}
+
+int xe_eudebug_support_disable(struct xe_device *xe)
+{
+ return __xe_eudebug_toggle_support(xe, false);
+}
+
static int xe_eudebug_enable(struct xe_device *xe, bool enable)
{
struct xe_gt *gt;
@@ -2229,6 +2257,11 @@ void xe_eudebug_init(struct xe_device *xe)
xe->eudebug.state = XE_EUDEBUG_NOT_SUPPORTED;
+ if (IS_SRIOV_VF(xe)) {
+ drm_info(&xe->drm, "eudebug not available in SR-IOV VF mode\n");
+ return;
+ }
+
err = drmm_mutex_init(dev, &xe->eudebug.lock);
if (err)
goto out_err;
diff --git a/drivers/gpu/drm/xe/xe_eudebug.h b/drivers/gpu/drm/xe/xe_eudebug.h
index 63a647c242cc..428ae70bdc90 100644
--- a/drivers/gpu/drm/xe/xe_eudebug.h
+++ b/drivers/gpu/drm/xe/xe_eudebug.h
@@ -46,6 +46,9 @@ int xe_eudebug_connect_ioctl(struct drm_device *dev,
void *data,
struct drm_file *file);
+void xe_eudebug_support_enable(struct xe_device *xe);
+int xe_eudebug_support_disable(struct xe_device *xe);
+
void xe_eudebug_init(struct xe_device *xe);
bool xe_eudebug_is_enabled(struct xe_device *xe);
@@ -80,6 +83,9 @@ static inline int xe_eudebug_connect_ioctl(struct drm_device *dev,
void *data,
struct drm_file *file) { return 0; }
+static inline void xe_eudebug_support_enable(struct xe_device *xe) { }
+static inline int xe_eudebug_support_disable(struct xe_device *xe) { return 0; }
+
static inline void xe_eudebug_init(struct xe_device *xe) { }
static inline bool xe_eudebug_is_enabled(struct xe_device *xe) { return false; }
diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
index 3c2eedcc2bca..3b85208fcfd0 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue.c
+++ b/drivers/gpu/drm/xe/xe_exec_queue.c
@@ -524,6 +524,9 @@ static int exec_queue_set_eudebug(struct xe_device *xe, struct xe_exec_queue *q,
!(value & DRM_XE_EXEC_QUEUE_EUDEBUG_FLAG_ENABLE)))
return -EINVAL;
+ if (XE_IOCTL_DBG(xe, !xe_eudebug_is_enabled(xe)))
+ return -EPERM;
+
q->eudebug_flags = EXEC_QUEUE_EUDEBUG_FLAG_ENABLE;
q->sched_props.preempt_timeout_us = 0;
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 390394bbaadc..4c32d868b5ad 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -21,6 +21,7 @@
#include "xe_bb.h"
#include "xe_bo.h"
#include "xe_device.h"
+#include "xe_eudebug.h"
#include "xe_eu_stall.h"
#include "xe_exec_queue.h"
#include "xe_execlist.h"
diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
index af05db07162e..4b5de4ffe5e4 100644
--- a/drivers/gpu/drm/xe/xe_pci_sriov.c
+++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
@@ -9,6 +9,7 @@
#include "regs/xe_bars.h"
#include "xe_assert.h"
#include "xe_device.h"
+#include "xe_eudebug.h"
#include "xe_gt_sriov_pf_config.h"
#include "xe_gt_sriov_pf_control.h"
#include "xe_gt_sriov_printk.h"
@@ -155,6 +156,10 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
xe_assert(xe, num_vfs <= total_vfs);
xe_sriov_dbg(xe, "enabling %u VF%s\n", num_vfs, str_plural(num_vfs));
+ err = xe_eudebug_support_disable(xe);
+ if (err < 0)
+ goto failed_eudebug;
+
err = xe_sriov_pf_wait_ready(xe);
if (err)
goto out;
@@ -197,6 +202,9 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
pf_unprovision_vfs(xe, num_vfs);
xe_pm_runtime_put(xe);
out:
+ xe_eudebug_support_enable(xe);
+failed_eudebug:
+
xe_sriov_notice(xe, "Failed to enable %u VF%s (%pe)\n",
num_vfs, str_plural(num_vfs), ERR_PTR(err));
return err;
@@ -225,6 +233,8 @@ static int pf_disable_vfs(struct xe_device *xe)
/* not needed anymore - see pf_enable_vfs() */
xe_pm_runtime_put(xe);
+ xe_eudebug_support_enable(xe);
+
xe_sriov_info(xe, "Disabled %u VF%s\n", num_vfs, str_plural(num_vfs));
return 0;
}
--
2.43.0
More information about the Intel-xe
mailing list