Skip to contentSkip to conversation

Reinstate render / compute cache invalidation in ring ops

PATCH New Matthew Brost 2 participants 3 messages Mar 22, 2023

Subsystems (2)
lore
Share & tools
lore

Matthew Brost

author maintainer
#0 lore raw

PATCH 1/1 Reinstate render / compute cache invalidation in ring ops

Render / compute engines have additional caches (not just TLBs) that need to be invalidated each batch, reinstate these invalidations in ring ops.

v2: Rebase for CI

---
 drivers/gpu/drm/xe/xe_ring_ops.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/gpu/drm/xe/xe_ring_ops.c +30 -0
index 4441fe60cd00..918e819e7c91 100644
@@ -106,6 +106,30 @@ static int emit_flush_invalidate(u32 flag, u32 *dw, int i)
 	return i;
 }
 
+static int emit_pipe_invalidate(u32 mask_flags, u32 *dw, int i)
+{
+	u32 flags = PIPE_CONTROL_CS_STALL |
+		PIPE_CONTROL_COMMAND_CACHE_INVALIDATE |
+		PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE |
+		PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
+		PIPE_CONTROL_VF_CACHE_INVALIDATE |
+		PIPE_CONTROL_CONST_CACHE_INVALIDATE |
+		PIPE_CONTROL_STATE_CACHE_INVALIDATE |
+		PIPE_CONTROL_QW_WRITE |
+		PIPE_CONTROL_STORE_DATA_INDEX;
+
+	flags &= ~mask_flags;
+
+	dw[i++] = GFX_OP_PIPE_CONTROL(6);
+	dw[i++] = flags;
+	dw[i++] = LRC_PPHWSP_SCRATCH_ADDR;
+	dw[i++] = 0;
+	dw[i++] = 0;
+	dw[i++] = 0;
+
+	return i;
+}
+
 #define MI_STORE_QWORD_IMM_GEN8_POSTED (MI_INSTR(0x20, 3) | (1 << 21))
 
 static int emit_store_imm_ppgtt_posted(u64 addr, u64 value,
@@ -212,8 +236,14 @@ static void __emit_job_gen12_render_compute(struct xe_sched_job *job,
 	struct xe_gt *gt = job->engine->gt;
 	struct xe_device *xe = gt_to_xe(gt);
 	bool pvc = xe->info.platform == XE_PVC;
+	u32 mask_flags = 0;
 
 	dw[i++] = preparser_disable(true);
+	if (pvc)
+		mask_flags = PIPE_CONTROL_3D_ARCH_FLAGS;
+	else if (job->engine->class == XE_ENGINE_CLASS_COMPUTE)
+		mask_flags = PIPE_CONTROL_3D_ENGINE_FLAGS;
+	i = emit_pipe_invalidate(mask_flags, dw, i);
 	/* Wa_1809175790 */
 	if (!xe->info.has_flat_ccs)
 		i = emit_aux_table_inv(gt, GEN12_GFX_CCS_AUX_NV.reg, dw, i);
Signature · 1 line
2.34.1
CI Reviewed-by Matthew Auld on v1 1/1
#1 lore raw

[Intel-xe] ✓ CI.Patch_applied: success for Reinstate render / compute cache invalidation in ring ops

== Series Details ==

== Series Details ==

Series: Reinstate render / compute cache invalidation in ring ops
URL : https://patchwork.freedesktop.org/series/115474/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: === commit a2ed856be77000c19b22c859bb34e85c64e37ef9

Author:     Matthew Brost <[email protected]>
AuthorDate: Mon Mar 20 10:46:24 2023 -0700
Commit:     Matthew Brost <[email protected]>
CommitDate: Tue Mar 21 18:14:54 2023 -0700

drm/xe: Drop zero length arrays

Zero-length arrays as fake flexible arrays are deprecated and we are moving towards adopting C99 flexible-array members instead.

=== git am output follows ===
Applying: Reinstate render / compute cache invalidation in ring ops

#2 lore raw

[Intel-xe] ✗ CI.KUnit: failure for Reinstate render / compute cache invalidation in ring ops

In reply to Matthew Brost
== Series Details ==

== Series Details ==

Series: Reinstate render / compute cache invalidation in ring ops
URL : https://patchwork.freedesktop.org/series/115474/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:../drivers/gpu/drm/xe/xe_ring_ops.c: In function ‘emit_pipe_invalidate’:
../drivers/gpu/drm/xe/xe_ring_ops.c:112:3: error: ‘PIPE_CONTROL_COMMAND_CACHE_INVALIDATE’ undeclared (first use in this function); did you mean ‘PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE’?

  112 |   PIPE_CONTROL_COMMAND_CACHE_INVALIDATE |
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE
../drivers/gpu/drm/xe/xe_ring_ops.c:112:3: note: each undeclared identifier is reported only once for each function it appears in
../drivers/gpu/drm/xe/xe_ring_ops.c:113:3: error: ‘PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE’ undeclared (first use in this function); did you mean ‘PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE’?
  113 |   PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE |
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE
../drivers/gpu/drm/xe/xe_ring_ops.c:116:3: error: ‘PIPE_CONTROL_CONST_CACHE_INVALIDATE’ undeclared (first use in this function); did you mean ‘PIPE_CONTROL_VF_CACHE_INVALIDATE’?
  116 |   PIPE_CONTROL_CONST_CACHE_INVALIDATE |
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   PIPE_CONTROL_VF_CACHE_INVALIDATE
../drivers/gpu/drm/xe/xe_ring_ops.c:117:3: error: ‘PIPE_CONTROL_STATE_CACHE_INVALIDATE’ undeclared (first use in this function); did you mean ‘PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE’?
  117 |   PIPE_CONTROL_STATE_CACHE_INVALIDATE |
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE
../drivers/gpu/drm/xe/xe_ring_ops.c:119:3: error: ‘PIPE_CONTROL_STORE_DATA_INDEX’ undeclared (first use in this function)
  119 |   PIPE_CONTROL_STORE_DATA_INDEX;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

make[6]: *** [../scripts/Makefile.build:252: drivers/gpu/drm/xe/xe_ring_ops.o] Error 1 make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:504: drivers/gpu/drm/xe] Error 2 make[5]: *** Waiting for unfinished jobs....
make[4]: *** [../scripts/Makefile.build:504: drivers/gpu/drm] Error 2 make[3]: *** [../scripts/Makefile.build:504: drivers/gpu] Error 2 make[2]: *** [../scripts/Makefile.build:504: drivers] Error 2
make[1]: *** [/kernel/Makefile:2021: .] Error 2
make: *** [Makefile:242: __sub-make] Error 2

[01:35:00] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[01:35:04] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel