Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/lrc: Allow INDIRECT_CTX for more engine classes

Currently it's only allowed for render and compute. Going forward we
want to enable it for more engine classes. Let the XE_LRC_FLAG_INDIRECT_CTX
flag (and thus gt_engine_needs_indirect_ctx()) be the deciding factor
for its availability.

While at it, add the missing const to rcs_funcs array. Since
CTX_INDIRECT_CTX_OFFSET_DEFAULT already matches the HW default and
gt_engine_needs_indirect_ctx() only ever enables it for rcs/ccs, there
is no change in behavior, it's only preparation for future use case.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250916-wa-bb-cmds-v5-5-306bddbc15da@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

+10 -7
-3
drivers/gpu/drm/xe/regs/xe_lrc_layout.h
··· 40 40 #define INDIRECT_CTX_RING_START_UDW (0x08 + 1) 41 41 #define INDIRECT_CTX_RING_CTL (0x0a + 1) 42 42 43 - #define CTX_INDIRECT_CTX_OFFSET_MASK REG_GENMASK(15, 6) 44 - #define CTX_INDIRECT_CTX_OFFSET_DEFAULT REG_FIELD_PREP(CTX_INDIRECT_CTX_OFFSET_MASK, 0xd) 45 - 46 43 #endif
+10 -4
drivers/gpu/drm/xe/xe_lrc.c
··· 1281 1281 static int 1282 1282 setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe) 1283 1283 { 1284 - static struct bo_setup rcs_funcs[] = { 1284 + static const struct bo_setup rcs_funcs[] = { 1285 1285 { .setup = setup_timestamp_wa }, 1286 + }; 1287 + static const struct bo_setup xcs_funcs[] = { 1286 1288 }; 1287 1289 struct bo_setup_state state = { 1288 1290 .lrc = lrc, ··· 1302 1300 hwe->class == XE_ENGINE_CLASS_COMPUTE) { 1303 1301 state.funcs = rcs_funcs; 1304 1302 state.num_funcs = ARRAY_SIZE(rcs_funcs); 1303 + } else { 1304 + state.funcs = xcs_funcs; 1305 + state.num_funcs = ARRAY_SIZE(xcs_funcs); 1305 1306 } 1306 1307 1307 1308 if (xe_gt_WARN_ON(lrc->gt, !state.funcs)) ··· 1331 1326 finish_bo(&state); 1332 1327 kfree(state.buffer); 1333 1328 1329 + /* 1330 + * Enable INDIRECT_CTX leaving INDIRECT_CTX_OFFSET at its default: it 1331 + * varies per engine class, but the default is good enough 1332 + */ 1334 1333 xe_lrc_write_ctx_reg(lrc, 1335 1334 CTX_CS_INDIRECT_CTX, 1336 1335 (xe_bo_ggtt_addr(lrc->bo) + state.offset) | 1337 1336 /* Size in CLs. */ 1338 1337 (state.written * sizeof(u32) / 64)); 1339 - xe_lrc_write_ctx_reg(lrc, 1340 - CTX_CS_INDIRECT_CTX_OFFSET, 1341 - CTX_INDIRECT_CTX_OFFSET_DEFAULT); 1342 1338 1343 1339 return 0; 1344 1340 }