[Intel-xe] [RFC 1/3] drm/xe: Add CONFIG_DRM_XE_PREEMPT_TIMEOUT

Niranjana Vishwanathapura niranjana.vishwanathapura at intel.com
Sat Jun 10 00:12:24 UTC 2023


Allow preemption timeout to be specified as a config option.

Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura at intel.com>
---
 drivers/gpu/drm/xe/Kconfig         |  6 ++++++
 drivers/gpu/drm/xe/Kconfig.profile | 12 ++++++++++++
 drivers/gpu/drm/xe/xe_engine.c     | 16 +++++++++++++++-
 3 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/xe/Kconfig.profile

diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
index d44794f99338..0e912bab2bc5 100644
--- a/drivers/gpu/drm/xe/Kconfig
+++ b/drivers/gpu/drm/xe/Kconfig
@@ -83,3 +83,9 @@ depends on DRM_XE
 depends on EXPERT
 source "drivers/gpu/drm/xe/Kconfig.debug"
 endmenu
+
+menu "drm/Xe Profile Guided Optimisation"
+visible if EXPERT
+depends on DRM_XE
+source "drivers/gpu/drm/xe/Kconfig.profile"
+endmenu
diff --git a/drivers/gpu/drm/xe/Kconfig.profile b/drivers/gpu/drm/xe/Kconfig.profile
new file mode 100644
index 000000000000..27be86adc6cb
--- /dev/null
+++ b/drivers/gpu/drm/xe/Kconfig.profile
@@ -0,0 +1,12 @@
+config DRM_XE_PREEMPT_TIMEOUT
+        int "Preempt timeout (ms, jiffy granularity)"
+        default 640 # milliseconds
+        help
+          How long to wait (in milliseconds) for a preemption event to occur
+          when submitting a new context. If the current context does not hit
+          an arbitration point and yield to HW before the timer expires, the
+          HW will be reset to allow the more important context to execute.
+
+          This is adjustable via XE_ENGINE_SET_PROPERTY_PREEMPTION_TIMEOUT.
+
+          May be 0 to disable the timeout.
diff --git a/drivers/gpu/drm/xe/xe_engine.c b/drivers/gpu/drm/xe/xe_engine.c
index b3036c4a8ec3..cdc4bfdaf015 100644
--- a/drivers/gpu/drm/xe/xe_engine.c
+++ b/drivers/gpu/drm/xe/xe_engine.c
@@ -21,6 +21,19 @@
 #include "xe_trace.h"
 #include "xe_vm.h"
 
+/* Default preempt timeout in us */
+#define XE_DEFAULT_PREEMPT_TIMEOUT  (640 * 1000)
+
+static inline void xe_engine_set_preempt_timeout(struct xe_engine *e)
+{
+	e->sched_props.preempt_timeout_us = XE_DEFAULT_PREEMPT_TIMEOUT;
+
+#if defined(CONFIG_DRM_XE_PREEMPT_TIMEOUT)
+	e->sched_props.preempt_timeout_us =
+		CONFIG_DRM_XE_PREEMPT_TIMEOUT * 1000;
+#endif
+}
+
 static struct xe_engine *__xe_engine_create(struct xe_device *xe,
 					    struct xe_vm *vm,
 					    u32 logical_mask,
@@ -54,7 +67,8 @@ static struct xe_engine *__xe_engine_create(struct xe_device *xe,
 
 	/* FIXME: Wire up to configurable default value */
 	e->sched_props.timeslice_us = 1 * 1000;
-	e->sched_props.preempt_timeout_us = 640 * 1000;
+
+	xe_engine_set_preempt_timeout(e);
 
 	if (xe_engine_is_parallel(e)) {
 		e->parallel.composite_fence_ctx = dma_fence_context_alloc(1);
-- 
2.21.0.rc0.32.g243a4c7e27



More information about the Intel-xe mailing list