Skip to content

Commit 6a35f22

Browse files
Andi Shytitursulin
authored andcommitted
drm/i915/gt: Support aux invalidation on all engines
Perform some refactoring with the purpose of keeping in one single place all the operations around the aux table invalidation. With this refactoring add more engines where the invalidation should be performed. Fixes: 972282c ("drm/i915/gen12: Add aux table invalidate for all engines") Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com> Cc: Matt Roper <matthew.d.roper@intel.com> Cc: <stable@vger.kernel.org> # v5.8+ Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230725001950.1014671-8-andi.shyti@linux.intel.com (cherry picked from commit 76ff778) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
1 parent 0fde2f2 commit 6a35f22

File tree

3 files changed

+41
-45
lines changed

3 files changed

+41
-45
lines changed

drivers/gpu/drm/i915/gt/gen8_engine_cs.c

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,47 @@ static u32 preparser_disable(bool state)
165165
return MI_ARB_CHECK | 1 << 8 | state;
166166
}
167167

168+
static i915_reg_t gen12_get_aux_inv_reg(struct intel_engine_cs *engine)
169+
{
170+
switch (engine->id) {
171+
case RCS0:
172+
return GEN12_CCS_AUX_INV;
173+
case BCS0:
174+
return GEN12_BCS0_AUX_INV;
175+
case VCS0:
176+
return GEN12_VD0_AUX_INV;
177+
case VCS2:
178+
return GEN12_VD2_AUX_INV;
179+
case VECS0:
180+
return GEN12_VE0_AUX_INV;
181+
case CCS0:
182+
return GEN12_CCS0_AUX_INV;
183+
default:
184+
return INVALID_MMIO_REG;
185+
}
186+
}
187+
168188
static bool gen12_needs_ccs_aux_inv(struct intel_engine_cs *engine)
169189
{
190+
i915_reg_t reg = gen12_get_aux_inv_reg(engine);
191+
170192
if (IS_PONTEVECCHIO(engine->i915))
171193
return false;
172194

173195
/*
174-
* so far platforms supported by i915 having
175-
* flat ccs do not require AUX invalidation
196+
* So far platforms supported by i915 having flat ccs do not require
197+
* AUX invalidation. Check also whether the engine requires it.
176198
*/
177-
return !HAS_FLAT_CCS(engine->i915);
199+
return i915_mmio_reg_valid(reg) && !HAS_FLAT_CCS(engine->i915);
178200
}
179201

180-
u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg)
202+
u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs)
181203
{
182-
u32 gsi_offset = gt->uncore->gsi_offset;
204+
i915_reg_t inv_reg = gen12_get_aux_inv_reg(engine);
205+
u32 gsi_offset = engine->gt->uncore->gsi_offset;
206+
207+
if (!gen12_needs_ccs_aux_inv(engine))
208+
return cs;
183209

184210
*cs++ = MI_LOAD_REGISTER_IMM(1) | MI_LRI_MMIO_REMAP_EN;
185211
*cs++ = i915_mmio_reg_offset(inv_reg) + gsi_offset;
@@ -317,11 +343,7 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
317343

318344
cs = gen8_emit_pipe_control(cs, flags, LRC_PPHWSP_SCRATCH_ADDR);
319345

320-
if (gen12_needs_ccs_aux_inv(rq->engine)) {
321-
/* hsdes: 1809175790 */
322-
cs = gen12_emit_aux_table_inv(rq->engine->gt, cs,
323-
GEN12_CCS_AUX_INV);
324-
}
346+
cs = gen12_emit_aux_table_inv(engine, cs);
325347

326348
*cs++ = preparser_disable(false);
327349
intel_ring_advance(rq, cs);
@@ -332,21 +354,14 @@ int gen12_emit_flush_rcs(struct i915_request *rq, u32 mode)
332354

333355
int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
334356
{
335-
intel_engine_mask_t aux_inv = 0;
336-
u32 cmd, *cs;
357+
u32 cmd = 4;
358+
u32 *cs;
337359

338-
cmd = 4;
339360
if (mode & EMIT_INVALIDATE) {
340361
cmd += 2;
341362

342-
if (gen12_needs_ccs_aux_inv(rq->engine) &&
343-
(rq->engine->class == VIDEO_DECODE_CLASS ||
344-
rq->engine->class == VIDEO_ENHANCEMENT_CLASS)) {
345-
aux_inv = rq->engine->mask &
346-
~GENMASK(_BCS(I915_MAX_BCS - 1), BCS0);
347-
if (aux_inv)
348-
cmd += 8;
349-
}
363+
if (gen12_needs_ccs_aux_inv(rq->engine))
364+
cmd += 8;
350365
}
351366

352367
cs = intel_ring_begin(rq, cmd);
@@ -381,14 +396,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)
381396
*cs++ = 0; /* upper addr */
382397
*cs++ = 0; /* value */
383398

384-
if (aux_inv) { /* hsdes: 1809175790 */
385-
if (rq->engine->class == VIDEO_DECODE_CLASS)
386-
cs = gen12_emit_aux_table_inv(rq->engine->gt,
387-
cs, GEN12_VD0_AUX_INV);
388-
else
389-
cs = gen12_emit_aux_table_inv(rq->engine->gt,
390-
cs, GEN12_VE0_AUX_INV);
391-
}
399+
cs = gen12_emit_aux_table_inv(rq->engine, cs);
392400

393401
if (mode & EMIT_INVALIDATE)
394402
*cs++ = preparser_disable(false);

drivers/gpu/drm/i915/gt/gen8_engine_cs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "intel_gt_regs.h"
1414
#include "intel_gpu_commands.h"
1515

16+
struct intel_engine_cs;
1617
struct intel_gt;
1718
struct i915_request;
1819

@@ -46,7 +47,7 @@ u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
4647
u32 *gen11_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
4748
u32 *gen12_emit_fini_breadcrumb_rcs(struct i915_request *rq, u32 *cs);
4849

49-
u32 *gen12_emit_aux_table_inv(struct intel_gt *gt, u32 *cs, const i915_reg_t inv_reg);
50+
u32 *gen12_emit_aux_table_inv(struct intel_engine_cs *engine, u32 *cs);
5051

5152
static inline u32 *
5253
__gen8_emit_pipe_control(u32 *batch, u32 bit_group_0,

drivers/gpu/drm/i915/gt/intel_lrc.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,10 +1364,7 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
13641364
IS_DG2_G11(ce->engine->i915))
13651365
cs = gen8_emit_pipe_control(cs, PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE, 0);
13661366

1367-
/* hsdes: 1809175790 */
1368-
if (!HAS_FLAT_CCS(ce->engine->i915))
1369-
cs = gen12_emit_aux_table_inv(ce->engine->gt,
1370-
cs, GEN12_CCS_AUX_INV);
1367+
cs = gen12_emit_aux_table_inv(ce->engine, cs);
13711368

13721369
/* Wa_16014892111 */
13731370
if (IS_MTL_GRAPHICS_STEP(ce->engine->i915, M, STEP_A0, STEP_B0) ||
@@ -1392,17 +1389,7 @@ gen12_emit_indirect_ctx_xcs(const struct intel_context *ce, u32 *cs)
13921389
PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE,
13931390
0);
13941391

1395-
/* hsdes: 1809175790 */
1396-
if (!HAS_FLAT_CCS(ce->engine->i915)) {
1397-
if (ce->engine->class == VIDEO_DECODE_CLASS)
1398-
cs = gen12_emit_aux_table_inv(ce->engine->gt,
1399-
cs, GEN12_VD0_AUX_INV);
1400-
else if (ce->engine->class == VIDEO_ENHANCEMENT_CLASS)
1401-
cs = gen12_emit_aux_table_inv(ce->engine->gt,
1402-
cs, GEN12_VE0_AUX_INV);
1403-
}
1404-
1405-
return cs;
1392+
return gen12_emit_aux_table_inv(ce->engine, cs);
14061393
}
14071394

14081395
static void

0 commit comments

Comments
 (0)