[PATCH 3/3] drm/xe/guc: Enable the Dynamic Inhibit Context Switch optimization
Daniele Ceraolo Spurio
daniele.ceraolospurio at intel.com
Thu Feb 27 01:05:30 UTC 2025
The Dynamic Inhibit Context Switch is an optimization aimed at reducing
the amount of time the HW is stuck waiting on an unsatisfied semaphore.
When this optimization is enabled, the GuC will dynamically modify the
CTX_CTRL_INHIBIT_SYN_CTX_SWITCH in the CTX_CONTEXT_CONTROL register of
lrcs to enable immediate switching out on an usatisfied semaphore wait
when multiple contexts are competing for time on the same engine.
This feature is available on recent HW from GuC 70.40.1 onwards and it
is enabled via a per-VF feature opt-in.
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
Cc: John Harrison <John.C.Harrison at Intel.com>
Cc: Julia Filipchuk <julia.filipchuk at intel.com>
---
drivers/gpu/drm/xe/abi/guc_klvs_abi.h | 13 +++++++++++++
drivers/gpu/drm/xe/xe_guc.c | 11 +++++++++++
2 files changed, 24 insertions(+)
diff --git a/drivers/gpu/drm/xe/abi/guc_klvs_abi.h b/drivers/gpu/drm/xe/abi/guc_klvs_abi.h
index 4c2b5bfde8fe..b86a074887a6 100644
--- a/drivers/gpu/drm/xe/abi/guc_klvs_abi.h
+++ b/drivers/gpu/drm/xe/abi/guc_klvs_abi.h
@@ -134,11 +134,24 @@ enum {
* Adds an extra dword to the XE_GUC_ACTION_NOTIFY_MEMORY_CAT_ERROR G2H
* containing the type of the CAT error. On HW that does not support
* reporting the CAT error type, the extra dword is set to 0xdeadbeef.
+ *
+ * _`GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH` : 0x4003
+ * This KLV enables the Dynamic Inhibit Context Switch optimization, which
+ * consists in the GuC setting the CTX_CTRL_INHIBIT_SYN_CTX_SWITCH bit to
+ * zero in the CTX_CONTEXT_CONTROL register of LRCs that are submitted
+ * to an oversubscribed engine. This will cause those contexts to be
+ * switched out immediately if they hit an unsatisfied semaphore wait
+ * (instead of waiting the full timeslice duration). The bit is instead set
+ * to one if a single context is queued on the engine, to avoid it being
+ * switched out if there isn't another context that can run in its place.
*/
#define GUC_KLV_GUC_OPT_IN_FEATURE_EXT_CAT_ERR_TYPE_KEY 0x4001
#define GUC_KLV_GUC_OPT_IN_FEATURE_EXT_CAT_ERR_TYPE_LEN 0u
+#define GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_KEY 0x4003
+#define GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_LEN 0u
+
/**
* DOC: GuC VGT Policy KLVs
*
diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 7483aba713b7..b6704d0e1b40 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -606,6 +606,7 @@ static int __guc_opt_in_features_enable(struct xe_guc *guc, u64 addr, u32 num_dw
int xe_guc_opt_in_features_enable(struct xe_guc *guc)
{
+ struct xe_device *xe = guc_to_xe(guc);
struct xe_bo *bo = guc->opt_in_bo;
struct xe_uc_fw_version *compat = &guc->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY];
u32 remain = bo->size;
@@ -627,6 +628,16 @@ int xe_guc_opt_in_features_enable(struct xe_guc *guc)
GUC_KLV_GUC_OPT_IN_FEATURE_EXT_CAT_ERR_TYPE_KEY,
&offset, &remain);
+ /*
+ * Dynamic ICS is available for PVC and Xe2 and newer platforms. It
+ * requires GuC 70.40.1, which maps to compatibility version 1.18.4
+ */
+ if ((xe->info.platform == XE_PVC || GRAPHICS_VER(xe) >= 20) &&
+ MAKE_GUC_VER_STRUCT(*compat) >= MAKE_GUC_VER(1, 18, 4))
+ xe_guc_klv_enable_simple(guc, &bo->vmap,
+ GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_KEY,
+ &offset, &remain);
+
if (offset) {
ret = __guc_opt_in_features_enable(guc, xe_bo_ggtt_addr(bo), offset / 4);
if (ret < 0) {
--
2.43.0
More information about the Intel-xe
mailing list