All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_exec_parse: Check batch_start_offset
Date: Wed, 11 Dec 2019 16:48:38 +0000	[thread overview]
Message-ID: <20191211164838.137117-1-chris@chris-wilson.co.uk> (raw)

Validate that the cmdparser works with whatever offset we use for our
batches.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_exec_parse.c | 55 +++++++++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/tests/i915/gem_exec_parse.c b/tests/i915/gem_exec_parse.c
index 0c6de677e..5578340f7 100644
--- a/tests/i915/gem_exec_parse.c
+++ b/tests/i915/gem_exec_parse.c
@@ -82,8 +82,10 @@ __checked_execbuf(int i915, struct drm_i915_gem_execbuffer2 *eb)
 	return 0;
 }
 
-static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
-				     int size, int patch_offset)
+static uint64_t __exec_batch_patched(int fd,
+				     uint32_t cmd_bo, unsigned int offset,
+				     uint32_t *cmds, unsigned int size,
+				     unsigned int patch_offset)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 obj[2];
@@ -92,14 +94,14 @@ static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
 	uint32_t target_bo = gem_create(fd, 4096);
 	uint64_t actual_value = 0;
 
-	gem_write(fd, cmd_bo, 0, cmds, size);
+	gem_write(fd, cmd_bo, offset, cmds, size);
 
 	memset(obj, 0, sizeof(obj));
 	obj[0].handle = target_bo;
 	obj[1].handle = cmd_bo;
 
 	memset(reloc, 0, sizeof(reloc));
-	reloc[0].offset = patch_offset;
+	reloc[0].offset = offset + patch_offset;
 	reloc[0].target_handle = obj[0].handle;
 	reloc[0].delta = 0;
 	reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND;
@@ -110,6 +112,7 @@ static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
+	execbuf.batch_start_offset = offset;
 	execbuf.batch_len = size;
 	execbuf.flags = I915_EXEC_RENDER;
 
@@ -123,12 +126,25 @@ static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
 	return actual_value;
 }
 
-static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
-			       int size, int patch_offset,
+static void exec_batch_patched(int fd, uint32_t cmd_bo,
+			       uint32_t *cmds, unsigned int size,
+			       unsigned int patch_offset,
 			       uint64_t expected_value)
 {
-	igt_assert_eq(__exec_batch_patched(fd, cmd_bo, cmds,
-					   size, patch_offset),
+	igt_assert_eq(__exec_batch_patched(fd, cmd_bo, 0,
+					   cmds, size,
+					   patch_offset),
+		      expected_value);
+}
+
+static void exec_batch_offset(int fd, uint32_t cmd_bo, unsigned int offset,
+			      uint32_t *cmds, unsigned int size,
+			      unsigned int patch_offset,
+			      uint64_t expected_value)
+{
+	igt_assert_eq(__exec_batch_patched(fd, cmd_bo, offset,
+					   cmds, size,
+					   patch_offset),
 		      expected_value);
 }
 
@@ -408,7 +424,7 @@ static void hsw_load_register_reg(void)
 		exec_batch(fd, handle, do_lrr, sizeof(do_lrr),
 			   I915_EXEC_RENDER,
 			   0);
-		var = __exec_batch_patched(fd, handle,
+		var = __exec_batch_patched(fd, handle, 0,
 					   store_gpr0, sizeof(store_gpr0),
 					   2 * sizeof(uint32_t)); /* reloc */
 		igt_assert_neq(var, 0xabcdabc0);
@@ -471,6 +487,27 @@ igt_main
 				   0x12000000);
 	}
 
+	igt_subtest("basic-offset") {
+		uint32_t pc[] = {
+			GFX_OP_PIPE_CONTROL,
+			PIPE_CONTROL_QW_WRITE,
+			0, /* To be patched */
+			0x12000000,
+			0,
+			MI_BATCH_BUFFER_END,
+		};
+		uint32_t scrub[1024];
+
+		memset(scrub, 0xc5, sizeof(scrub));
+		for (int i = 0; i <= 4096 - sizeof(pc); i += 8) {
+			gem_write(fd, handle, 0, scrub, sizeof(scrub));
+			exec_batch_offset(fd, handle, i,
+					  pc, sizeof(pc),
+					  8, /* patch offset, */
+					  0x12000000);
+		}
+	}
+
 	igt_subtest("basic-rejected") {
 		uint32_t invalid_cmd[] = {
 			INSTR_INVALID_CLIENT << INSTR_CLIENT_SHIFT,
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] i915/gem_exec_parse: Check batch_start_offset
Date: Wed, 11 Dec 2019 16:48:38 +0000	[thread overview]
Message-ID: <20191211164838.137117-1-chris@chris-wilson.co.uk> (raw)

Validate that the cmdparser works with whatever offset we use for our
batches.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_exec_parse.c | 55 +++++++++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/tests/i915/gem_exec_parse.c b/tests/i915/gem_exec_parse.c
index 0c6de677e..5578340f7 100644
--- a/tests/i915/gem_exec_parse.c
+++ b/tests/i915/gem_exec_parse.c
@@ -82,8 +82,10 @@ __checked_execbuf(int i915, struct drm_i915_gem_execbuffer2 *eb)
 	return 0;
 }
 
-static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
-				     int size, int patch_offset)
+static uint64_t __exec_batch_patched(int fd,
+				     uint32_t cmd_bo, unsigned int offset,
+				     uint32_t *cmds, unsigned int size,
+				     unsigned int patch_offset)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 obj[2];
@@ -92,14 +94,14 @@ static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
 	uint32_t target_bo = gem_create(fd, 4096);
 	uint64_t actual_value = 0;
 
-	gem_write(fd, cmd_bo, 0, cmds, size);
+	gem_write(fd, cmd_bo, offset, cmds, size);
 
 	memset(obj, 0, sizeof(obj));
 	obj[0].handle = target_bo;
 	obj[1].handle = cmd_bo;
 
 	memset(reloc, 0, sizeof(reloc));
-	reloc[0].offset = patch_offset;
+	reloc[0].offset = offset + patch_offset;
 	reloc[0].target_handle = obj[0].handle;
 	reloc[0].delta = 0;
 	reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND;
@@ -110,6 +112,7 @@ static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
+	execbuf.batch_start_offset = offset;
 	execbuf.batch_len = size;
 	execbuf.flags = I915_EXEC_RENDER;
 
@@ -123,12 +126,25 @@ static uint64_t __exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
 	return actual_value;
 }
 
-static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds,
-			       int size, int patch_offset,
+static void exec_batch_patched(int fd, uint32_t cmd_bo,
+			       uint32_t *cmds, unsigned int size,
+			       unsigned int patch_offset,
 			       uint64_t expected_value)
 {
-	igt_assert_eq(__exec_batch_patched(fd, cmd_bo, cmds,
-					   size, patch_offset),
+	igt_assert_eq(__exec_batch_patched(fd, cmd_bo, 0,
+					   cmds, size,
+					   patch_offset),
+		      expected_value);
+}
+
+static void exec_batch_offset(int fd, uint32_t cmd_bo, unsigned int offset,
+			      uint32_t *cmds, unsigned int size,
+			      unsigned int patch_offset,
+			      uint64_t expected_value)
+{
+	igt_assert_eq(__exec_batch_patched(fd, cmd_bo, offset,
+					   cmds, size,
+					   patch_offset),
 		      expected_value);
 }
 
@@ -408,7 +424,7 @@ static void hsw_load_register_reg(void)
 		exec_batch(fd, handle, do_lrr, sizeof(do_lrr),
 			   I915_EXEC_RENDER,
 			   0);
-		var = __exec_batch_patched(fd, handle,
+		var = __exec_batch_patched(fd, handle, 0,
 					   store_gpr0, sizeof(store_gpr0),
 					   2 * sizeof(uint32_t)); /* reloc */
 		igt_assert_neq(var, 0xabcdabc0);
@@ -471,6 +487,27 @@ igt_main
 				   0x12000000);
 	}
 
+	igt_subtest("basic-offset") {
+		uint32_t pc[] = {
+			GFX_OP_PIPE_CONTROL,
+			PIPE_CONTROL_QW_WRITE,
+			0, /* To be patched */
+			0x12000000,
+			0,
+			MI_BATCH_BUFFER_END,
+		};
+		uint32_t scrub[1024];
+
+		memset(scrub, 0xc5, sizeof(scrub));
+		for (int i = 0; i <= 4096 - sizeof(pc); i += 8) {
+			gem_write(fd, handle, 0, scrub, sizeof(scrub));
+			exec_batch_offset(fd, handle, i,
+					  pc, sizeof(pc),
+					  8, /* patch offset, */
+					  0x12000000);
+		}
+	}
+
 	igt_subtest("basic-rejected") {
 		uint32_t invalid_cmd[] = {
 			INSTR_INVALID_CLIENT << INSTR_CLIENT_SHIFT,
-- 
2.24.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-12-11 16:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11 16:48 Chris Wilson [this message]
2019-12-11 16:48 ` [igt-dev] [PATCH i-g-t] i915/gem_exec_parse: Check batch_start_offset Chris Wilson
2019-12-11 17:52 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-12-12  2:55 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-12-12  8:11 ` [igt-dev] ✗ GitLab.Pipeline: failure " Patchwork

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=20191211164838.137117-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.