drm/xe: Add CONFIG_DRM_XE_PREEMPT_TIMEOUT
authorNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Mon, 7 Aug 2023 14:58:38 +0000 (14:58 +0000)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:40:20 +0000 (11:40 -0500)
Allow preemption timeout to be specified as a config option.

v2: Change unit to microseconds (Tejas)
v3: Remove get_default_preempt_timeout()

Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/Kconfig.profile
drivers/gpu/drm/xe/xe_hw_engine.c
drivers/gpu/drm/xe/xe_hw_engine.h

index 51951c8149a175c65e570e42e756de1877b175ad..ba17a25e8db3b1f4ad0059b51cd1c9602475bd36 100644 (file)
@@ -22,6 +22,14 @@ config DRM_XE_TIMESLICE_MIN
        help
          Configures the default min timeslice duration between multiple
          contexts by guc scheduling.
+config DRM_XE_PREEMPT_TIMEOUT
+       int "Preempt timeout (us, jiffy granularity)"
+       default 640000 # microseconds
+       help
+         How long to wait (in microseconds) 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.
 config DRM_XE_PREEMPT_TIMEOUT_MAX
        int "Default max preempt timeout (us)"
        default 10000000 # microseconds
index c445406844622fa922166ad5092230fd528fdade..4c812d04e182395da0919b43ece38e548118bdb3 100644 (file)
@@ -370,7 +370,7 @@ static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe,
                hwe->eclass->sched_props.timeslice_us = 1 * 1000;
                hwe->eclass->sched_props.timeslice_min = XE_HW_ENGINE_TIMESLICE_MIN;
                hwe->eclass->sched_props.timeslice_max = XE_HW_ENGINE_TIMESLICE_MAX;
-               hwe->eclass->sched_props.preempt_timeout_us = 640 * 1000;
+               hwe->eclass->sched_props.preempt_timeout_us = XE_HW_ENGINE_PREEMPT_TIMEOUT;
                hwe->eclass->sched_props.preempt_timeout_min = XE_HW_ENGINE_PREEMPT_TIMEOUT_MIN;
                hwe->eclass->sched_props.preempt_timeout_max = XE_HW_ENGINE_PREEMPT_TIMEOUT_MAX;
                /* Record default props */
@@ -562,6 +562,9 @@ int xe_hw_engines_init_early(struct xe_gt *gt)
        read_copy_fuses(gt);
        read_compute_fuses(gt);
 
+       BUILD_BUG_ON(XE_HW_ENGINE_PREEMPT_TIMEOUT < XE_HW_ENGINE_PREEMPT_TIMEOUT_MIN);
+       BUILD_BUG_ON(XE_HW_ENGINE_PREEMPT_TIMEOUT > XE_HW_ENGINE_PREEMPT_TIMEOUT_MAX);
+
        for (i = 0; i < ARRAY_SIZE(gt->hw_engines); i++)
                hw_engine_init_early(gt, &gt->hw_engines[i], i);
 
index 3d37d6d44261d7c474387e0339fffa75ca3299c4..71968ee2f600d2d917c780ccaa7d59411cb73ebb 100644 (file)
@@ -30,6 +30,11 @@ struct drm_printer;
 #else
 #define XE_HW_ENGINE_TIMESLICE_MAX (10 * 1000 * 1000)
 #endif
+#ifdef CONFIG_DRM_XE_PREEMPT_TIMEOUT
+#define XE_HW_ENGINE_PREEMPT_TIMEOUT CONFIG_DRM_XE_PREEMPT_TIMEOUT
+#else
+#define XE_HW_ENGINE_PREEMPT_TIMEOUT (640 * 1000)
+#endif
 #ifdef CONFIG_DRM_XE_PREEMPT_TIMEOUT_MIN
 #define XE_HW_ENGINE_PREEMPT_TIMEOUT_MIN CONFIG_DRM_XE_PREEMPT_TIMEOUT_MIN
 #else