Skip to content

Commit 9c7d93a

Browse files
committed
drm/xe/guc: Enable the Dynamic Inhibit Context Switch optimization
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 unsatisfied 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. v2: rebase v3: switch to using guc_buf_cache instead of dedicated alloc v4: add helper to check for feature availability (Michal), don't enable if multi-lrc is possible. Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: John Harrison <John.C.Harrison@Intel.com> Cc: Julia Filipchuk <julia.filipchuk@intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: John Harrison <John.C.Harrison@Intel.com> Link: https://lore.kernel.org/r/20250625205405.1653212-4-daniele.ceraolospurio@intel.com
1 parent a7ffcea commit 9c7d93a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

drivers/gpu/drm/xe/abi/guc_klvs_abi.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,24 @@ enum {
134134
* Adds an extra dword to the XE_GUC_ACTION_NOTIFY_MEMORY_CAT_ERROR G2H
135135
* containing the type of the CAT error. On HW that does not support
136136
* reporting the CAT error type, the extra dword is set to 0xdeadbeef.
137+
*
138+
* _`GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH` : 0x4003
139+
* This KLV enables the Dynamic Inhibit Context Switch optimization, which
140+
* consists in the GuC setting the CTX_CTRL_INHIBIT_SYN_CTX_SWITCH bit to
141+
* zero in the CTX_CONTEXT_CONTROL register of LRCs that are submitted
142+
* to an oversubscribed engine. This will cause those contexts to be
143+
* switched out immediately if they hit an unsatisfied semaphore wait
144+
* (instead of waiting the full timeslice duration). The bit is instead set
145+
* to one if a single context is queued on the engine, to avoid it being
146+
* switched out if there isn't another context that can run in its place.
137147
*/
138148

139149
#define GUC_KLV_OPT_IN_FEATURE_EXT_CAT_ERR_TYPE_KEY 0x4001
140150
#define GUC_KLV_OPT_IN_FEATURE_EXT_CAT_ERR_TYPE_LEN 0u
141151

152+
#define GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_KEY 0x4003
153+
#define GUC_KLV_OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH_LEN 0u
154+
142155
/**
143156
* DOC: GuC VGT Policy KLVs
144157
*

drivers/gpu/drm/xe/xe_guc.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,32 @@ static int __guc_opt_in_features_enable(struct xe_guc *guc, u64 addr, u32 num_dw
583583
return xe_guc_ct_send_block(&guc->ct, action, ARRAY_SIZE(action));
584584
}
585585

586+
static bool supports_dynamic_ics(struct xe_guc *guc)
587+
{
588+
struct xe_device *xe = guc_to_xe(guc);
589+
struct xe_gt *gt = guc_to_gt(guc);
590+
591+
/* Dynamic ICS is available for PVC and Xe2 and newer platforms. */
592+
if (xe->info.platform != XE_PVC && GRAPHICS_VER(xe) < 20)
593+
return false;
594+
595+
/*
596+
* The feature is currently not compatible with multi-lrc, so the GuC
597+
* does not support it at all on the media engines (which are the main
598+
* users of mlrc). On the primary GT side, to avoid it being used in
599+
* conjunction with mlrc, we only enable it if we are in single CCS
600+
* mode.
601+
*/
602+
if (xe_gt_is_media_type(gt) || gt->ccs_mode > 1)
603+
return false;
604+
605+
/*
606+
* Dynamic ICS requires GuC v70.40.1, which maps to compatibility
607+
* version v1.18.4.
608+
*/
609+
return GUC_SUBMIT_VER(guc) >= MAKE_GUC_VER(1, 18, 4);
610+
}
611+
586612
#define OPT_IN_MAX_DWORDS 16
587613
int xe_guc_opt_in_features_enable(struct xe_guc *guc)
588614
{
@@ -607,6 +633,9 @@ int xe_guc_opt_in_features_enable(struct xe_guc *guc)
607633
if (GUC_SUBMIT_VER(guc) >= MAKE_GUC_VER(1, 7, 0))
608634
klvs[count++] = PREP_GUC_KLV_TAG(OPT_IN_FEATURE_EXT_CAT_ERR_TYPE);
609635

636+
if (supports_dynamic_ics(guc))
637+
klvs[count++] = PREP_GUC_KLV_TAG(OPT_IN_FEATURE_DYNAMIC_INHIBIT_CONTEXT_SWITCH);
638+
610639
if (count) {
611640
xe_assert(xe, count <= OPT_IN_MAX_DWORDS);
612641

0 commit comments

Comments
 (0)