public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib/dummyload: Cleanup access to spin obj array
Date: Wed, 22 May 2019 12:46:52 +0300	[thread overview]
Message-ID: <20190522094652.17269-1-mika.kuoppala@linux.intel.com> (raw)
In-Reply-To: <155851788398.23981.2076407745257565334@skylake-alporthouse-com>

Instead of relying a static obj array inside igt_spin_t,
access it with proper indexing.

v2: IGT_SPIN_BATCH
v3: indent

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_dummyload.c            | 13 ++++++-------
 lib/igt_dummyload.h            |  1 +
 tests/i915/gem_exec_schedule.c | 23 +++++++++++++----------
 tests/i915/gem_softpin.c       |  2 +-
 tests/i915/gem_spin_batch.c    |  4 ++--
 tests/i915/i915_hangman.c      |  2 +-
 6 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 15d64fad..e6e366cb 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -72,7 +72,7 @@ emit_recursive_batch(igt_spin_t *spin,
 		     int fd, const struct igt_spin_factory *opts)
 {
 #define SCRATCH 0
-#define BATCH 1
+#define BATCH IGT_SPIN_BATCH
 	const int gen = intel_gen(intel_get_drm_devid(fd));
 	struct drm_i915_gem_relocation_entry relocs[2], *r;
 	struct drm_i915_gem_execbuffer2 *execbuf;
@@ -261,12 +261,11 @@ emit_recursive_batch(igt_spin_t *spin,
 	igt_assert_lt(cs - batch, BATCH_SIZE / sizeof(*cs));
 
 	/* Make it easier for callers to resubmit. */
-
-	obj[BATCH].relocation_count = 0;
-	obj[BATCH].relocs_ptr = 0;
-
-	obj[SCRATCH].flags = EXEC_OBJECT_PINNED;
-	obj[BATCH].flags = EXEC_OBJECT_PINNED;
+	for (i = 0; i < ARRAY_SIZE(spin->obj); i++) {
+		spin->obj[i].relocation_count = 0;
+		spin->obj[i].relocs_ptr = 0;
+		spin->obj[i].flags = EXEC_OBJECT_PINNED;
+	}
 
 	spin->cmd_precondition = *spin->condition;
 
diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h
index 61a9f2fc..bb361842 100644
--- a/lib/igt_dummyload.h
+++ b/lib/igt_dummyload.h
@@ -42,6 +42,7 @@ typedef struct igt_spin {
 
 	int out_fence;
 	struct drm_i915_gem_exec_object2 obj[2];
+#define IGT_SPIN_BATCH   1
 	struct drm_i915_gem_execbuffer2 execbuf;
 	uint32_t poll_handle;
 	uint32_t *poll;
diff --git a/tests/i915/gem_exec_schedule.c b/tests/i915/gem_exec_schedule.c
index c0438513..7b418622 100644
--- a/tests/i915/gem_exec_schedule.c
+++ b/tests/i915/gem_exec_schedule.c
@@ -234,7 +234,7 @@ static void independent(int fd, unsigned int engine)
 		} else {
 			struct drm_i915_gem_execbuffer2 eb = {
 				.buffer_count = 1,
-				.buffers_ptr = to_user_pointer(&spin->obj[1]),
+				.buffers_ptr = to_user_pointer(&spin->obj[IGT_SPIN_BATCH]),
 				.flags = other,
 			};
 			gem_execbuf(fd, &eb);
@@ -537,7 +537,8 @@ static void semaphore_resolve(int i915)
 
 		/* Then cancel the spinner */
 		*cs++ = MI_STORE_DWORD_IMM;
-		*cs++ = spin->obj[1].offset + offset_in_page(spin->condition);
+		*cs++ = spin->obj[IGT_SPIN_BATCH].offset +
+			offset_in_page(spin->condition);
 		*cs++ = 0;
 		*cs++ = MI_BATCH_BUFFER_END;
 
@@ -548,7 +549,7 @@ static void semaphore_resolve(int i915)
 
 		/* First up is our spinning semaphore */
 		memset(obj, 0, sizeof(obj));
-		obj[0] = spin->obj[1];
+		obj[0] = spin->obj[IGT_SPIN_BATCH];
 		obj[1].handle = semaphore;
 		obj[1].offset = SEMAPHORE_ADDR;
 		obj[1].flags = EXEC_OBJECT_PINNED;
@@ -562,7 +563,7 @@ static void semaphore_resolve(int i915)
 		memset(obj, 0, sizeof(obj));
 		obj[0].handle = handle;
 		obj[0].flags = EXEC_OBJECT_WRITE; /* always after semaphore */
-		obj[1] = spin->obj[1];
+		obj[1] = spin->obj[IGT_SPIN_BATCH];
 		eb.buffer_count = 2;
 		eb.rsvd1 = 0;
 		gem_execbuf(i915, &eb);
@@ -638,11 +639,13 @@ static void semaphore_noskip(int i915)
 		/* Cancel the following spinner */
 		*cs++ = MI_STORE_DWORD_IMM;
 		if (gen >= 8) {
-			*cs++ = spin->obj[1].offset + offset_in_page(spin->condition);
+			*cs++ = spin->obj[IGT_SPIN_BATCH].offset +
+				offset_in_page(spin->condition);
 			*cs++ = 0;
 		} else {
 			*cs++ = 0;
-			*cs++ = spin->obj[1].offset + offset_in_page(spin->condition);
+			*cs++ = spin->obj[IGT_SPIN_BATCH].offset +
+				offset_in_page(spin->condition);
 		}
 		*cs++ = MI_BATCH_BUFFER_END;
 
@@ -651,9 +654,9 @@ static void semaphore_noskip(int i915)
 
 		/* port0: implicit semaphore from engine */
 		memset(obj, 0, sizeof(obj));
-		obj[0] = chain->obj[1];
+		obj[0] = chain->obj[IGT_SPIN_BATCH];
 		obj[0].flags |= EXEC_OBJECT_WRITE;
-		obj[1] = spin->obj[1];
+		obj[1] = spin->obj[IGT_SPIN_BATCH];
 		obj[2].handle = handle;
 		memset(&eb, 0, sizeof(eb));
 		eb.buffer_count = 3;
@@ -666,7 +669,7 @@ static void semaphore_noskip(int i915)
 		memset(obj, 0, sizeof(obj));
 		obj[0].handle = handle;
 		obj[0].flags = EXEC_OBJECT_WRITE;
-		obj[1] = spin->obj[1];
+		obj[1] = spin->obj[IGT_SPIN_BATCH];
 		memset(&eb, 0, sizeof(eb));
 		eb.buffer_count = 2;
 		eb.buffers_ptr = to_user_pointer(obj);
@@ -842,7 +845,7 @@ static igt_spin_t *__noise(int fd, uint32_t ctx, int prio, igt_spin_t *spin)
 		} else {
 			struct drm_i915_gem_execbuffer2 eb = {
 				.buffer_count = 1,
-				.buffers_ptr = to_user_pointer(&spin->obj[1]),
+				.buffers_ptr = to_user_pointer(&spin->obj[IGT_SPIN_BATCH]),
 				.rsvd1 = ctx,
 				.flags = other,
 			};
diff --git a/tests/i915/gem_softpin.c b/tests/i915/gem_softpin.c
index 336008b8..42650e04 100644
--- a/tests/i915/gem_softpin.c
+++ b/tests/i915/gem_softpin.c
@@ -360,7 +360,7 @@ static void test_evict_hang(int fd)
 	execbuf.buffer_count = 1;
 
 	hang = igt_hang_ctx(fd, 0, 0, 0);
-	expected = hang.spin->obj[1].offset;
+	expected = hang.spin->obj[IGT_SPIN_BATCH].offset;
 
 	/* Replace the hung batch with ourselves, forcing an eviction */
 	object.offset = expected;
diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c
index a92672b8..3b4f9073 100644
--- a/tests/i915/gem_spin_batch.c
+++ b/tests/i915/gem_spin_batch.c
@@ -79,7 +79,7 @@ static void spin_resubmit(int fd, unsigned int engine, unsigned int flags)
 
 	struct drm_i915_gem_execbuffer2 eb = {
 		.buffer_count = 1,
-		.buffers_ptr = to_user_pointer(&spin->obj[1]),
+		.buffers_ptr = to_user_pointer(&spin->obj[IGT_SPIN_BATCH]),
 		.rsvd1 = ctx1,
 	};
 
@@ -98,7 +98,7 @@ static void spin_resubmit(int fd, unsigned int engine, unsigned int flags)
 
 	igt_spin_end(spin);
 
-	gem_sync(fd, spin->obj[1].handle);
+	gem_sync(fd, spin->handle);
 
 	igt_spin_free(fd, spin);
 
diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
index 9a1d5889..51b3b700 100644
--- a/tests/i915/i915_hangman.c
+++ b/tests/i915/i915_hangman.c
@@ -209,7 +209,7 @@ static void test_error_state_capture(unsigned ring_id,
 	clear_error_state();
 
 	hang = igt_hang_ctx(device, 0, ring_id, HANG_ALLOW_CAPTURE);
-	offset = hang.spin->obj[1].offset;
+	offset = hang.spin->obj[IGT_SPIN_BATCH].offset;
 
 	batch = gem_mmap__cpu(device, hang.spin->handle, 0, 4096, PROT_READ);
 	gem_set_domain(device, hang.spin->handle, I915_GEM_DOMAIN_CPU, 0);
-- 
2.17.1

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

  reply	other threads:[~2019-05-22  9:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  9:13 [igt-dev] [PATCH i-g-t] lib/dummyload: Cleanup access to spin obj array Mika Kuoppala
2019-05-22  9:18 ` Chris Wilson
2019-05-22  9:34   ` Mika Kuoppala
2019-05-22  9:38     ` Chris Wilson
2019-05-22  9:46       ` Mika Kuoppala [this message]
2019-05-23  8:59       ` Mika Kuoppala
2019-05-22 10:52 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/dummyload: Cleanup access to spin obj array (rev3) Patchwork
2019-05-23  2:01 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20190522094652.17269-1-mika.kuoppala@linux.intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox