Commit c9dfd66c authored by Lucas De Marchi's avatar Lucas De Marchi
Browse files

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: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250916-wa-bb-cmds-v5-5-306bddbc15da@intel.com


Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 39ac06f7
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -40,7 +40,4 @@
#define INDIRECT_CTX_RING_START_UDW	(0x08 + 1)
#define INDIRECT_CTX_RING_CTL		(0x0a + 1)

#define CTX_INDIRECT_CTX_OFFSET_MASK	REG_GENMASK(15, 6)
#define CTX_INDIRECT_CTX_OFFSET_DEFAULT	REG_FIELD_PREP(CTX_INDIRECT_CTX_OFFSET_MASK, 0xd)

#endif
+10 −4
Original line number Diff line number Diff line
@@ -1281,9 +1281,11 @@ static int setup_wa_bb(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
static int
setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
{
	static struct bo_setup rcs_funcs[] = {
	static const struct bo_setup rcs_funcs[] = {
		{ .setup = setup_timestamp_wa },
	};
	static const struct bo_setup xcs_funcs[] = {
	};
	struct bo_setup_state state = {
		.lrc = lrc,
		.hwe = hwe,
@@ -1300,6 +1302,9 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
	    hwe->class == XE_ENGINE_CLASS_COMPUTE) {
		state.funcs = rcs_funcs;
		state.num_funcs = ARRAY_SIZE(rcs_funcs);
	} else {
		state.funcs = xcs_funcs;
		state.num_funcs = ARRAY_SIZE(xcs_funcs);
	}

	if (xe_gt_WARN_ON(lrc->gt, !state.funcs))
@@ -1326,14 +1331,15 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
	finish_bo(&state);
	kfree(state.buffer);

	/*
	 * Enable INDIRECT_CTX leaving INDIRECT_CTX_OFFSET at its default: it
	 * varies per engine class, but the default is good enough
	 */
	xe_lrc_write_ctx_reg(lrc,
			     CTX_CS_INDIRECT_CTX,
			     (xe_bo_ggtt_addr(lrc->bo) + state.offset) |
			     /* Size in CLs. */
			     (state.written * sizeof(u32) / 64));
	xe_lrc_write_ctx_reg(lrc,
			     CTX_CS_INDIRECT_CTX_OFFSET,
			     CTX_INDIRECT_CTX_OFFSET_DEFAULT);

	return 0;
}