Skip to contentSkip to conversation

Adapt copy commands for Xe2

PATCH Superseded Lucas De Marchi 3 participants 20 messages Oct 4, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Adapt copy commands for Xe2

A few copy commands changed for Xe2, mainly adding or moving the bits used for MOCS. This adapts the places we are manually adding the commands in the batch buffer, the gpu_cmds and the intel_blt libraries.

Missing here is the conversion of lib/intel_batchbuffer.c. I had understood that intel_batchbuffer would end up using the new intel_blt. So, it may just be that we have some patches being cooked for that. Or I understood it wrong. Anyway, it doesn't seem good that we have basically 3 ways to do the same thing.

Also it seems that this is the first time we are updating intel_blt for a platform with a breaking change. I used 2 different approaches in how to adapt the struct: one for xy-block-copy/xy-fast-copy and another for ctrl-surf-copy. The reason is that for the former there was just a minor change and the latter basically rewrites all the dwords. Going forward I think we should keep applying small deltas to at most 1 or 2 breaking changes, otherwise it makes it harder to read.

v2: Provide fixes according to the feedback in v1

Lucas De Marchi (13):
lib/rendercopy: Use common mocs function lib/gpu_cmds: Remove prefix from gen7_fill_binding_table() lib/gpu_cmds: Reorder if/else ladder according to IP version lib/gpu_cmds: Fork a gen9_fill_surface_state() lib/gpu_cmds: Reduce scope of xehp_fill_surface_state()
lib: Fork gen9_media.h
lib/intel_mocs: Stop encoding mocs
lib/intel_mocs: Add Xe2 mocs indexes
lib/igt_draw: Add Xe2 mocs to XY_FAST_COLOR_BLT lib/intel_mocs: Remove unused lefotver defines lib/intel_blt: Support Xe2 in xy-block-copy command lib/intel_blt: Support xe2 in xy-fast-copy command lib/intel_blt: Support xe2 in ctrl-surf-copy command

 docs/reference/igt-gpu-tools/meson.build |   1 +
 lib/gen8_media.h                         |  14 -
 lib/gen9_media.h                         | 144 +++++++++
 lib/gen9_render.h                        |   3 +-
 lib/gpu_cmds.c                           | 100 +++++--
 lib/gpu_cmds.h                           |   7 +-
 lib/igt_draw.c                           |   8 +-
 lib/igt_fb.c                             |   2 +-
 lib/intel_blt.c                          | 357 +++++++++++++++++------
 lib/intel_blt.h                          |  10 +-
 lib/intel_compute.c                      |   1 +
 lib/intel_mocs.c                         |  23 +-
 lib/intel_mocs.h                         |   4 +-
 lib/intel_reg.h                          |   4 +-
 lib/media_fill.c                         |   1 +
 lib/rendercopy_gen9.c                    |  41 +--
 lib/xehp_media.h                         |   3 +-
 tests/intel/gem_ccs.c                    |   8 +-
 tests/intel/gem_lmem_swapping.c          |   4 +-
 tests/intel/xe_ccs.c                     |   6 +-
 20 files changed, 538 insertions(+), 203 deletions(-)
 create mode 100644 lib/gen9_media.h
Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/13 lib/rendercopy: Use common mocs function

Do not duplicate what is done by lib/intel_mocs.[ch], just reuse it.

---
 lib/rendercopy_gen9.c | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)
lib/rendercopy_gen9.c +1 -28
index db67b5ee3..b8959d073 100644
@@ -19,6 +19,7 @@
 #include "intel_bufops.h"
 #include "intel_batchbuffer.h"
 #include "intel_io.h"
+#include "intel_mocs.h"
 #include "rendercopy.h"
 #include "gen9_render.h"
 #include "intel_reg.h"
@@ -135,34 +136,6 @@ static const uint32_t gen12p71_render_copy[][4] = {
 	{ 0x80041131, 0x00000004, 0x50007144, 0x00c40000 },
 };
 
-/*
- * Gen >= 12 onwards don't have a setting for PTE,
- * so using I915_MOCS_PTE as mocs index may lead to
- * some undefined MOCS behavior.
- * Correct MOCS index should be referred from BSpec
- * and programmed accordingly.
- * This helper function is providing appropriate UC index.
- */
-static uint8_t
-intel_get_uc_mocs(int fd) {
-
-	uint16_t devid = intel_get_drm_devid(fd);
-	uint8_t  uc_index;
-
-	if (IS_DG1(devid))
-		uc_index = 1;
-	else if (IS_GEN12(devid))
-		uc_index = 3;
-	else
-		uc_index = I915_MOCS_PTE;
-
-	/*
-	 * BitField [6:1] represents index to MOCS Tables
-	 * BitField [0] represents Encryption/Decryption
-	 */
-	return uc_index << 1;
-}
-
 /* Mostly copy+paste from gen6, except height, width, pitch moved */
 static uint32_t
 gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
Signature · 1 line
2.40.1
#2 lore raw

PATCH v2 2/13 lib/gpu_cmds: Remove prefix from gen7_fill_binding_table()

In reply to Lucas De Marchi

This function is used by pretty much all versions. It's odd to have a gen7 function end up calling next-gen functions and it's error prone:
when adding something to e.g. a gen8 function to realize that behavior breaks previous platforms.

---
 lib/gpu_cmds.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
lib/gpu_cmds.c +4 -5
index bb35204fb..648451f74 100644
@@ -259,8 +259,7 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 }
 
 static uint32_t
-gen7_fill_binding_table(struct intel_bb *ibb,
-			struct intel_buf *buf)
+fill_binding_table(struct intel_bb *ibb, struct intel_buf *buf)
 {
 	uint32_t binding_table_offset;
 	uint32_t *binding_table;
@@ -321,7 +320,7 @@ gen7_fill_interface_descriptor(struct intel_bb *ibb,
 	uint32_t offset;
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen7_fill_binding_table(ibb, buf);
+	binding_table_offset = fill_binding_table(ibb, buf);
 	kernel_offset = gen7_fill_kernel(ibb, kernel, size);
 
 	intel_bb_ptr_align(ibb, 64);
@@ -357,7 +356,7 @@ gen8_fill_interface_descriptor(struct intel_bb *ibb,
 	uint32_t offset;
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen7_fill_binding_table(ibb, buf);
+	binding_table_offset = fill_binding_table(ibb, buf);
 	kernel_offset = gen7_fill_kernel(ibb, kernel, size);
 
 	intel_bb_ptr_align(ibb, 64);
@@ -803,7 +802,7 @@ xehp_fill_interface_descriptor(struct intel_bb *ibb,
 {
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen7_fill_binding_table(ibb, dst);
+	binding_table_offset = fill_binding_table(ibb, dst);
 	kernel_offset = gen7_fill_kernel(ibb, kernel, size);
 
 	memset(idd, 0, sizeof(*idd));
Signature · 1 line
2.40.1
Reviewed-by on v2 2/13
#3 lore raw

Re: [igt-dev] [Intel-xe] [PATCH i-g-t v2 02/13] lib/gpu_cmds: Remove prefix from gen7_fill_binding_table()

Quoted 6 lines · Lucas De Marchi

This function is used by pretty much all versions. It's odd to have a gen7 function end up calling next-gen functions and it's error prone:
when adding something to e.g. a gen8 function to realize that behavior breaks previous platforms.

Quoted 49 lines
---
 lib/gpu_cmds.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
lib/gpu_cmds.c +4 -5
index bb35204fb..648451f74 100644
@@ -259,8 +259,7 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 }
 
 static uint32_t
-gen7_fill_binding_table(struct intel_bb *ibb,
-			struct intel_buf *buf)
+fill_binding_table(struct intel_bb *ibb, struct intel_buf *buf)
 {
 	uint32_t binding_table_offset;
 	uint32_t *binding_table;
@@ -321,7 +320,7 @@ gen7_fill_interface_descriptor(struct intel_bb *ibb,
 	uint32_t offset;
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen7_fill_binding_table(ibb, buf);
+	binding_table_offset = fill_binding_table(ibb, buf);
 	kernel_offset = gen7_fill_kernel(ibb, kernel, size);
 
 	intel_bb_ptr_align(ibb, 64);
@@ -357,7 +356,7 @@ gen8_fill_interface_descriptor(struct intel_bb *ibb,
 	uint32_t offset;
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen7_fill_binding_table(ibb, buf);
+	binding_table_offset = fill_binding_table(ibb, buf);
 	kernel_offset = gen7_fill_kernel(ibb, kernel, size);
 
 	intel_bb_ptr_align(ibb, 64);
@@ -803,7 +802,7 @@ xehp_fill_interface_descriptor(struct intel_bb *ibb,
 {
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen7_fill_binding_table(ibb, dst);
+	binding_table_offset = fill_binding_table(ibb, dst);
 	kernel_offset = gen7_fill_kernel(ibb, kernel, size);
 
 	memset(idd, 0, sizeof(*idd));
Signature · 1 line
2.40.1
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#4 lore raw

PATCH v2 3/13 lib/gpu_cmds: Reorder if/else ladder according to IP version

In reply to Lucas De Marchi

Make it easier to follow the flow by following the convention of "latest platform earlier".

---
 lib/gpu_cmds.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
lib/gpu_cmds.c +5 -7
index 648451f74..0fd8f8213 100644
@@ -270,17 +270,15 @@ fill_binding_table(struct intel_bb *ibb, struct intel_buf *buf)
 	binding_table = intel_bb_ptr(ibb);
 	intel_bb_ptr_add(ibb, 64);
 
-	if (IS_GEN7(devid))
-		binding_table[0] = gen7_fill_surface_state(ibb, buf,
-							   SURFACEFORMAT_R8_UNORM, 1);
-
-	else if (intel_graphics_ver(devid) >= IP_VER(12, 50))
+	if (intel_graphics_ver(devid) >= IP_VER(12, 50))
 		binding_table[0] = xehp_fill_surface_state(ibb, buf,
 							   SURFACEFORMAT_R8_UNORM, 1);
-
-	else
+	else if (intel_graphics_ver(devid) >= IP_VER(8, 0))
 		binding_table[0] = gen8_fill_surface_state(ibb, buf,
 							   SURFACEFORMAT_R8_UNORM, 1);
+	else
+		binding_table[0] = gen7_fill_surface_state(ibb, buf,
+							   SURFACEFORMAT_R8_UNORM, 1);
 
 	return binding_table_offset;
 }
Signature · 1 line
2.40.1
#5 lore raw

PATCH v2 4/13 lib/gpu_cmds: Fork a gen9_fill_surface_state()

In reply to Lucas De Marchi

Commit 02c2cf17628b ("lib/[gpu_cmds|intel_bufops]: Enable surface state mocs setting.") added support for setting the mocs field in the surface state. However it's not until gen9 that MOCS uses a table, programmed by the kernel, and only has an index set in the surface state. Previously it was the specific caching behavior.

As such, it makes no sense to set this field to I915_MOCS_PTE << 1: it will only add garbage to the batch buffer. Solve this by forking a separate function for gen9 and above, keeping the old behavior for previous platforms.

Bspec: 12483, 12239, 12236

---
 lib/gpu_cmds.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
lib/gpu_cmds.c +55 -0
index 0fd8f8213..83d2302f9 100644
@@ -136,6 +136,58 @@ gen8_fill_surface_state(struct intel_bb *ibb,
 	struct gen8_surface_state *ss;
 	uint32_t write_domain, read_domain, offset;
 	uint64_t address;
+
+	if (is_dst) {
+		write_domain = read_domain = I915_GEM_DOMAIN_RENDER;
+	} else {
+		write_domain = 0;
+		read_domain = I915_GEM_DOMAIN_SAMPLER;
+	}
+
+	intel_bb_ptr_align(ibb, 64);
+	offset = intel_bb_offset(ibb);
+	ss = intel_bb_ptr(ibb);
+	intel_bb_ptr_add(ibb, 64);
+
+	ss->ss0.surface_type = SURFACE_2D;
+	ss->ss0.surface_format = format;
+	ss->ss0.render_cache_read_write = 1;
+	ss->ss0.vertical_alignment = 1; /* align 4 */
+	ss->ss0.horizontal_alignment = 1; /* align 4 */
+
+	if (buf->tiling == I915_TILING_X)
+		ss->ss0.tiled_mode = 2;
+	else if (buf->tiling == I915_TILING_Y || buf->tiling == I915_TILING_4)
+		ss->ss0.tiled_mode = 3;
+
+	address = intel_bb_offset_reloc(ibb, buf->handle,
+					read_domain, write_domain,
+					offset + 4 * 8, buf->addr.offset);
+
+	ss->ss8.base_addr = (uint32_t) address;
+	ss->ss9.base_addr_hi = address >> 32;
+
+	ss->ss2.height = intel_buf_height(buf) - 1;
+	ss->ss2.width  = intel_buf_width(buf) - 1;
+	ss->ss3.pitch  = buf->surface[0].stride - 1;
+
+	ss->ss7.shader_chanel_select_r = 4;
+	ss->ss7.shader_chanel_select_g = 5;
+	ss->ss7.shader_chanel_select_b = 6;
+	ss->ss7.shader_chanel_select_a = 7;
+
+	return offset;
+}
+
+static uint32_t
+gen9_fill_surface_state(struct intel_bb *ibb,
+			struct intel_buf *buf,
+			uint32_t format,
+			int is_dst)
+{
+	struct gen8_surface_state *ss;
+	uint32_t write_domain, read_domain, offset;
+	uint64_t address;
 	enum intel_buf_mocs mocs = intel_buf_get_mocs(buf);
 
 	if (is_dst) {
@@ -273,6 +325,9 @@ fill_binding_table(struct intel_bb *ibb, struct intel_buf *buf)
 	if (intel_graphics_ver(devid) >= IP_VER(12, 50))
 		binding_table[0] = xehp_fill_surface_state(ibb, buf,
 							   SURFACEFORMAT_R8_UNORM, 1);
+	else if (intel_graphics_ver(devid) >= IP_VER(9, 0))
+		binding_table[0] = gen9_fill_surface_state(ibb, buf,
+							   SURFACEFORMAT_R8_UNORM, 1);
 	else if (intel_graphics_ver(devid) >= IP_VER(8, 0))
 		binding_table[0] = gen8_fill_surface_state(ibb, buf,
 							   SURFACEFORMAT_R8_UNORM, 1);
Signature · 1 line
2.40.1
#6 lore raw

PATCH v2 5/13 lib/gpu_cmds: Reduce scope of xehp_fill_surface_state()

In reply to Lucas De Marchi

gpu_cmds.h is the interface to other igt components: don't use it to declare functions not supposed to be used from outside.

---
 lib/gpu_cmds.c | 8 +++++++-
 lib/gpu_cmds.h | 6 ------
 2 files changed, 7 insertions(+), 7 deletions(-)
lib/gpu_cmds.c +7 -1
index 83d2302f9..e53580e65 100644
@@ -25,6 +25,12 @@
 #include "gpu_cmds.h"
 #include "intel_mocs.h"
 
+static uint32_t
+xehp_fill_surface_state(struct intel_bb *ibb,
+			struct intel_buf *buf,
+			uint32_t format,
+			int is_dst);
+
 uint32_t
 gen7_fill_curbe_buffer_data(struct intel_bb *ibb, uint8_t color)
 {
@@ -873,7 +879,7 @@ xehp_fill_interface_descriptor(struct intel_bb *ibb,
 	idd->desc5.num_threads_in_tg = 1;
 }
 
-uint32_t
+static uint32_t
 xehp_fill_surface_state(struct intel_bb *ibb,
 			struct intel_buf *buf,
 			uint32_t format,
lib/gpu_cmds.h +0 -6
index b7ed64f84..5ac007cc4 100644
@@ -116,12 +116,6 @@ xehp_fill_interface_descriptor(struct intel_bb *ibb,
 			       size_t size,
 			       struct xehp_interface_descriptor_data *idd);
 
-uint32_t
-xehp_fill_surface_state(struct intel_bb *ibb,
-			struct intel_buf *buf,
-			uint32_t format,
-			int is_dst);
-
 void
 xehp_emit_state_compute_mode(struct intel_bb *ibb);
 
Signature · 1 line
2.40.1
#7 lore raw

PATCH v2 6/13 lib: Fork gen9_media.h

In reply to Lucas De Marchi

Fork gen9_media.h from gen8_media.h with the gen9 definitions that were in that header and with a new struct gen9_surface_state. Although the surface state is the same as for gen8, the meaning of at least mocs is different. As a follow up the mocs definition will change for gen9 and above.

---
 docs/reference/igt-gpu-tools/meson.build |   1 +
 lib/gen8_media.h                         |  14 ---
 lib/gen9_media.h                         | 143 +++++++++++++++++++++++
 lib/gpu_cmds.c                           |   4 +-
 lib/gpu_cmds.h                           |   1 +
 lib/intel_compute.c                      |   1 +
 lib/media_fill.c                         |   1 +
 7 files changed, 149 insertions(+), 16 deletions(-)
 create mode 100644 lib/gen9_media.h
docs/reference/igt-gpu-tools/meson.build +1 -0
index 513385b4b..d5db95e40 100644
@@ -6,6 +6,7 @@ ignore_headers = [
 	'gen7_render.h',
 	'gen8_media.h',
 	'gen8_render.h',
+	'gen9_media.h',
 	'gpgpu_fill.h',
 	'i830_reg.h',
 	'i915_3d.h',
lib/gen8_media.h +0 -14
index 07ea2ac03..c1807629e 100644
@@ -207,18 +207,4 @@ struct gen8_surface_state
 	} ss15;
 };
 
-
-#define GEN9_PIPELINE_SELECTION_MASK		(3 << 8)
-
-/*  If enabled, it will force awake media enginee and the following instructions
- *  will require that the media enginee is awake.
- */
-#define GEN9_FORCE_MEDIA_AWAKE_DISABLE		(0 << 5)
-#define GEN9_FORCE_MEDIA_AWAKE_ENABLE		(1 << 5)
-#define GEN9_FORCE_MEDIA_AWAKE_MASK		(1 << 13)
-
-#define GEN9_SAMPLER_DOP_GATE_DISABLE		(0 << 4)
-#define GEN9_SAMPLER_DOP_GATE_ENABLE		(1 << 4)
-#define GEN9_SAMPLER_DOP_GATE_MASK		(1 << 12)
-
 #endif /* GEN8_MEDIA_H */
lib/gen9_media.h new file +143 -0

143 lines not on this page · raw message

lib/gpu_cmds.c +2 -2
index e53580e65..61b18d20d 100644
@@ -191,7 +191,7 @@ gen9_fill_surface_state(struct intel_bb *ibb,
 			uint32_t format,
 			int is_dst)
 {
-	struct gen8_surface_state *ss;
+	struct gen9_surface_state *ss;
 	uint32_t write_domain, read_domain, offset;
 	uint64_t address;
 	enum intel_buf_mocs mocs = intel_buf_get_mocs(buf);
@@ -252,7 +252,7 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 			 uint32_t horizontal_alignment,
 			 int is_dst)
 {
-	struct gen8_surface_state *ss;
+	struct gen9_surface_state *ss;
 	uint32_t write_domain, read_domain, offset;
 	uint64_t address;
 	enum intel_buf_mocs mocs = intel_buf_get_mocs(buf);
lib/gpu_cmds.h +1 -0
index 5ac007cc4..348c6c945 100644
@@ -30,6 +30,7 @@
 #include "media_fill.h"
 #include "gen7_media.h"
 #include "gen8_media.h"
+#include "gen9_media.h"
 #include "xehp_media.h"
 #include "intel_reg.h"
 #include "drmtest.h"
lib/intel_compute.c +1 -0
index 0c30f39c1..9109df540 100644
@@ -12,6 +12,7 @@
 #include "igt.h"
 #include "gen7_media.h"
 #include "gen8_media.h"
+#include "gen9_media.h"
 #include "intel_compute.h"
 #include "lib/igt_syncobj.h"
 #include "lib/intel_reg.h"
lib/media_fill.c +1 -0
index 2520995d9..88d83061a 100644
@@ -27,6 +27,7 @@
 #include "media_fill.h"
 #include "gen7_media.h"
 #include "gen8_media.h"
+#include "gen9_media.h"
 #include "intel_reg.h"
 #include "drmtest.h"
 #include "gpu_cmds.h"
Signature · 1 line
2.40.1
#8 lore raw

PATCH v2 7/13 lib/intel_mocs: Stop encoding mocs

In reply to Lucas De Marchi

From gen9 until xe2, the various gpu commands use a mocs object that is defined as

	[0]   pxp
	[6:1] mocs index

However this is not true for xe2 anymore. Also the way it is coded right now it's very easy to double shift the mocs value and end up with the wrong setting. Avoid this by separating where the index should be used (intel_mocs.[ch]) and the encoding on the various commands. To help with clarity the following renames were done:

	intel_get_wb_mocs() -> intel_get_wb_mocs_index()
	intel_get_uc_mocs() -> intel_get_uc_mocs_index()
	gen9_surface_state.*.memory_object_control
		 -> gen9_surface_state.*.mocs_index
	mocs -> mocs_index in lib/intel_blt.*

v2:
- Use I915_MOCS_PTE instead of the hardcoded 1 in the gen11 media function (Matt Roper)
- Fix a wrong shift by XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT, result of a copy and paste mistake from lib/igt_draw.c to lib/igt_fb.c (Matt Roper)
- In addition to the conversions in intel_blt, also add a _index suffix to avoid confusion

---
 lib/gen9_media.h                |  3 +-
 lib/gen9_render.h               |  3 +-
 lib/gpu_cmds.c                  | 14 ++++-----
 lib/igt_draw.c                  |  4 ++-
 lib/igt_fb.c                    |  2 +-
 lib/intel_blt.c                 | 52 ++++++++++++++++++---------------
 lib/intel_blt.h                 | 10 +++----
 lib/intel_mocs.c                | 14 ++++-----
 lib/intel_mocs.h                |  4 +--
 lib/intel_reg.h                 |  3 +-
 lib/rendercopy_gen9.c           | 12 ++++----
 lib/xehp_media.h                |  3 +-
 tests/intel/gem_ccs.c           |  8 ++---
 tests/intel/gem_lmem_swapping.c |  4 +--
 tests/intel/xe_ccs.c            |  6 ++--
 15 files changed, 75 insertions(+), 67 deletions(-)
lib/gen9_media.h +2 -1
index 414001dfd..a422cf7fe 100644
@@ -45,7 +45,8 @@ struct gen9_surface_state
 		uint32_t qpitch:15;
 		uint32_t pad1:4;
 		uint32_t base_mip_level:5;
-		uint32_t memory_object_control:7;
+		uint32_t pxp:1;
+		uint32_t mocs_index:6;
 		uint32_t pad0:1;
 	} ss1;
 
lib/gen9_render.h +2 -1
index af3a2b3af..8ed60a2a5 100644
@@ -42,7 +42,8 @@ struct gen9_surface_state {
 		uint32_t qpitch:15;
 		uint32_t pad1:4;
 		uint32_t base_mip_level:5;
-		uint32_t memory_object_control:7;
+		uint32_t pxp:1;
+		uint32_t mocs_index:6;
 		uint32_t pad0:1;
 	} ss1;
 
lib/gpu_cmds.c +7 -7
index 61b18d20d..f19f93b28 100644
@@ -215,9 +215,9 @@ gen9_fill_surface_state(struct intel_bb *ibb,
 	ss->ss0.horizontal_alignment = 1; /* align 4 */
 
 	if (mocs == INTEL_BUF_MOCS_UC)
-		ss->ss1.memory_object_control = intel_get_uc_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(ibb->fd);
 	else if (mocs == INTEL_BUF_MOCS_WB)
-		ss->ss1.memory_object_control = intel_get_wb_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_wb_mocs_index(ibb->fd);
 
 	if (buf->tiling == I915_TILING_X)
 		ss->ss0.tiled_mode = 2;
@@ -276,9 +276,9 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 	ss->ss0.horizontal_alignment = horizontal_alignment; /* align 4 */
 
 	if (mocs == INTEL_BUF_MOCS_UC)
-		ss->ss1.memory_object_control = intel_get_uc_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(ibb->fd);
 	else if (mocs == INTEL_BUF_MOCS_WB)
-		ss->ss1.memory_object_control = intel_get_wb_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_wb_mocs_index(ibb->fd);
 
 	if (buf->tiling == I915_TILING_X)
 		ss->ss0.tiled_mode = 2;
@@ -295,7 +295,7 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 	ss->ss9.base_addr_hi = address >> 32;
 
 	if (is_dst) {
-		ss->ss1.memory_object_control = 2;
+		ss->ss1.mocs_index = I915_MOCS_PTE;
 		ss->ss2.height = 1;
 		ss->ss2.width  = 95;
 		ss->ss3.pitch  = 0;
@@ -909,9 +909,9 @@ xehp_fill_surface_state(struct intel_bb *ibb,
 	ss->ss0.horizontal_alignment = 1; /* align 4 */
 
 	if (mocs == INTEL_BUF_MOCS_UC)
-		ss->ss1.memory_object_control = intel_get_uc_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(ibb->fd);
 	else if (mocs == INTEL_BUF_MOCS_WB)
-		ss->ss1.memory_object_control = intel_get_wb_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_wb_mocs_index(ibb->fd);
 
 	if (buf->tiling == I915_TILING_X)
 		ss->ss0.tiled_mode = 2;
lib/igt_draw.c +3 -1
index 476778a13..d7c3ac64c 100644
@@ -676,6 +676,7 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
 	uint32_t devid = intel_get_drm_devid(fd);
 	int ver = intel_display_ver(devid);
 	int pitch;
+	uint32_t mocs;
 
 	dst = create_buf(fd, cmd_data->bops, buf, tiling);
 	ibb = intel_bb_create(fd, PAGE_SIZE);
@@ -715,9 +716,10 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
 		}
 
 		pitch = tiling ? buf->stride / 4 : buf->stride;
+		mocs = intel_get_uc_mocs_index(fd) << XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT;
 
 		intel_bb_out(ibb, XY_FAST_COLOR_BLT | blt_cmd_depth);
-		intel_bb_out(ibb, blt_cmd_tiling | intel_get_uc_mocs(fd) << 21 | (pitch-1));
+		intel_bb_out(ibb, blt_cmd_tiling | mocs | (pitch-1));
 		intel_bb_out(ibb, (rect->y << 16) | rect->x);
 		intel_bb_out(ibb, ((rect->y + rect->h) << 16) | (rect->x + rect->w));
 		intel_bb_emit_reloc_fenced(ibb, dst->handle, 0,
lib/igt_fb.c +1 -1
index f0c0681ab..dc8994902 100644
@@ -2766,7 +2766,7 @@ static struct blt_copy_object *blt_fb_init(const struct igt_fb *fb,
 	stride = blt_tile == T_LINEAR ? fb->strides[plane] : fb->strides[plane] / 4;
 
 	blt_set_object(blt, handle, fb->size, memregion,
-		       intel_get_uc_mocs(fb->fd),
+		       intel_get_uc_mocs_index(fb->fd),
 		       blt_tile,
 		       is_ccs_modifier(fb->modifier) ? COMPRESSION_ENABLED : COMPRESSION_DISABLED,
 		       is_gen12_mc_ccs_modifier(fb->modifier) ? COMPRESSION_TYPE_MEDIA : COMPRESSION_TYPE_3D);
lib/intel_blt.c +28 -24

161 lines not on this page · raw message

lib/intel_blt.h +5 -5
index d9c8883c7..7b4271620 100644
@@ -78,7 +78,7 @@ struct blt_copy_object {
 	uint32_t handle;
 	uint32_t region;
 	uint64_t size;
-	uint8_t mocs;
+	uint8_t mocs_index;
 	enum blt_tiling_type tiling;
 	enum blt_compression compression;  /* BC only */
 	enum blt_compression_type compression_type; /* BC only */
@@ -150,7 +150,7 @@ struct blt_ctrl_surf_copy_object {
 	uint32_t handle;
 	uint32_t region;
 	uint64_t size;
-	uint8_t mocs;
+	uint8_t mocs_index;
 	enum blt_access_type access_type;
 };
 
@@ -239,7 +239,7 @@ void blt_set_batch(struct blt_copy_batch *batch,
 
 struct blt_copy_object *
 blt_create_object(const struct blt_copy_data *blt, uint32_t region,
-		  uint32_t width, uint32_t height, uint32_t bpp, uint8_t mocs,
+		  uint32_t width, uint32_t height, uint32_t bpp, uint8_t mocs_index,
 		  enum blt_tiling_type tiling,
 		  enum blt_compression compression,
 		  enum blt_compression_type compression_type,
@@ -247,7 +247,7 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
 void blt_destroy_object(int fd, struct blt_copy_object *obj);
 void blt_set_object(struct blt_copy_object *obj,
 		    uint32_t handle, uint64_t size, uint32_t region,
-		    uint8_t mocs, enum blt_tiling_type tiling,
+		    uint8_t mocs_index, enum blt_tiling_type tiling,
 		    enum blt_compression compression,
 		    enum blt_compression_type compression_type);
 void blt_set_object_ext(struct blt_block_copy_object_ext *obj,
@@ -258,7 +258,7 @@ void blt_set_copy_object(struct blt_copy_object *obj,
 			 const struct blt_copy_object *orig);
 void blt_set_ctrl_surf_object(struct blt_ctrl_surf_copy_object *obj,
 			      uint32_t handle, uint32_t region, uint64_t size,
-			      uint8_t mocs, enum blt_access_type access_type);
+			      uint8_t mocs_index, enum blt_access_type access_type);
 
 void blt_surface_info(const char *info,
 		      const struct blt_copy_object *obj);
lib/intel_mocs.c +6 -8
index cf3b8e4fe..6a4ec25e4 100644
@@ -51,22 +51,20 @@ static void get_mocs_index(int fd, struct drm_intel_mocs_index *mocs)
 	}
 }
 
-/* BitField [6:1] represents index to MOCS Tables
- * BitField [0] represents Encryption/Decryption
- */
-
-uint8_t intel_get_wb_mocs(int fd)
+uint8_t intel_get_wb_mocs_index(int fd)
 {
 	struct drm_intel_mocs_index mocs;
 
 	get_mocs_index(fd, &mocs);
-	return mocs.wb_index << 1;
+
+	return mocs.wb_index;
 }
 
-uint8_t intel_get_uc_mocs(int fd)
+uint8_t intel_get_uc_mocs_index(int fd)
 {
 	struct drm_intel_mocs_index mocs;
 
 	get_mocs_index(fd, &mocs);
-	return mocs.uc_index << 1;
+
+	return mocs.uc_index;
 }
lib/intel_mocs.h +2 -2
index 255eac0ff..278f143ec 100644
@@ -6,7 +6,7 @@
 #ifndef _INTEL_MOCS_H
 #define _INTEL_MOCS_H
 
-uint8_t intel_get_wb_mocs(int fd);
-uint8_t intel_get_uc_mocs(int fd);
+uint8_t intel_get_wb_mocs_index(int fd);
+uint8_t intel_get_uc_mocs_index(int fd);
 
 #endif /* _INTEL_MOCS_H */
lib/intel_reg.h +2 -1
index 3bf3676dc..f97154d2b 100644
@@ -2562,7 +2562,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define XY_MONO_SRC_BLT_WRITE_ALPHA	(1<<21)
 #define XY_MONO_SRC_BLT_WRITE_RGB	(1<<20)
 
-#define XY_FAST_COLOR_BLT		((0x2<<29)|(0x44<<22)|0xe)
+#define XY_FAST_COLOR_BLT				((0x2<<29)|(0x44<<22)|0xe)
+#define   XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT		22
 
 #define XY_FAST_COPY_BLT				((2<<29)|(0x42<<22)|0x8)
 /* dword 0 */
lib/rendercopy_gen9.c +6 -6
index b8959d073..6c410e8a8 100644
@@ -138,7 +138,7 @@ static const uint32_t gen12p71_render_copy[][4] = {
 
 /* Mostly copy+paste from gen6, except height, width, pitch moved */
 static uint32_t
-gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
+gen9_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
 	      bool fast_clear) {
 	struct gen9_surface_state *ss;
 	uint32_t write_domain, read_domain;
@@ -173,11 +173,11 @@ gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
 		/*
 		 * mocs table version 1 index 3 groub wb use l3
 		 */
-		ss->ss1.memory_object_control = 3 << 1;
+		ss->ss1.mocs_index= 3;
 		ss->ss5.mip_tail_start_lod = 0;
 	} else {
 		ss->ss0.render_cache_read_write = 1;
-		ss->ss1.memory_object_control = intel_get_uc_mocs(i915);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(i915);
 		ss->ss5.mip_tail_start_lod = 1; /* needed with trmode */
 	}
 
@@ -187,7 +187,7 @@ gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
 		ss->ss0.tiled_mode = 3;
 
 	if (intel_buf_pxp(buf))
-		ss->ss1.memory_object_control |= 1;
+		ss->ss1.pxp = 1;
 
 	if (buf->tiling == I915_TILING_Yf)
 		ss->ss5.trmode = 1;
@@ -282,10 +282,10 @@ gen8_bind_surfaces(struct intel_bb *ibb,
 	binding_table = intel_bb_ptr_align(ibb, 32);
 	binding_table_offset = intel_bb_ptr_add_return_prev_offset(ibb, 32);
 
-	binding_table[0] = gen8_bind_buf(ibb, dst, 1, fast_clear);
+	binding_table[0] = gen9_bind_buf(ibb, dst, 1, fast_clear);
 
 	if (src != NULL)
-		binding_table[1] = gen8_bind_buf(ibb, src, 0, false);
+		binding_table[1] = gen9_bind_buf(ibb, src, 0, false);
 
 	return binding_table_offset;
 }
lib/xehp_media.h +2 -1
index 65a72d950..087eb2ec0 100644
@@ -109,7 +109,8 @@ struct xehp_surface_state {
 		uint32_t double_fetch_disable: BITRANGE(17, 17);
 		uint32_t corner_texel_mode: BITRANGE(18, 18);
 		uint32_t base_mip_level: BITRANGE(19, 23);
-		uint32_t memory_object_control: BITRANGE(24, 30);
+		uint32_t pad1: BITRANGE(24, 24);
+		uint32_t mocs_index: BITRANGE(25, 30);
 		uint32_t unorm_path_in_color_pipe: BITRANGE(31, 31);
 	} ss1;
 
tests/intel/gem_ccs.c +4 -4
index f5d4ab359..ed149ef9e 100644
@@ -100,7 +100,7 @@ static void surf_copy(int i915,
 	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
 	uint64_t bb_size, ccssize = mid->size / CCS_RATIO;
 	uint32_t *ccscopy;
-	uint8_t uc_mocs = intel_get_uc_mocs(i915);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(i915);
 	int result;
 
 	igt_assert(mid->compression);
@@ -323,7 +323,7 @@ static void block_copy(int i915,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(i915);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(i915);
 	int result;
 
 	igt_assert(__gem_create_in_memory_regions(i915, &bb, &bb_size, region1) == 0);
@@ -439,7 +439,7 @@ static void block_multicopy(int i915,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(i915);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(i915);
 	int result;
 
 	igt_assert(__gem_create_in_memory_regions(i915, &bb, &bb_size, region1) == 0);
@@ -475,7 +475,7 @@ static void block_multicopy(int i915,
 
 	if (config->inplace) {
 		blt_set_object(&blt3.dst, mid->handle, dst->size, mid->region,
-			       mid->mocs, mid_tiling, COMPRESSION_DISABLED,
+			       mid->mocs_index, mid_tiling, COMPRESSION_DISABLED,
 			       comp_type);
 		blt3.dst.ptr = mid->ptr;
 	}
tests/intel/gem_lmem_swapping.c +2 -2
index ede545c92..2e0ba0793 100644
@@ -486,7 +486,7 @@ static void __do_evict(int i915,
 				   INTEL_MEMORY_REGION_ID(I915_SYSTEM_MEMORY, 0));
 		blt_set_object(tmp, tmp->handle, params->size.max,
 			       INTEL_MEMORY_REGION_ID(I915_SYSTEM_MEMORY, 0),
-			       intel_get_uc_mocs(i915), T_LINEAR,
+			       intel_get_uc_mocs_index(i915), T_LINEAR,
 			       COMPRESSION_DISABLED, COMPRESSION_TYPE_3D);
 		blt_set_geom(tmp, stride, 0, 0, width, height, 0, 0);
 	}
@@ -516,7 +516,7 @@ static void __do_evict(int i915,
 			obj->blt_obj = calloc(1, sizeof(*obj->blt_obj));
 			igt_assert(obj->blt_obj);
 			blt_set_object(obj->blt_obj, obj->handle, obj->size, region_id,
-				       intel_get_uc_mocs(i915), T_LINEAR,
+				       intel_get_uc_mocs_index(i915), T_LINEAR,
 				       COMPRESSION_ENABLED, COMPRESSION_TYPE_3D);
 			blt_set_geom(obj->blt_obj, stride, 0, 0, width, height, 0, 0);
 			init_object_ccs(i915, obj, tmp, rand(), blt_ctx,
tests/intel/xe_ccs.c +3 -3
index 20bbc4448..27ac51380 100644
@@ -96,7 +96,7 @@ static void surf_copy(int xe,
 	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
 	uint64_t bb_size, ccssize = mid->size / CCS_RATIO;
 	uint32_t *ccscopy;
-	uint8_t uc_mocs = intel_get_uc_mocs(xe);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(xe);
 	uint32_t sysmem = system_memory(xe);
 	int result;
 
@@ -294,7 +294,7 @@ static void block_copy(int xe,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(xe);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(xe);
 	int result;
 
 	bb = xe_bo_create_flags(xe, 0, bb_size, region1);
@@ -415,7 +415,7 @@ static void block_multicopy(int xe,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(xe);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(xe);
 	int result;
 
 	bb = xe_bo_create_flags(xe, 0, bb_size, region1);
Signature · 1 line
2.40.1
Reviewed-by on v2 7/13
#9 lore raw

Re: [igt-dev] [Intel-xe] [PATCH i-g-t v2 07/13] lib/intel_mocs: Stop encoding mocs

Quoted 464 lines · Lucas De Marchi

From gen9 until xe2, the various gpu commands use a mocs object that is defined as

	[0]   pxp
	[6:1] mocs index

However this is not true for xe2 anymore. Also the way it is coded right now it's very easy to double shift the mocs value and end up with the wrong setting. Avoid this by separating where the index should be used (intel_mocs.[ch]) and the encoding on the various commands. To help with clarity the following renames were done:

	intel_get_wb_mocs() -> intel_get_wb_mocs_index()
	intel_get_uc_mocs() -> intel_get_uc_mocs_index()
	gen9_surface_state.*.memory_object_control
		 -> gen9_surface_state.*.mocs_index
	mocs -> mocs_index in lib/intel_blt.*

v2:
- Use I915_MOCS_PTE instead of the hardcoded 1 in the gen11 media function (Matt Roper)
- Fix a wrong shift by XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT, result of a copy and paste mistake from lib/igt_draw.c to lib/igt_fb.c (Matt Roper)
- In addition to the conversions in intel_blt, also add a _index suffix to avoid confusion

---
 lib/gen9_media.h                |  3 +-
 lib/gen9_render.h               |  3 +-
 lib/gpu_cmds.c                  | 14 ++++-----
 lib/igt_draw.c                  |  4 ++-
 lib/igt_fb.c                    |  2 +-
 lib/intel_blt.c                 | 52 ++++++++++++++++++---------------
 lib/intel_blt.h                 | 10 +++----
 lib/intel_mocs.c                | 14 ++++-----
 lib/intel_mocs.h                |  4 +--
 lib/intel_reg.h                 |  3 +-
 lib/rendercopy_gen9.c           | 12 ++++----
 lib/xehp_media.h                |  3 +-
 tests/intel/gem_ccs.c           |  8 ++---
 tests/intel/gem_lmem_swapping.c |  4 +--
 tests/intel/xe_ccs.c            |  6 ++--
 15 files changed, 75 insertions(+), 67 deletions(-)
lib/gen9_media.h +2 -1
index 414001dfd..a422cf7fe 100644
@@ -45,7 +45,8 @@ struct gen9_surface_state
 		uint32_t qpitch:15;
 		uint32_t pad1:4;
 		uint32_t base_mip_level:5;
-		uint32_t memory_object_control:7;
+		uint32_t pxp:1;
+		uint32_t mocs_index:6;
 		uint32_t pad0:1;
 	} ss1;
 
lib/gen9_render.h +2 -1
index af3a2b3af..8ed60a2a5 100644
@@ -42,7 +42,8 @@ struct gen9_surface_state {
 		uint32_t qpitch:15;
 		uint32_t pad1:4;
 		uint32_t base_mip_level:5;
-		uint32_t memory_object_control:7;
+		uint32_t pxp:1;
+		uint32_t mocs_index:6;
 		uint32_t pad0:1;
 	} ss1;
 
lib/gpu_cmds.c +7 -7
index 61b18d20d..f19f93b28 100644
@@ -215,9 +215,9 @@ gen9_fill_surface_state(struct intel_bb *ibb,
 	ss->ss0.horizontal_alignment = 1; /* align 4 */
 
 	if (mocs == INTEL_BUF_MOCS_UC)
-		ss->ss1.memory_object_control = intel_get_uc_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(ibb->fd);
 	else if (mocs == INTEL_BUF_MOCS_WB)
-		ss->ss1.memory_object_control = intel_get_wb_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_wb_mocs_index(ibb->fd);
 
 	if (buf->tiling == I915_TILING_X)
 		ss->ss0.tiled_mode = 2;
@@ -276,9 +276,9 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 	ss->ss0.horizontal_alignment = horizontal_alignment; /* align 4 */
 
 	if (mocs == INTEL_BUF_MOCS_UC)
-		ss->ss1.memory_object_control = intel_get_uc_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(ibb->fd);
 	else if (mocs == INTEL_BUF_MOCS_WB)
-		ss->ss1.memory_object_control = intel_get_wb_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_wb_mocs_index(ibb->fd);
 
 	if (buf->tiling == I915_TILING_X)
 		ss->ss0.tiled_mode = 2;
@@ -295,7 +295,7 @@ gen11_fill_surface_state(struct intel_bb *ibb,
 	ss->ss9.base_addr_hi = address >> 32;
 
 	if (is_dst) {
-		ss->ss1.memory_object_control = 2;
+		ss->ss1.mocs_index = I915_MOCS_PTE;
 		ss->ss2.height = 1;
 		ss->ss2.width  = 95;
 		ss->ss3.pitch  = 0;
@@ -909,9 +909,9 @@ xehp_fill_surface_state(struct intel_bb *ibb,
 	ss->ss0.horizontal_alignment = 1; /* align 4 */
 
 	if (mocs == INTEL_BUF_MOCS_UC)
-		ss->ss1.memory_object_control = intel_get_uc_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(ibb->fd);
 	else if (mocs == INTEL_BUF_MOCS_WB)
-		ss->ss1.memory_object_control = intel_get_wb_mocs(ibb->fd);
+		ss->ss1.mocs_index = intel_get_wb_mocs_index(ibb->fd);
 
 	if (buf->tiling == I915_TILING_X)
 		ss->ss0.tiled_mode = 2;
lib/igt_draw.c +3 -1
index 476778a13..d7c3ac64c 100644
@@ -676,6 +676,7 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
 	uint32_t devid = intel_get_drm_devid(fd);
 	int ver = intel_display_ver(devid);
 	int pitch;
+	uint32_t mocs;
 
 	dst = create_buf(fd, cmd_data->bops, buf, tiling);
 	ibb = intel_bb_create(fd, PAGE_SIZE);
@@ -715,9 +716,10 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
 		}
 
 		pitch = tiling ? buf->stride / 4 : buf->stride;
+		mocs = intel_get_uc_mocs_index(fd) << XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT;
 
 		intel_bb_out(ibb, XY_FAST_COLOR_BLT | blt_cmd_depth);
-		intel_bb_out(ibb, blt_cmd_tiling | intel_get_uc_mocs(fd) << 21 | (pitch-1));
+		intel_bb_out(ibb, blt_cmd_tiling | mocs | (pitch-1));
 		intel_bb_out(ibb, (rect->y << 16) | rect->x);
 		intel_bb_out(ibb, ((rect->y + rect->h) << 16) | (rect->x + rect->w));
 		intel_bb_emit_reloc_fenced(ibb, dst->handle, 0,
lib/igt_fb.c +1 -1
index f0c0681ab..dc8994902 100644
@@ -2766,7 +2766,7 @@ static struct blt_copy_object *blt_fb_init(const struct igt_fb *fb,
 	stride = blt_tile == T_LINEAR ? fb->strides[plane] : fb->strides[plane] / 4;
 
 	blt_set_object(blt, handle, fb->size, memregion,
-		       intel_get_uc_mocs(fb->fd),
+		       intel_get_uc_mocs_index(fb->fd),
 		       blt_tile,
 		       is_ccs_modifier(fb->modifier) ? COMPRESSION_ENABLED : COMPRESSION_DISABLED,
 		       is_gen12_mc_ccs_modifier(fb->modifier) ? COMPRESSION_TYPE_MEDIA : COMPRESSION_TYPE_3D);
lib/intel_blt.c +28 -24
index b55fa9b52..d1aa0872c 100644
@@ -58,7 +58,8 @@ struct gen12_block_copy_data {
 	struct {
 		uint32_t dst_pitch:			BITRANGE(0, 17);
 		uint32_t dst_aux_mode:			BITRANGE(18, 20);
-		uint32_t dst_mocs:			BITRANGE(21, 27);
+		uint32_t pxp:				BITRANGE(21, 21);
+		uint32_t dst_mocs_index:		BITRANGE(22, 27);
 		uint32_t dst_ctrl_surface_type:		BITRANGE(28, 28);
 		uint32_t dst_compression:		BITRANGE(29, 29);
 		uint32_t dst_tiling:			BITRANGE(30, 31);
@@ -98,7 +99,8 @@ struct gen12_block_copy_data {
 	struct {
 		uint32_t src_pitch:			BITRANGE(0, 17);
 		uint32_t src_aux_mode:			BITRANGE(18, 20);
-		uint32_t src_mocs:			BITRANGE(21, 27);
+		uint32_t pxp:				BITRANGE(21, 21);
+		uint32_t src_mocs_index:		BITRANGE(22, 27);
 		uint32_t src_ctrl_surface_type:		BITRANGE(28, 28);
 		uint32_t src_compression:		BITRANGE(29, 29);
 		uint32_t src_tiling:			BITRANGE(30, 31);
@@ -565,7 +567,7 @@ static void fill_data(struct gen12_block_copy_data *data,
 		data->dw01.dst_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->dst);
 	data->dw01.dst_pitch = blt->dst.pitch - 1;
 
-	data->dw01.dst_mocs = blt->dst.mocs;
+	data->dw01.dst_mocs_index = blt->dst.mocs_index;
 	data->dw01.dst_compression = blt->dst.compression;
 	data->dw01.dst_tiling = __block_tiling(blt->dst.tiling);
 
@@ -590,7 +592,7 @@ static void fill_data(struct gen12_block_copy_data *data,
 
 	data->dw08.src_pitch = blt->src.pitch - 1;
 	data->dw08.src_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->src);
-	data->dw08.src_mocs = blt->src.mocs;
+	data->dw08.src_mocs_index = blt->src.mocs_index;
 	data->dw08.src_compression = blt->src.compression;
 	data->dw08.src_tiling = __block_tiling(blt->src.tiling);
 
@@ -660,10 +662,10 @@ static void dump_bb_cmd(struct gen12_block_copy_data *data)
 		 cmd[0],
 		 data->dw00.client, data->dw00.opcode, data->dw00.color_depth,
 		 data->dw00.special_mode, data->dw00.length);
-	igt_info(" dw01: [%08x] dst <pitch: %d, aux: %d, mocs: %d, compr: %d, "
+	igt_info(" dw01: [%08x] dst <pitch: %d, aux: %d, mocs_idx: %d, compr: %d, "
 		 "tiling: %d, ctrl surf type: %d>\n",
 		 cmd[1], data->dw01.dst_pitch, data->dw01.dst_aux_mode,
-		 data->dw01.dst_mocs, data->dw01.dst_compression,
+		 data->dw01.dst_mocs_index, data->dw01.dst_compression,
 		 data->dw01.dst_tiling, data->dw01.dst_ctrl_surface_type);
 	igt_info(" dw02: [%08x] dst geom <x1: %d, y1: %d>\n",
 		 cmd[2], data->dw02.dst_x1, data->dw02.dst_y1);
@@ -678,10 +680,10 @@ static void dump_bb_cmd(struct gen12_block_copy_data *data)
 		 data->dw06.dst_target_memory);
 	igt_info(" dw07: [%08x] src geom <x1: %d, y1: %d>\n",
 		 cmd[7], data->dw07.src_x1, data->dw07.src_y1);
-	igt_info(" dw08: [%08x] src <pitch: %d, aux: %d, mocs: %d, compr: %d, "
+	igt_info(" dw08: [%08x] src <pitch: %d, aux: %d, mocs_idx: %d, compr: %d, "
 		 "tiling: %d, ctrl surf type: %d>\n",
 		 cmd[8], data->dw08.src_pitch, data->dw08.src_aux_mode,
-		 data->dw08.src_mocs, data->dw08.src_compression,
+		 data->dw08.src_mocs_index, data->dw08.src_compression,
 		 data->dw08.src_tiling, data->dw08.src_ctrl_surface_type);
 	igt_info(" dw09: [%08x] src offset lo (0x%x)\n",
 		 cmd[9], data->dw09.src_address_lo);
@@ -946,7 +948,8 @@ struct gen12_ctrl_surf_copy_data {
 
 	struct {
 		uint32_t src_address_hi:		BITRANGE(0, 24);
-		uint32_t src_mocs:			BITRANGE(25, 31);
+		uint32_t pxp:				BITRANGE(25, 25);
+		uint32_t src_mocs_index:		BITRANGE(26, 31);
 	} dw02;
 
 	struct {
@@ -955,7 +958,8 @@ struct gen12_ctrl_surf_copy_data {
 
 	struct {
 		uint32_t dst_address_hi:		BITRANGE(0, 24);
-		uint32_t dst_mocs:			BITRANGE(25, 31);
+		uint32_t pxp:				BITRANGE(25, 25);
+		uint32_t dst_mocs_index:		BITRANGE(26, 31);
 	} dw04;
 };
 
@@ -972,12 +976,12 @@ static void dump_bb_surf_ctrl_cmd(const struct gen12_ctrl_surf_copy_data *data)
 		 data->dw00.size_of_ctrl_copy, data->dw00.length);
 	igt_info(" dw01: [%08x] src offset lo (0x%x)\n",
 		 cmd[1], data->dw01.src_address_lo);
-	igt_info(" dw02: [%08x] src offset hi (0x%x), src mocs: %u\n",
-		 cmd[2], data->dw02.src_address_hi, data->dw02.src_mocs);
+	igt_info(" dw02: [%08x] src offset hi (0x%x), src mocs idx: %u\n",
+		 cmd[2], data->dw02.src_address_hi, data->dw02.src_mocs_index);
 	igt_info(" dw03: [%08x] dst offset lo (0x%x)\n",
 		 cmd[3], data->dw03.dst_address_lo);
-	igt_info(" dw04: [%08x] dst offset hi (0x%x), src mocs: %u\n",
-		 cmd[4], data->dw04.dst_address_hi, data->dw04.dst_mocs);
+	igt_info(" dw04: [%08x] dst offset hi (0x%x), dst mocs idx: %u\n",
+		 cmd[4], data->dw04.dst_address_hi, data->dw04.dst_mocs_index);
 }
 
 /**
@@ -1042,11 +1046,11 @@ uint64_t emit_blt_ctrl_surf_copy(int fd,
 
 	data.dw01.src_address_lo = src_offset;
 	data.dw02.src_address_hi = src_offset >> 32;
-	data.dw02.src_mocs = surf->src.mocs;
+	data.dw02.src_mocs_index = surf->src.mocs_index;
 
 	data.dw03.dst_address_lo = dst_offset;
 	data.dw04.dst_address_hi = dst_offset >> 32;
-	data.dw04.dst_mocs = surf->dst.mocs;
+	data.dw04.dst_mocs_index = surf->dst.mocs_index;
 
 	bb = bo_map(fd, surf->bb.handle, surf->bb.size, surf->driver);
 
@@ -1435,7 +1439,7 @@ void blt_set_batch(struct blt_copy_batch *batch,
 
 struct blt_copy_object *
 blt_create_object(const struct blt_copy_data *blt, uint32_t region,
-		  uint32_t width, uint32_t height, uint32_t bpp, uint8_t mocs,
+		  uint32_t width, uint32_t height, uint32_t bpp, uint8_t mocs_index,
 		  enum blt_tiling_type tiling,
 		  enum blt_compression compression,
 		  enum blt_compression_type compression_type,
@@ -1460,7 +1464,7 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
 							  &size, region) == 0);
 	}
 
-	blt_set_object(obj, handle, size, region, mocs, tiling,
+	blt_set_object(obj, handle, size, region, mocs_index, tiling,
 		       compression, compression_type);
 	blt_set_geom(obj, stride, 0, 0, width, height, 0, 0);
 
@@ -1481,14 +1485,14 @@ void blt_destroy_object(int fd, struct blt_copy_object *obj)
 
 void blt_set_object(struct blt_copy_object *obj,
 		    uint32_t handle, uint64_t size, uint32_t region,
-		    uint8_t mocs, enum blt_tiling_type tiling,
+		    uint8_t mocs_index, enum blt_tiling_type tiling,
 		    enum blt_compression compression,
 		    enum blt_compression_type compression_type)
 {
 	obj->handle = handle;
 	obj->size = size;
 	obj->region = region;
-	obj->mocs = mocs;
+	obj->mocs_index = mocs_index;
 	obj->tiling = tiling;
 	obj->compression = compression;
 	obj->compression_type = compression_type;
@@ -1516,12 +1520,12 @@ void blt_set_copy_object(struct blt_copy_object *obj,
 
 void blt_set_ctrl_surf_object(struct blt_ctrl_surf_copy_object *obj,
 			      uint32_t handle, uint32_t region, uint64_t size,
-			      uint8_t mocs, enum blt_access_type access_type)
+			      uint8_t mocs_index, enum blt_access_type access_type)
 {
 	obj->handle = handle;
 	obj->region = region;
 	obj->size = size;
-	obj->mocs = mocs;
+	obj->mocs_index = mocs_index;
 	obj->access_type = access_type;
 }
 
@@ -1589,8 +1593,8 @@ void blt_surface_fill_rect(int fd, const struct blt_copy_object *obj,
 void blt_surface_info(const char *info, const struct blt_copy_object *obj)
 {
 	igt_info("[%s]\n", info);
-	igt_info("surface <handle: %u, size: %llx, region: %x, mocs: %x>\n",
-		 obj->handle, (long long) obj->size, obj->region, obj->mocs);
+	igt_info("surface <handle: %u, size: %llx, region: %x, mocs_idx: %x>\n",
+		 obj->handle, (long long) obj->size, obj->region, obj->mocs_index);
 	igt_info("        <tiling: %s, compression: %u, compression type: %d>\n",
 		 blt_tiling_name(obj->tiling), obj->compression, obj->compression_type);
 	igt_info("        <pitch: %u, offset [x: %u, y: %u] geom [<%d,%d> <%d,%d>]>\n",
lib/intel_blt.h +5 -5
index d9c8883c7..7b4271620 100644
@@ -78,7 +78,7 @@ struct blt_copy_object {
 	uint32_t handle;
 	uint32_t region;
 	uint64_t size;
-	uint8_t mocs;
+	uint8_t mocs_index;
 	enum blt_tiling_type tiling;
 	enum blt_compression compression;  /* BC only */
 	enum blt_compression_type compression_type; /* BC only */
@@ -150,7 +150,7 @@ struct blt_ctrl_surf_copy_object {
 	uint32_t handle;
 	uint32_t region;
 	uint64_t size;
-	uint8_t mocs;
+	uint8_t mocs_index;
 	enum blt_access_type access_type;
 };
 
@@ -239,7 +239,7 @@ void blt_set_batch(struct blt_copy_batch *batch,
 
 struct blt_copy_object *
 blt_create_object(const struct blt_copy_data *blt, uint32_t region,
-		  uint32_t width, uint32_t height, uint32_t bpp, uint8_t mocs,
+		  uint32_t width, uint32_t height, uint32_t bpp, uint8_t mocs_index,
 		  enum blt_tiling_type tiling,
 		  enum blt_compression compression,
 		  enum blt_compression_type compression_type,
@@ -247,7 +247,7 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
 void blt_destroy_object(int fd, struct blt_copy_object *obj);
 void blt_set_object(struct blt_copy_object *obj,
 		    uint32_t handle, uint64_t size, uint32_t region,
-		    uint8_t mocs, enum blt_tiling_type tiling,
+		    uint8_t mocs_index, enum blt_tiling_type tiling,
 		    enum blt_compression compression,
 		    enum blt_compression_type compression_type);
 void blt_set_object_ext(struct blt_block_copy_object_ext *obj,
@@ -258,7 +258,7 @@ void blt_set_copy_object(struct blt_copy_object *obj,
 			 const struct blt_copy_object *orig);
 void blt_set_ctrl_surf_object(struct blt_ctrl_surf_copy_object *obj,
 			      uint32_t handle, uint32_t region, uint64_t size,
-			      uint8_t mocs, enum blt_access_type access_type);
+			      uint8_t mocs_index, enum blt_access_type access_type);
 
 void blt_surface_info(const char *info,
 		      const struct blt_copy_object *obj);
lib/intel_mocs.c +6 -8
index cf3b8e4fe..6a4ec25e4 100644
@@ -51,22 +51,20 @@ static void get_mocs_index(int fd, struct drm_intel_mocs_index *mocs)
 	}
 }
 
-/* BitField [6:1] represents index to MOCS Tables
- * BitField [0] represents Encryption/Decryption
- */
-
-uint8_t intel_get_wb_mocs(int fd)
+uint8_t intel_get_wb_mocs_index(int fd)
 {
 	struct drm_intel_mocs_index mocs;
 
 	get_mocs_index(fd, &mocs);
-	return mocs.wb_index << 1;
+
+	return mocs.wb_index;
 }
 
-uint8_t intel_get_uc_mocs(int fd)
+uint8_t intel_get_uc_mocs_index(int fd)
 {
 	struct drm_intel_mocs_index mocs;
 
 	get_mocs_index(fd, &mocs);
-	return mocs.uc_index << 1;
+
+	return mocs.uc_index;
 }
lib/intel_mocs.h +2 -2
index 255eac0ff..278f143ec 100644
@@ -6,7 +6,7 @@
 #ifndef _INTEL_MOCS_H
 #define _INTEL_MOCS_H
 
-uint8_t intel_get_wb_mocs(int fd);
-uint8_t intel_get_uc_mocs(int fd);
+uint8_t intel_get_wb_mocs_index(int fd);
+uint8_t intel_get_uc_mocs_index(int fd);
 
 #endif /* _INTEL_MOCS_H */
lib/intel_reg.h +2 -1
index 3bf3676dc..f97154d2b 100644
@@ -2562,7 +2562,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define XY_MONO_SRC_BLT_WRITE_ALPHA	(1<<21)
 #define XY_MONO_SRC_BLT_WRITE_RGB	(1<<20)
 
-#define XY_FAST_COLOR_BLT		((0x2<<29)|(0x44<<22)|0xe)
+#define XY_FAST_COLOR_BLT				((0x2<<29)|(0x44<<22)|0xe)
+#define   XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT		22
 
 #define XY_FAST_COPY_BLT				((2<<29)|(0x42<<22)|0x8)
 /* dword 0 */
lib/rendercopy_gen9.c +1 -1
index b8959d073..6c410e8a8 100644
@@ -138,7 +138,7 @@ static const uint32_t gen12p71_render_copy[][4] = {
 
 /* Mostly copy+paste from gen6, except height, width, pitch moved */
 static uint32_t
-gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
+gen9_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
 	      bool fast_clear) {
 	struct gen9_surface_state *ss;
 	uint32_t write_domain, read_domain;

lib/rendercopy_gen9.c gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst, · line 176

Quoted 5 lines
lib/rendercopy_gen9.c +1 -1
@@ -173,11 +173,11 @@ gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
 		/*
 		 * mocs table version 1 index 3 groub wb use l3
 		 */
-		ss->ss1.memory_object_control = 3 << 1;
+		ss->ss1.mocs_index= 3;

Nitpick: missing a space here.

Quoted 35 lines
lib/rendercopy_gen9.c +4 -4
 		ss->ss5.mip_tail_start_lod = 0;
 	} else {
 		ss->ss0.render_cache_read_write = 1;
-		ss->ss1.memory_object_control = intel_get_uc_mocs(i915);
+		ss->ss1.mocs_index = intel_get_uc_mocs_index(i915);
 		ss->ss5.mip_tail_start_lod = 1; /* needed with trmode */
 	}
 
@@ -187,7 +187,7 @@ gen8_bind_buf(struct intel_bb *ibb, const struct intel_buf *buf, int is_dst,
 		ss->ss0.tiled_mode = 3;
 
 	if (intel_buf_pxp(buf))
-		ss->ss1.memory_object_control |= 1;
+		ss->ss1.pxp = 1;
 
 	if (buf->tiling == I915_TILING_Yf)
 		ss->ss5.trmode = 1;
@@ -282,10 +282,10 @@ gen8_bind_surfaces(struct intel_bb *ibb,
 	binding_table = intel_bb_ptr_align(ibb, 32);
 	binding_table_offset = intel_bb_ptr_add_return_prev_offset(ibb, 32);
 
-	binding_table[0] = gen8_bind_buf(ibb, dst, 1, fast_clear);
+	binding_table[0] = gen9_bind_buf(ibb, dst, 1, fast_clear);
 
 	if (src != NULL)
-		binding_table[1] = gen8_bind_buf(ibb, src, 0, false);
+		binding_table[1] = gen9_bind_buf(ibb, src, 0, false);
 
 	return binding_table_offset;
 }
lib/xehp_media.h +0 -0
index 65a72d950..087eb2ec0 100644

lib/xehp_media.h struct xehp_surface_state { · line 112

Quoted 5 lines
lib/xehp_media.h +1 -1
@@ -109,7 +109,8 @@ struct xehp_surface_state {
 		uint32_t double_fetch_disable: BITRANGE(17, 17);
 		uint32_t corner_texel_mode: BITRANGE(18, 18);
 		uint32_t base_mip_level: BITRANGE(19, 23);
-		uint32_t memory_object_control: BITRANGE(24, 30);
+		uint32_t pad1: BITRANGE(24, 24);

Should we name this one 'pxp' to match what we've done in the other structures?

Aside from these two minor nitpicks,

Quoted 101 lines
lib/xehp_media.h +1 -0
+		uint32_t mocs_index: BITRANGE(25, 30);
 		uint32_t unorm_path_in_color_pipe: BITRANGE(31, 31);
 	} ss1;
 
tests/intel/gem_ccs.c +4 -4
index f5d4ab359..ed149ef9e 100644
@@ -100,7 +100,7 @@ static void surf_copy(int i915,
 	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
 	uint64_t bb_size, ccssize = mid->size / CCS_RATIO;
 	uint32_t *ccscopy;
-	uint8_t uc_mocs = intel_get_uc_mocs(i915);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(i915);
 	int result;
 
 	igt_assert(mid->compression);
@@ -323,7 +323,7 @@ static void block_copy(int i915,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(i915);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(i915);
 	int result;
 
 	igt_assert(__gem_create_in_memory_regions(i915, &bb, &bb_size, region1) == 0);
@@ -439,7 +439,7 @@ static void block_multicopy(int i915,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(i915);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(i915);
 	int result;
 
 	igt_assert(__gem_create_in_memory_regions(i915, &bb, &bb_size, region1) == 0);
@@ -475,7 +475,7 @@ static void block_multicopy(int i915,
 
 	if (config->inplace) {
 		blt_set_object(&blt3.dst, mid->handle, dst->size, mid->region,
-			       mid->mocs, mid_tiling, COMPRESSION_DISABLED,
+			       mid->mocs_index, mid_tiling, COMPRESSION_DISABLED,
 			       comp_type);
 		blt3.dst.ptr = mid->ptr;
 	}
tests/intel/gem_lmem_swapping.c +2 -2
index ede545c92..2e0ba0793 100644
@@ -486,7 +486,7 @@ static void __do_evict(int i915,
 				   INTEL_MEMORY_REGION_ID(I915_SYSTEM_MEMORY, 0));
 		blt_set_object(tmp, tmp->handle, params->size.max,
 			       INTEL_MEMORY_REGION_ID(I915_SYSTEM_MEMORY, 0),
-			       intel_get_uc_mocs(i915), T_LINEAR,
+			       intel_get_uc_mocs_index(i915), T_LINEAR,
 			       COMPRESSION_DISABLED, COMPRESSION_TYPE_3D);
 		blt_set_geom(tmp, stride, 0, 0, width, height, 0, 0);
 	}
@@ -516,7 +516,7 @@ static void __do_evict(int i915,
 			obj->blt_obj = calloc(1, sizeof(*obj->blt_obj));
 			igt_assert(obj->blt_obj);
 			blt_set_object(obj->blt_obj, obj->handle, obj->size, region_id,
-				       intel_get_uc_mocs(i915), T_LINEAR,
+				       intel_get_uc_mocs_index(i915), T_LINEAR,
 				       COMPRESSION_ENABLED, COMPRESSION_TYPE_3D);
 			blt_set_geom(obj->blt_obj, stride, 0, 0, width, height, 0, 0);
 			init_object_ccs(i915, obj, tmp, rand(), blt_ctx,
tests/intel/xe_ccs.c +3 -3
index 20bbc4448..27ac51380 100644
@@ -96,7 +96,7 @@ static void surf_copy(int xe,
 	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
 	uint64_t bb_size, ccssize = mid->size / CCS_RATIO;
 	uint32_t *ccscopy;
-	uint8_t uc_mocs = intel_get_uc_mocs(xe);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(xe);
 	uint32_t sysmem = system_memory(xe);
 	int result;
 
@@ -294,7 +294,7 @@ static void block_copy(int xe,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(xe);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(xe);
 	int result;
 
 	bb = xe_bo_create_flags(xe, 0, bb_size, region1);
@@ -415,7 +415,7 @@ static void block_multicopy(int xe,
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
-	uint8_t uc_mocs = intel_get_uc_mocs(xe);
+	uint8_t uc_mocs = intel_get_uc_mocs_index(xe);
 	int result;
 
 	bb = xe_bo_create_flags(xe, 0, bb_size, region1);
Signature · 1 line
2.40.1
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#10 lore raw

PATCH v2 8/13 lib/intel_mocs: Add Xe2 mocs indexes

In reply to Lucas De Marchi

Add WB and UC mocs indexes for Xe2 architecture and later.

---
 lib/intel_mocs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/intel_mocs.c +6 -1
index 6a4ec25e4..d9de16932 100644
@@ -14,6 +14,8 @@
 #define MTL_MOCS_WB_IDX				10
 #define GEN12_MOCS_UC_IDX			3
 #define GEN12_MOCS_WB_IDX			2
+#define XE2_MOCS_UC_IDX				3
+#define XE2_MOCS_WB_IDX				1
 #define XY_BLOCK_COPY_BLT_MOCS_SHIFT		21
 #define XY_CTRL_SURF_COPY_BLT_MOCS_SHIFT	25
 
@@ -33,7 +35,10 @@ static void get_mocs_index(int fd, struct drm_intel_mocs_index *mocs)
 	 * This helper function is providing current UC as well
 	 * as WB MOCS index based on platform.
 	 */
-	if (IS_METEORLAKE(devid)) {
+	if (intel_graphics_ver(devid) >= IP_VER(20, 0)) {
+		mocs->uc_index = XE2_MOCS_UC_IDX;
+		mocs->wb_index = XE2_MOCS_WB_IDX;
+	} else if (IS_METEORLAKE(devid)) {
 		mocs->uc_index = MTL_MOCS_UC_IDX;
 		mocs->wb_index = MTL_MOCS_WB_IDX;
 	} else if (IS_DG2(devid)) {
Signature · 1 line
2.40.1
#11 lore raw

Re: [igt-dev] [Intel-xe] [PATCH i-g-t v2 08/13] lib/intel_mocs: Add Xe2 mocs indexes

Quoted 12 lines · Lucas De Marchi

Add WB and UC mocs indexes for Xe2 architecture and later.

---
 lib/intel_mocs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/intel_mocs.c +0 -0
index 6a4ec25e4..d9de16932 100644

lib/intel_mocs.c line 18

Quoted 5 lines
lib/intel_mocs.c +2 -0
@@ -14,6 +14,8 @@
 #define MTL_MOCS_WB_IDX				10
 #define GEN12_MOCS_UC_IDX			3
 #define GEN12_MOCS_WB_IDX			2
+#define XE2_MOCS_UC_IDX				3
+#define XE2_MOCS_WB_IDX				1

Wouldn't we want index 4 here (WB in both L3 and L4) rather than just L3?

Matt

Quoted 19 lines
lib/intel_mocs.c +4 -1
 #define XY_BLOCK_COPY_BLT_MOCS_SHIFT		21
 #define XY_CTRL_SURF_COPY_BLT_MOCS_SHIFT	25
 
@@ -33,7 +35,10 @@ static void get_mocs_index(int fd, struct drm_intel_mocs_index *mocs)
 	 * This helper function is providing current UC as well
 	 * as WB MOCS index based on platform.
 	 */
-	if (IS_METEORLAKE(devid)) {
+	if (intel_graphics_ver(devid) >= IP_VER(20, 0)) {
+		mocs->uc_index = XE2_MOCS_UC_IDX;
+		mocs->wb_index = XE2_MOCS_WB_IDX;
+	} else if (IS_METEORLAKE(devid)) {
 		mocs->uc_index = MTL_MOCS_UC_IDX;
 		mocs->wb_index = MTL_MOCS_WB_IDX;
 	} else if (IS_DG2(devid)) {
Signature · 1 line
2.40.1
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#12 lore raw

Re: [igt-dev] [Intel-xe] [PATCH i-g-t v2 08/13] lib/intel_mocs: Add Xe2 mocs indexes

Quoted 8 lines · Matt Roper
Quoted 7 lines · Lucas De Marchi

Add WB and UC mocs indexes for Xe2 architecture and later.

---
 lib/intel_mocs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 13 lines

lib/intel_mocs.c line 18

Quoted 10 lines
lib/intel_mocs.c +2 -0
index 6a4ec25e4..d9de16932 100644
@@ -14,6 +14,8 @@
 #define MTL_MOCS_WB_IDX				10
 #define GEN12_MOCS_UC_IDX			3
 #define GEN12_MOCS_WB_IDX			2
+#define XE2_MOCS_UC_IDX				3
+#define XE2_MOCS_WB_IDX				1

Wouldn't we want index 4 here (WB in both L3 and L4) rather than just L3?

I think we were always using the same index as used on the kernel side.

If we are going to use index 4 here, then we also need to update the kernel side to actually program it. Right now we are doing:

	static const struct xe_mocs_entry xe2_mocs_table[] = {
		/* Defer to PAT */
		MOCS_ENTRY(0, XE2_L3_0_WB | L4_0_WB, 0),
		/* Cached L3 + L4 */
		MOCS_ENTRY(1, IG_PAT | XE2_L3_0_WB | L4_0_WB, 0),
		/* Uncached L3, Cached L4 */
		MOCS_ENTRY(2, IG_PAT | XE2_L3_3_UC | L4_0_WB, 0),
		/* Uncached L3 + L4 */
		MOCS_ENTRY(3, IG_PAT | XE2_L3_3_UC | L4_3_UC, 0),
	};

Lucas De Marchi

#13 lore raw

PATCH v2 9/13 lib/igt_draw: Add Xe2 mocs to XY_FAST_COLOR_BLT

In reply to Lucas De Marchi
---
 lib/igt_draw.c  | 6 +++++-
 lib/intel_reg.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)
lib/igt_draw.c +5 -1
index d7c3ac64c..9a7664a37 100644
@@ -716,7 +716,11 @@ static void draw_rect_blt(int fd, struct cmd_data *cmd_data,
 		}
 
 		pitch = tiling ? buf->stride / 4 : buf->stride;
-		mocs = intel_get_uc_mocs_index(fd) << XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT;
+
+		if (ver >= 20)
+			mocs = intel_get_uc_mocs_index(fd) << XE2_XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT;
+		else
+			mocs = intel_get_uc_mocs_index(fd) << XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT;
 
 		intel_bb_out(ibb, XY_FAST_COLOR_BLT | blt_cmd_depth);
 		intel_bb_out(ibb, blt_cmd_tiling | mocs | (pitch-1));
lib/intel_reg.h +1 -0
index f97154d2b..ea463376b 100644
@@ -2564,6 +2564,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define XY_FAST_COLOR_BLT				((0x2<<29)|(0x44<<22)|0xe)
 #define   XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT		22
+#define   XE2_XY_FAST_COLOR_BLT_MOCS_INDEX_SHIFT	24
 
 #define XY_FAST_COPY_BLT				((2<<29)|(0x42<<22)|0x8)
 /* dword 0 */
Signature · 1 line
2.40.1
#14 lore raw

PATCH v2 10/13 lib/intel_mocs: Remove unused lefotver defines

In reply to Lucas De Marchi

Leftover from previous refactors. Remove since they are unused.

---
 lib/intel_mocs.c | 2 --
 1 file changed, 2 deletions(-)
lib/intel_mocs.c +0 -2
index d9de16932..aafe27692 100644
@@ -16,8 +16,6 @@
 #define GEN12_MOCS_WB_IDX			2
 #define XE2_MOCS_UC_IDX				3
 #define XE2_MOCS_WB_IDX				1
-#define XY_BLOCK_COPY_BLT_MOCS_SHIFT		21
-#define XY_CTRL_SURF_COPY_BLT_MOCS_SHIFT	25
 
 struct drm_intel_mocs_index {
 	uint8_t uc_index;
Signature · 1 line
2.40.1
#15 lore raw

PATCH v2 11/13 lib/intel_blt: Support Xe2 in xy-block-copy command

In reply to Lucas De Marchi

Xe2 block-copy command is slightly different, with dw01 and dw02 having a few differences: 1) different bitrange for mocs; 2) no ctrl_surface_type, aux_mode or compression.

---
 lib/intel_blt.c | 111 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 73 insertions(+), 38 deletions(-)
lib/intel_blt.c +73 -38
index d1aa0872c..4e0fe6320 100644
@@ -55,15 +55,26 @@ struct gen12_block_copy_data {
 		uint32_t client:			BITRANGE(29, 31);
 	} dw00;
 
-	struct {
-		uint32_t dst_pitch:			BITRANGE(0, 17);
-		uint32_t dst_aux_mode:			BITRANGE(18, 20);
-		uint32_t pxp:				BITRANGE(21, 21);
-		uint32_t dst_mocs_index:		BITRANGE(22, 27);
-		uint32_t dst_ctrl_surface_type:		BITRANGE(28, 28);
-		uint32_t dst_compression:		BITRANGE(29, 29);
-		uint32_t dst_tiling:			BITRANGE(30, 31);
-	} dw01;
+	union {
+		struct {
+			uint32_t dst_pitch:			BITRANGE(0, 17);
+			uint32_t dst_aux_mode:			BITRANGE(18, 20);
+			uint32_t pxp:				BITRANGE(21, 21);
+			uint32_t dst_mocs_index:		BITRANGE(22, 27);
+			uint32_t dst_ctrl_surface_type:		BITRANGE(28, 28);
+			uint32_t dst_compression:		BITRANGE(29, 29);
+			uint32_t dst_tiling:			BITRANGE(30, 31);
+		} dw01;
+		struct {
+			uint32_t dst_pitch:			BITRANGE(0, 17);
+			uint32_t dst_aux_mode:			BITRANGE(18, 20);
+			uint32_t pxp:				BITRANGE(21, 21);
+			uint32_t dst_mocs_index:		BITRANGE(22, 27);
+			uint32_t dst_ctrl_surface_type:		BITRANGE(28, 28);
+			uint32_t dst_compression:		BITRANGE(29, 29);
+			uint32_t dst_tiling:			BITRANGE(30, 31);
+		} dw01_xe2;
+	};
 
 	struct {
 		int32_t dst_x1:				BITRANGE(0, 15);
@@ -96,15 +107,26 @@ struct gen12_block_copy_data {
 		int32_t src_y1:				BITRANGE(16, 31);
 	} dw07;
 
-	struct {
-		uint32_t src_pitch:			BITRANGE(0, 17);
-		uint32_t src_aux_mode:			BITRANGE(18, 20);
-		uint32_t pxp:				BITRANGE(21, 21);
-		uint32_t src_mocs_index:		BITRANGE(22, 27);
-		uint32_t src_ctrl_surface_type:		BITRANGE(28, 28);
-		uint32_t src_compression:		BITRANGE(29, 29);
-		uint32_t src_tiling:			BITRANGE(30, 31);
-	} dw08;
+	union {
+		struct {
+			uint32_t src_pitch:			BITRANGE(0, 17);
+			uint32_t src_aux_mode:			BITRANGE(18, 20);
+			uint32_t pxp:				BITRANGE(21, 21);
+			uint32_t src_mocs_index:		BITRANGE(22, 27);
+			uint32_t src_ctrl_surface_type:		BITRANGE(28, 28);
+			uint32_t src_compression:		BITRANGE(29, 29);
+			uint32_t src_tiling:			BITRANGE(30, 31);
+		} dw08;
+		struct {
+			uint32_t src_pitch:			BITRANGE(0, 17);
+			uint32_t pad0:				BITRANGE(18, 20);
+			uint32_t pxp:				BITRANGE(21, 21);
+			uint32_t pad1:				BITRANGE(22, 23);
+			uint32_t src_mocs_index:		BITRANGE(24, 27);
+			uint32_t pad2:				BITRANGE(28, 29);
+			uint32_t src_tiling:			BITRANGE(30, 31);
+		} dw08_xe2;
+	};
 
 	struct {
 		uint32_t src_address_lo;
@@ -553,7 +575,7 @@ static bool __new_tile_y_type(enum blt_tiling_type tiling)
 static void fill_data(struct gen12_block_copy_data *data,
 		      const struct blt_copy_data *blt,
 		      uint64_t src_offset, uint64_t dst_offset,
-		      bool extended_command)
+		      bool extended_command, unsigned int ip_ver)
 {
 	data->dw00.client = 0x2;
 	data->dw00.opcode = 0x41;
@@ -561,18 +583,24 @@ static void fill_data(struct gen12_block_copy_data *data,
 	data->dw00.special_mode = __special_mode(blt);
 	data->dw00.length = extended_command ? 20 : 10;
 
-	if (__special_mode(blt) == SM_FULL_RESOLVE)
-		data->dw01.dst_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->src);
-	else
-		data->dw01.dst_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->dst);
-	data->dw01.dst_pitch = blt->dst.pitch - 1;
+	if (ip_ver >= IP_VER(20, 0)) {
+		data->dw01_xe2.dst_pitch = blt->dst.pitch - 1;
+		data->dw01_xe2.dst_mocs_index = blt->dst.mocs_index;
+		data->dw01_xe2.dst_tiling = __block_tiling(blt->dst.tiling);
+	} else {
+		if (__special_mode(blt) == SM_FULL_RESOLVE)
+			data->dw01.dst_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->src);
+		else
+			data->dw01.dst_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->dst);
+		data->dw01.dst_pitch = blt->dst.pitch - 1;
 
-	data->dw01.dst_mocs_index = blt->dst.mocs_index;
-	data->dw01.dst_compression = blt->dst.compression;
-	data->dw01.dst_tiling = __block_tiling(blt->dst.tiling);
+		data->dw01.dst_mocs_index = blt->dst.mocs_index;
+		data->dw01.dst_compression = blt->dst.compression;
+		data->dw01.dst_tiling = __block_tiling(blt->dst.tiling);
 
-	if (blt->dst.compression)
-		data->dw01.dst_ctrl_surface_type = blt->dst.compression_type;
+		if (blt->dst.compression)
+			data->dw01.dst_ctrl_surface_type = blt->dst.compression_type;
+	}
 
 	data->dw02.dst_x1 = blt->dst.x1;
 	data->dw02.dst_y1 = blt->dst.y1;
@@ -590,14 +618,20 @@ static void fill_data(struct gen12_block_copy_data *data,
 	data->dw07.src_x1 = blt->src.x1;
 	data->dw07.src_y1 = blt->src.y1;
 
-	data->dw08.src_pitch = blt->src.pitch - 1;
-	data->dw08.src_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->src);
-	data->dw08.src_mocs_index = blt->src.mocs_index;
-	data->dw08.src_compression = blt->src.compression;
-	data->dw08.src_tiling = __block_tiling(blt->src.tiling);
-
-	if (blt->src.compression)
-		data->dw08.src_ctrl_surface_type = blt->src.compression_type;
+	if (ip_ver >= IP_VER(20, 0)) {
+		data->dw08_xe2.src_pitch = blt->src.pitch - 1;
+		data->dw08_xe2.src_mocs_index = blt->src.mocs_index;
+		data->dw08_xe2.src_tiling = __block_tiling(blt->src.tiling);
+	} else {
+		data->dw08.src_pitch = blt->src.pitch - 1;
+		data->dw08.src_aux_mode = __aux_mode(blt->fd, blt->driver, &blt->src);
+		data->dw08.src_mocs_index = blt->src.mocs_index;
+		data->dw08.src_compression = blt->src.compression;
+		data->dw08.src_tiling = __block_tiling(blt->src.tiling);
+
+		if (blt->src.compression)
+			data->dw08.src_ctrl_surface_type = blt->src.compression_type;
+	}
 
 	data->dw09.src_address_lo = src_offset;
 	data->dw10.src_address_hi = src_offset >> 32;
@@ -802,6 +836,7 @@ uint64_t emit_blt_block_copy(int fd,
 			     uint64_t bb_pos,
 			     bool emit_bbe)
 {
+	unsigned int ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
 	struct gen12_block_copy_data data = {};
 	struct gen12_block_copy_data_ext dext = {};
 	uint64_t dst_offset, src_offset, bb_offset, alignment;
@@ -818,7 +853,7 @@ uint64_t emit_blt_block_copy(int fd,
 		     + blt->dst.plane_offset;
 	bb_offset = get_offset(ahnd, blt->bb.handle, blt->bb.size, alignment);
 
-	fill_data(&data, blt, src_offset, dst_offset, ext);
+	fill_data(&data, blt, src_offset, dst_offset, ext, ip_ver);
 
 	bb = bo_map(fd, blt->bb.handle, blt->bb.size, blt->driver);
 
Signature · 1 line
2.40.1
#16 lore raw

PATCH v2 12/13 lib/intel_blt: Support xe2 in xy-fast-copy command

In reply to Lucas De Marchi

Xe2 xy-fast-copy command is slightly different, with dw01 and dw07 having a few differences: 1) different bitrange for mocs (it was previously absent in dw07); 2) no dst_memory, src_memory;
3) hardcoded dst_type_y and src_type_y to 1.

---
 lib/intel_blt.c | 82 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 61 insertions(+), 21 deletions(-)
lib/intel_blt.c +61 -21
index 4e0fe6320..0d00f0fbc 100644
@@ -1185,16 +1185,29 @@ struct gen12_fast_copy_data {
 		uint32_t client:			BITRANGE(29, 31);
 	} dw00;
 
-	struct {
-		uint32_t dst_pitch:			BITRANGE(0, 15);
-		uint32_t rsvd1:				BITRANGE(16, 23);
-		uint32_t color_depth:			BITRANGE(24, 26);
-		uint32_t rsvd0:				BITRANGE(27, 27);
-		uint32_t dst_memory:			BITRANGE(28, 28);
-		uint32_t src_memory:			BITRANGE(29, 29);
-		uint32_t dst_type_y:			BITRANGE(30, 30);
-		uint32_t src_type_y:			BITRANGE(31, 31);
-	} dw01;
+	union {
+		struct {
+			uint32_t dst_pitch:			BITRANGE(0, 15);
+			uint32_t rsvd1:				BITRANGE(16, 23);
+			uint32_t color_depth:			BITRANGE(24, 26);
+			uint32_t rsvd0:				BITRANGE(27, 27);
+			uint32_t dst_memory:			BITRANGE(28, 28);
+			uint32_t src_memory:			BITRANGE(29, 29);
+			uint32_t dst_type_y:			BITRANGE(30, 30);
+			uint32_t src_type_y:			BITRANGE(31, 31);
+		} dw01;
+		struct {
+			uint32_t dst_pitch:			BITRANGE(0, 15);
+			uint32_t rsvd2:				BITRANGE(16, 16);
+			uint32_t pxp:				BITRANGE(16, 17);
+			uint32_t rsvd1:				BITRANGE(18, 19);
+			uint32_t dst_mocs_index:		BITRANGE(20, 23);
+			uint32_t color_depth:			BITRANGE(24, 26);
+			uint32_t rsvd0:				BITRANGE(27, 29);
+			uint32_t dst_type_y:			BITRANGE(30, 30);
+			uint32_t src_type_y:			BITRANGE(31, 31);
+		} dw01_xe2;
+	};
 
 	struct {
 		int32_t dst_x1:				BITRANGE(0, 15);
@@ -1219,10 +1232,20 @@ struct gen12_fast_copy_data {
 		int32_t src_y1:				BITRANGE(16, 31);
 	} dw06;
 
-	struct {
-		uint32_t src_pitch:			BITRANGE(0, 15);
-		uint32_t rsvd0:				BITRANGE(16, 31);
-	} dw07;
+	union {
+		struct {
+			uint32_t src_pitch:			BITRANGE(0, 15);
+			uint32_t rsvd0:				BITRANGE(16, 31);
+		} dw07;
+		struct {
+			uint32_t src_pitch:			BITRANGE(0, 15);
+			uint32_t rsvd0:				BITRANGE(16, 16);
+			uint32_t pxp:				BITRANGE(17, 17);
+			uint32_t rsvd1:				BITRANGE(18, 19);
+			uint32_t src_mocs_index:		BITRANGE(20, 23);
+			uint32_t rsvd2:				BITRANGE(24, 31);
+		} dw07_xe2;
+	};
 
 	struct {
 		uint32_t src_address_lo;
@@ -1321,11 +1344,13 @@ uint64_t emit_blt_fast_copy(int fd,
 			    uint64_t bb_pos,
 			    bool emit_bbe)
 {
+	unsigned int ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
 	struct gen12_fast_copy_data data = {};
 	uint64_t dst_offset, src_offset, bb_offset, alignment;
 	uint32_t bbe = MI_BATCH_BUFFER_END;
 	uint32_t *bb;
 
+
 	alignment = get_default_alignment(fd, blt->driver);
 
 	data.dw00.client = 0x2;
@@ -1334,12 +1359,22 @@ uint64_t emit_blt_fast_copy(int fd,
 	data.dw00.src_tiling = __fast_tiling(blt->src.tiling);
 	data.dw00.length = 8;
 
-	data.dw01.dst_pitch = blt->dst.pitch;
-	data.dw01.color_depth = __fast_color_depth(blt->color_depth);
-	data.dw01.dst_memory = __memory_type(blt->fd, blt->driver, blt->dst.region);
-	data.dw01.src_memory = __memory_type(blt->fd, blt->driver, blt->src.region);
-	data.dw01.dst_type_y = __new_tile_y_type(blt->dst.tiling) ? 1 : 0;
-	data.dw01.src_type_y = __new_tile_y_type(blt->src.tiling) ? 1 : 0;
+	if (ip_ver >= IP_VER(20, 0)) {
+		data.dw01_xe2.dst_pitch = blt->dst.pitch;
+		data.dw01_xe2.dst_mocs_index = blt->dst.mocs_index;
+		data.dw01_xe2.color_depth = __fast_color_depth(blt->color_depth);
+
+		/* Undefined behavior to leave as 0, must be set to 1 */
+		data.dw01_xe2.dst_type_y = 1;
+		data.dw01_xe2.src_type_y = 1;
+	} else {
+		data.dw01.dst_pitch = blt->dst.pitch;
+		data.dw01.color_depth = __fast_color_depth(blt->color_depth);
+		data.dw01.dst_memory = __memory_type(blt->fd, blt->driver, blt->dst.region);
+		data.dw01.src_memory = __memory_type(blt->fd, blt->driver, blt->src.region);
+		data.dw01.dst_type_y = __new_tile_y_type(blt->dst.tiling) ? 1 : 0;
+		data.dw01.src_type_y = __new_tile_y_type(blt->src.tiling) ? 1 : 0;
+	}
 
 	data.dw02.dst_x1 = blt->dst.x1;
 	data.dw02.dst_y1 = blt->dst.y1;
@@ -1359,7 +1394,12 @@ uint64_t emit_blt_fast_copy(int fd,
 	data.dw06.src_x1 = blt->src.x1;
 	data.dw06.src_y1 = blt->src.y1;
 
-	data.dw07.src_pitch = blt->src.pitch;
+	if (ip_ver >= IP_VER(20, 0)) {
+		data.dw07_xe2.src_pitch = blt->src.pitch;
+		data.dw07_xe2.src_mocs_index = blt->src.mocs_index;
+	} else {
+		data.dw07.src_pitch = blt->src.pitch;
+	}
 
 	data.dw08.src_address_lo = src_offset;
 	data.dw09.src_address_hi = src_offset >> 32;
Signature · 1 line
2.40.1
#17 lore raw

PATCH v2 13/13 lib/intel_blt: Support xe2 in ctrl-surf-copy command

In reply to Lucas De Marchi

Xe2 ctrl-surf-copy command varies significantly from gen12. Create a new struct and function to fill the data, sharing the rest of the logic in emit_blt_ctrl_surf_copy().

---
 lib/intel_blt.c | 128 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 107 insertions(+), 21 deletions(-)
lib/intel_blt.c +107 -21
index 0d00f0fbc..81b765548 100644
@@ -998,6 +998,65 @@ struct gen12_ctrl_surf_copy_data {
 	} dw04;
 };
 
+struct xe2_ctrl_surf_copy_data {
+	struct {
+		uint32_t length:			BITRANGE(0, 7);
+		uint32_t rsvd0:				BITRANGE(8, 8);
+		uint32_t size_of_ctrl_copy:		BITRANGE(9, 18);
+		uint32_t rsvd1:				BITRANGE(19, 19);
+		uint32_t dst_access_type:		BITRANGE(20, 20);
+		uint32_t src_access_type:		BITRANGE(21, 21);
+		uint32_t opcode:			BITRANGE(22, 28);
+		uint32_t client:			BITRANGE(29, 31);
+	} dw00;
+
+	struct {
+		uint32_t src_address_lo;
+	} dw01;
+
+	struct {
+		uint32_t src_address_hi:		BITRANGE(0, 24);
+		uint32_t pxp:				BITRANGE(25, 27);
+		uint32_t src_mocs_index:		BITRANGE(28, 31);
+	} dw02;
+
+	struct {
+		uint32_t dst_address_lo;
+	} dw03;
+
+	struct {
+		uint32_t dst_address_hi:		BITRANGE(0, 24);
+		uint32_t pxp:				BITRANGE(25, 27);
+		uint32_t dst_mocs_index:		BITRANGE(28, 31);
+	} dw04;
+};
+
+union ctrl_surf_copy_data {
+	struct gen12_ctrl_surf_copy_data gen12;
+	struct xe2_ctrl_surf_copy_data xe2;
+};
+
+static void xe2_dump_bb_surf_ctrl_cmd(const struct xe2_ctrl_surf_copy_data *data)
+{
+	uint32_t *cmd = (uint32_t *) data;
+
+	igt_info("details:\n");
+	igt_info(" dw00: [%08x] <client: 0x%x, opcode: 0x%x, "
+		 "src/dst access type: <%d, %d>, size of ctrl copy: %u, length: %d>\n",
+		 cmd[0],
+		 data->dw00.client, data->dw00.opcode,
+		 data->dw00.src_access_type, data->dw00.dst_access_type,
+		 data->dw00.size_of_ctrl_copy, data->dw00.length);
+	igt_info(" dw01: [%08x] src offset lo (0x%x)\n",
+		 cmd[1], data->dw01.src_address_lo);
+	igt_info(" dw02: [%08x] src offset hi (0x%x), src mocs idx: %u\n",
+		 cmd[2], data->dw02.src_address_hi, data->dw02.src_mocs_index);
+	igt_info(" dw03: [%08x] dst offset lo (0x%x)\n",
+		 cmd[3], data->dw03.dst_address_lo);
+	igt_info(" dw04: [%08x] dst offset hi (0x%x), src mocs idx: %u\n",
+		 cmd[4], data->dw04.dst_address_hi, data->dw04.dst_mocs_index);
+}
+
 static void dump_bb_surf_ctrl_cmd(const struct gen12_ctrl_surf_copy_data *data)
 {
 	uint32_t *cmd = (uint32_t *) data;
@@ -1056,7 +1115,9 @@ uint64_t emit_blt_ctrl_surf_copy(int fd,
 				 uint64_t bb_pos,
 				 bool emit_bbe)
 {
-	struct gen12_ctrl_surf_copy_data data = {};
+	unsigned int ip_ver = intel_graphics_ver(intel_get_drm_devid(fd));
+	union ctrl_surf_copy_data data = { };
+	size_t data_sz;
 	uint64_t dst_offset, src_offset, bb_offset, alignment;
 	uint32_t bbe = MI_BATCH_BUFFER_END;
 	uint32_t *bb;
@@ -1065,33 +1126,55 @@ uint64_t emit_blt_ctrl_surf_copy(int fd,
 	igt_assert_f(surf, "ctrl-surf-copy requires data to do ctrl-surf-copy blit\n");
 
 	alignment = max_t(uint64_t, get_default_alignment(fd, surf->driver), 1ull << 16);
-
-	data.dw00.client = 0x2;
-	data.dw00.opcode = 0x48;
-	data.dw00.src_access_type = surf->src.access_type;
-	data.dw00.dst_access_type = surf->dst.access_type;
-
-	/* Ensure dst has size capable to keep src ccs aux */
-	data.dw00.size_of_ctrl_copy = __ccs_size(surf) / CCS_RATIO - 1;
-	data.dw00.length = 0x3;
-
 	src_offset = get_offset(ahnd, surf->src.handle, surf->src.size, alignment);
 	dst_offset = get_offset(ahnd, surf->dst.handle, surf->dst.size, alignment);
 	bb_offset = get_offset(ahnd, surf->bb.handle, surf->bb.size, alignment);
 
-	data.dw01.src_address_lo = src_offset;
-	data.dw02.src_address_hi = src_offset >> 32;
-	data.dw02.src_mocs_index = surf->src.mocs_index;
+	if (ip_ver >= IP_VER(20, 0)) {
+		data.xe2.dw00.client = 0x2;
+		data.xe2.dw00.opcode = 0x48;
+		data.xe2.dw00.src_access_type = surf->src.access_type;
+		data.xe2.dw00.dst_access_type = surf->dst.access_type;
+
+		/* Ensure dst has size capable to keep src ccs aux */
+		data.xe2.dw00.size_of_ctrl_copy = __ccs_size(surf) / CCS_RATIO - 1;
+		data.xe2.dw00.length = 0x3;
+
+		data.xe2.dw01.src_address_lo = src_offset;
+		data.xe2.dw02.src_address_hi = src_offset >> 32;
+		data.xe2.dw02.src_mocs_index = surf->src.mocs_index;
+
+		data.xe2.dw03.dst_address_lo = dst_offset;
+		data.xe2.dw04.dst_address_hi = dst_offset >> 32;
+		data.xe2.dw04.dst_mocs_index = surf->dst.mocs_index;
+
+		data_sz = sizeof(data.xe2);
+	} else {
+		data.gen12.dw00.client = 0x2;
+		data.gen12.dw00.opcode = 0x48;
+		data.gen12.dw00.src_access_type = surf->src.access_type;
+		data.gen12.dw00.dst_access_type = surf->dst.access_type;
+
+		/* Ensure dst has size capable to keep src ccs aux */
+		data.gen12.dw00.size_of_ctrl_copy = __ccs_size(surf) / CCS_RATIO - 1;
+		data.gen12.dw00.length = 0x3;
+
+		data.gen12.dw01.src_address_lo = src_offset;
+		data.gen12.dw02.src_address_hi = src_offset >> 32;
+		data.gen12.dw02.src_mocs_index = surf->src.mocs_index;
+
+		data.gen12.dw03.dst_address_lo = dst_offset;
+		data.gen12.dw04.dst_address_hi = dst_offset >> 32;
+		data.gen12.dw04.dst_mocs_index = surf->dst.mocs_index;
 
-	data.dw03.dst_address_lo = dst_offset;
-	data.dw04.dst_address_hi = dst_offset >> 32;
-	data.dw04.dst_mocs_index = surf->dst.mocs_index;
+		data_sz = sizeof(data.gen12);
+	}
 
 	bb = bo_map(fd, surf->bb.handle, surf->bb.size, surf->driver);
 
-	igt_assert(bb_pos + sizeof(data) < surf->bb.size);
-	memcpy(bb + bb_pos, &data, sizeof(data));
-	bb_pos += sizeof(data);
+	igt_assert(bb_pos + data_sz < surf->bb.size);
+	memcpy(bb + bb_pos, &data, data_sz);
+	bb_pos += data_sz;
 
 	if (emit_bbe) {
 		igt_assert(bb_pos + sizeof(uint32_t) < surf->bb.size);
@@ -1105,7 +1188,10 @@ uint64_t emit_blt_ctrl_surf_copy(int fd,
 			 ", bb offset: %" PRIx64 "\n",
 			 src_offset, dst_offset, bb_offset);
 
-		dump_bb_surf_ctrl_cmd(&data);
+		if (ip_ver >= IP_VER(20, 0))
+			xe2_dump_bb_surf_ctrl_cmd(&data.xe2);
+		else
+			dump_bb_surf_ctrl_cmd(&data.gen12);
 	}
 
 	munmap(bb, surf->bb.size);
Signature · 1 line
2.40.1
#18 lore raw

[Intel-xe] ✗ CI.Patch_applied: failure for Adapt copy commands for Xe2 (rev3)

In reply to Lucas De Marchi
== Series Details ==

== Series Details ==

Series: Adapt copy commands for Xe2 (rev3)
URL : https://patchwork.freedesktop.org/series/123772/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: === Base commit: 090c3e92d drm/xe/hwmon: Expose hwmon energy attribute === git am output follows ===
error: lib/rendercopy_gen9.c: does not exist in index
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: lib/rendercopy: Use common mocs function
Patch failed at 0001 lib/rendercopy: Use common mocs function When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

#19 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for Adapt copy commands for Xe2 (rev3)

In reply to Lucas De Marchi
== Series Details ==

== Series Details ==

Series: Adapt copy commands for Xe2 (rev3)
URL : https://patchwork.freedesktop.org/series/123773/
State : failure

== Summary ==

IGT patchset build failed on latest successful build a4b4a33d8312e4e30ca23d26bbd1758e56540e1d tests/kms_frontbuffer_tracking: Remove badstride subtests

Tail of build.log:
[616/1641] Compiling C object 'tests/59830eb@@xe_sysfs_defaults@exe/intel_xe_sysfs_defaults.c.o'. [617/1641] Compiling C object 'tests/59830eb@@xe_exec_basic@exe/intel_xe_exec_basic.c.o'. [618/1641] Compiling C object 'tests/59830eb@@gem_sync@exe/intel_gem_sync.c.o'.
[619/1641] Compiling C object 'tests/59830eb@@kms_big_fb@exe/intel_kms_big_fb.c.o'. [620/1641] Compiling C object 'tests/59830eb@@xe_pm_residency@exe/intel_xe_pm_residency.c.o'. [621/1641] Compiling C object 'tests/59830eb@@msm_submitoverhead@exe/msm_msm_submitoverhead.c.o'. [622/1641] Compiling C object 'tests/59830eb@@msm_mapping@exe/msm_msm_mapping.c.o'. [623/1641] Compiling C object 'tests/59830eb@@msm_recovery@exe/msm_msm_recovery.c.o'. [624/1641] Compiling C object 'tests/59830eb@@xe_sysfs_scheduler@exe/intel_xe_sysfs_scheduler.c.o'. [625/1641] Compiling C object 'tests/59830eb@@xe_prime_self_import@exe/intel_xe_prime_self_import.c.o'. [626/1641] Compiling C object 'tests/59830eb@@xe_spin_batch@exe/intel_xe_spin_batch.c.o'. [627/1641] Compiling C object 'tests/59830eb@@kms_chamelium_audio@exe/chamelium_kms_chamelium_helper.c.o'. [628/1641] Compiling C object 'tests/59830eb@@xe_exec_fault_mode@exe/intel_xe_exec_fault_mode.c.o'. [629/1641] Compiling C object 'tests/59830eb@@xe_query@exe/intel_xe_query.c.o'.
[630/1641] Compiling C object 'tests/v3d/cad21b8@@v3d_get_bo_offset@exe/v3d_get_bo_offset.c.o'. [631/1641] Compiling C object 'tests/v3d/cad21b8@@v3d_create_bo@exe/v3d_create_bo.c.o'. [632/1641] Compiling C object 'tests/59830eb@@kms_chamelium_color@exe/kms_color_helper.c.o'. [633/1641] Compiling C object 'tests/59830eb@@gem_softpin@exe/intel_gem_softpin.c.o'. [634/1641] Compiling C object 'tests/59830eb@@msm_submit@exe/msm_msm_submit.c.o'.
[635/1641] Compiling C object 'tests/59830eb@@msm_shrink@exe/msm_msm_shrink.c.o'.
[636/1641] Compiling C object 'tests/59830eb@@xe_guc_pc@exe/intel_xe_guc_pc.c.o'.
[637/1641] Compiling C object 'tests/v3d/cad21b8@@v3d_mmap@exe/v3d_mmap.c.o'.
[638/1641] Compiling C object 'tests/59830eb@@kms_chamelium_hpd@exe/chamelium_kms_chamelium_helper.c.o'. [639/1641] Compiling C object 'tests/59830eb@@xe_pm@exe/intel_xe_pm.c.o'.
[640/1641] Compiling C object 'tests/59830eb@@kms_chamelium_edid@exe/chamelium_kms_chamelium_helper.c.o'. [641/1641] Compiling C object 'tests/59830eb@@kms_chamelium_frames@exe/chamelium_kms_chamelium_helper.c.o'. [642/1641] Compiling C object 'tests/59830eb@@xe_exec_balancer@exe/intel_xe_exec_balancer.c.o'. [643/1641] Compiling C object 'tests/v3d/cad21b8@@v3d_job_submission@exe/v3d_job_submission.c.o'. [644/1641] Compiling C object 'tests/59830eb@@xe_evict@exe/intel_xe_evict.c.o'.
[645/1641] Compiling C object 'tests/59830eb@@kms_chamelium_audio@exe/chamelium_kms_chamelium_audio.c.o'. [646/1641] Compiling C object 'tests/59830eb@@xe_exec_reset@exe/intel_xe_exec_reset.c.o'. [647/1641] Compiling C object 'tests/59830eb@@kms_psr2_sf@exe/intel_kms_psr2_sf.c.o'. [648/1641] Compiling C object 'tests/59830eb@@kms_chamelium_hpd@exe/chamelium_kms_chamelium_hpd.c.o'. [649/1641] Compiling C object 'tests/59830eb@@kms_chamelium_edid@exe/chamelium_kms_chamelium_edid.c.o'. [650/1641] Compiling C object 'tests/59830eb@@xe_intel_bb@exe/intel_xe_intel_bb.c.o'. [651/1641] Compiling C object 'tests/59830eb@@kms_chamelium_color@exe/chamelium_kms_chamelium_color.c.o'. [652/1641] Compiling C object 'tests/59830eb@@xe_exec_threads@exe/intel_xe_exec_threads.c.o'. [653/1641] Compiling C object 'tests/59830eb@@i915_query@exe/intel_i915_query.c.o'. [654/1641] Compiling C object 'tests/59830eb@@gem_exec_balancer@exe/intel_gem_exec_balancer.c.o'. [655/1641] Compiling C object 'tests/59830eb@@kms_chamelium_frames@exe/chamelium_kms_chamelium_frames.c.o'. [656/1641] Compiling C object 'tests/59830eb@@i915_pm_rpm@exe/intel_i915_pm_rpm.c.o'. [657/1641] Compiling C object 'tests/59830eb@@gem_exec_fence@exe/intel_gem_exec_fence.c.o'. [658/1641] Compiling C object 'tests/59830eb@@gem_userptr_blits@exe/intel_gem_userptr_blits.c.o'. [659/1641] Compiling C object 'tests/59830eb@@xe_vm@exe/intel_xe_vm.c.o'.
[660/1641] Compiling C object 'tests/59830eb@@kms_frontbuffer_tracking@exe/intel_kms_frontbuffer_tracking.c.o'. [661/1641] Compiling C object 'tests/59830eb@@perf_pmu@exe/intel_perf_pmu.c.o'.
[662/1641] Generating i915-perf-equations with a custom command.
[663/1641] Compiling C object 'tests/59830eb@@gem_exec_schedule@exe/intel_gem_exec_schedule.c.o'. [664/1641] Compiling C object 'tests/59830eb@@perf@exe/intel_perf.c.o'.
ninja: build stopped: subcommand failed.