Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [igt-dev] [PATCH i-g-t v3 13/13] lib/intel_blt: Support xe2 in ctrl-surf-copy command
Date: Wed,  4 Oct 2023 08:49:22 -0700	[thread overview]
Message-ID: <20231004154922.3478014-14-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20231004154922.3478014-1-lucas.demarchi@intel.com>

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().

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/intel_blt.c | 128 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 107 insertions(+), 21 deletions(-)

diff --git a/lib/intel_blt.c b/lib/intel_blt.c
index 0d00f0fbc..81b765548 100644
--- a/lib/intel_blt.c
+++ b/lib/intel_blt.c
@@ -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);
-- 
2.40.1

  parent reply	other threads:[~2023-10-04 15:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 15:49 [igt-dev] [PATCH i-g-t v3 00/13] Adapt copy commands for Xe2 Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 01/13] lib/rendercopy: Use common mocs function Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 02/13] lib/gpu_cmds: Remove prefix from gen7_fill_binding_table() Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 03/13] lib/gpu_cmds: Reorder if/else ladder according to IP version Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 04/13] lib/gpu_cmds: Fork a gen9_fill_surface_state() Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 05/13] lib/gpu_cmds: Reduce scope of xehp_fill_surface_state() Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 06/13] lib: Fork gen9_media.h Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 07/13] lib/intel_mocs: Stop encoding mocs Lucas De Marchi
2023-10-09 18:54   ` Matt Roper
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 08/13] lib/intel_mocs: Add Xe2 mocs indexes Lucas De Marchi
2023-10-09 18:56   ` Matt Roper
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 09/13] lib/igt_draw: Add Xe2 mocs to XY_FAST_COLOR_BLT Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 10/13] lib/intel_mocs: Remove unused lefotver defines Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 11/13] lib/intel_blt: Support Xe2 in xy-block-copy command Lucas De Marchi
2023-10-04 15:49 ` [igt-dev] [PATCH i-g-t v3 12/13] lib/intel_blt: Support xe2 in xy-fast-copy command Lucas De Marchi
2023-10-06 22:38   ` [igt-dev] [PATCH i-g-t v3.1 " Lucas De Marchi
2023-10-04 15:49 ` Lucas De Marchi [this message]
2023-10-04 18:51 ` [igt-dev] ✗ Fi.CI.BAT: failure for Adapt copy commands for Xe2 (rev4) Patchwork
2023-10-04 19:36 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
2023-10-04 21:49 ` [igt-dev] ✓ Fi.CI.BAT: success for Adapt copy commands for Xe2 (rev5) Patchwork
2023-10-04 23:52 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-10-05  8:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-10-06 23:34 ` [igt-dev] ✓ Fi.CI.BAT: success for Adapt copy commands for Xe2 (rev6) Patchwork
2023-10-06 23:34 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-10-07 13:11 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-10-10 15:49 ` [igt-dev] [PATCH i-g-t v3 00/13] Adapt copy commands for Xe2 Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231004154922.3478014-14-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox