All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v7 24/54] tests/gem_exec_whisper: Adopt to use allocator
Date: Tue, 10 Aug 2021 12:52:53 +0200	[thread overview]
Message-ID: <20210810105323.31375-25-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20210810105323.31375-1-zbigniew.kempczynski@intel.com>

For newer gens we're not able to rely on relocations. Adopt to use
offsets acquired from the allocator.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 tests/i915/gem_exec_whisper.c | 39 ++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/tests/i915/gem_exec_whisper.c b/tests/i915/gem_exec_whisper.c
index d16409203..104f0a160 100644
--- a/tests/i915/gem_exec_whisper.c
+++ b/tests/i915/gem_exec_whisper.c
@@ -89,6 +89,8 @@ struct hang {
 	struct drm_i915_gem_relocation_entry reloc;
 	struct drm_i915_gem_execbuffer2 execbuf;
 	int fd;
+	uint64_t ahnd;
+	uint64_t bb_offset;
 };
 
 static void init_hang(struct hang *h, int fd, const intel_ctx_cfg_t *cfg)
@@ -104,8 +106,10 @@ static void init_hang(struct hang *h, int fd, const intel_ctx_cfg_t *cfg)
 	if (gem_has_contexts(fd)) {
 		h->ctx = intel_ctx_create(h->fd, cfg);
 		h->execbuf.rsvd1 = h->ctx->id;
+		h->ahnd = get_reloc_ahnd(fd, h->ctx->id);
 	} else {
 		h->ctx = NULL;
+		h->ahnd = get_reloc_ahnd(fd, 0);
 	}
 
 	memset(&h->execbuf, 0, sizeof(h->execbuf));
@@ -114,9 +118,12 @@ static void init_hang(struct hang *h, int fd, const intel_ctx_cfg_t *cfg)
 
 	memset(&h->obj, 0, sizeof(h->obj));
 	h->obj.handle = gem_create(h->fd, 4096);
+	h->bb_offset = get_offset(h->ahnd, h->obj.handle, 4096, 0);
+	if (h->ahnd)
+		h->obj.flags |= EXEC_OBJECT_PINNED;
 
 	h->obj.relocs_ptr = to_user_pointer(&h->reloc);
-	h->obj.relocation_count = 1;
+	h->obj.relocation_count = !h->ahnd ? 1 : 0;
 	memset(&h->reloc, 0, sizeof(h->reloc));
 
 	batch = gem_mmap__cpu(h->fd, h->obj.handle, 0, 4096, PROT_WRITE);
@@ -138,8 +145,8 @@ static void init_hang(struct hang *h, int fd, const intel_ctx_cfg_t *cfg)
 	batch[i] = MI_BATCH_BUFFER_START;
 	if (gen >= 8) {
 		batch[i] |= 1 << 8 | 1;
-		batch[++i] = 0;
-		batch[++i] = 0;
+		batch[++i] = h->bb_offset;
+		batch[++i] = h->bb_offset >> 32;
 	} else if (gen >= 6) {
 		batch[i] |= 1 << 8;
 		batch[++i] = 0;
@@ -167,6 +174,8 @@ static void submit_hang(struct hang *h, unsigned *engines, int nengine, unsigned
 
 static void fini_hang(struct hang *h)
 {
+	put_offset(h->ahnd, h->bb_offset);
+	put_ahnd(h->ahnd);
 	intel_ctx_destroy(h->fd, h->ctx);
 	close(h->fd);
 }
@@ -206,6 +215,7 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 	int i, n, loc;
 	int debugfs;
 	int nchild;
+	bool has_relocs = gem_has_relocations(fd);
 
 	if (flags & PRIORITY) {
 		igt_require(gem_scheduler_enabled(fd));
@@ -264,7 +274,7 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 		memset(&store, 0, sizeof(store));
 		store.handle = gem_create(fd, 4096);
 		store.relocs_ptr = to_user_pointer(&reloc);
-		store.relocation_count = 1;
+		store.relocation_count = has_relocs ? 1 : 0;
 
 		memset(&reloc, 0, sizeof(reloc));
 		reloc.offset = sizeof(uint32_t);
@@ -288,12 +298,18 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 			execbuf.flags |= I915_EXEC_NO_RELOC;
 			if (gen < 6)
 				execbuf.flags |= I915_EXEC_SECURE;
+
 			execbuf.rsvd1 = ctx->id;
 			igt_require(__gem_execbuf(fd, &execbuf) == 0);
 			scratch = tmp[0];
 			store = tmp[1];
 		}
 
+		if (!has_relocs) {
+			scratch.flags |= EXEC_OBJECT_PINNED;
+			store.flags |= EXEC_OBJECT_PINNED;
+		}
+
 		i = 0;
 		batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
 		if (gen >= 8) {
@@ -355,7 +371,9 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 			inter[n].presumed_offset = old_offset;
 			inter[n].delta = loc;
 			batches[n].relocs_ptr = to_user_pointer(&inter[n]);
-			batches[n].relocation_count = 1;
+			batches[n].relocation_count = has_relocs ? 1 : 0;
+			if (!has_relocs)
+				batches[n].flags |= EXEC_OBJECT_PINNED;
 			gem_write(fd, batches[n].handle, 0, batch, sizeof(batch));
 
 			old_offset = batches[n].offset;
@@ -396,7 +414,9 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 				tmp[1] = store;
 				verify_reloc(fd, store.handle, &reloc);
 				execbuf.buffers_ptr = to_user_pointer(tmp);
+
 				gem_execbuf(fd, &execbuf);
+
 				igt_assert_eq_u64(reloc.presumed_offset, tmp[0].offset);
 				if (flags & SYNC)
 					gem_sync(fd, tmp[0].handle);
@@ -450,7 +470,7 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 						gem_sync(this_fd, batches[n-1].handle);
 					relocations += inter[n].presumed_offset != old_offset;
 
-					batches[n-1].relocation_count = 1;
+					batches[n-1].relocation_count = has_relocs ? 1 : 0;
 					batches[n-1].flags &= ~EXEC_OBJECT_WRITE;
 
 					if (this_fd != fd) {
@@ -468,6 +488,8 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 				tmp[0] = tmp[1];
 				tmp[0].relocation_count = 0;
 				tmp[0].flags = EXEC_OBJECT_WRITE;
+				if (!has_relocs)
+					tmp[0].flags |= EXEC_OBJECT_PINNED;
 				reloc_migrations += tmp[0].offset != inter[0].presumed_offset;
 				tmp[0].offset = inter[0].presumed_offset;
 				old_offset = tmp[0].offset;
@@ -478,6 +500,7 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 					reloc_interruptions++;
 					inter[0].presumed_offset = tmp[0].offset;
 				}
+
 				igt_assert_eq_u64(inter[0].presumed_offset, tmp[0].offset);
 				relocations += inter[0].presumed_offset != old_offset;
 				batches[0] = tmp[1];
@@ -487,7 +510,7 @@ static void whisper(int fd, const intel_ctx_t *ctx,
 				igt_assert(tmp[0].flags & EXEC_OBJECT_WRITE);
 				igt_assert_eq_u64(reloc.presumed_offset, tmp[0].offset);
 				igt_assert(tmp[1].relocs_ptr == to_user_pointer(&reloc));
-				tmp[1].relocation_count = 1;
+				tmp[1].relocation_count = has_relocs ? 1 : 0;
 				tmp[1].flags &= ~EXEC_OBJECT_WRITE;
 				verify_reloc(fd, store.handle, &reloc);
 				gem_execbuf(fd, &execbuf);
@@ -591,6 +614,7 @@ igt_main
 		ctx = intel_ctx_create_all_physical(fd);
 
 		igt_fork_hang_detector(fd);
+		intel_allocator_multiprocess_start();
 	}
 
 	for (const struct mode *m = modes; m->name; m++) {
@@ -631,6 +655,7 @@ igt_main
 	}
 
 	igt_fixture {
+		intel_allocator_multiprocess_stop();
 		intel_ctx_destroy(fd, ctx);
 		close(fd);
 	}
-- 
2.26.0

  parent reply	other threads:[~2021-08-10 10:54 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 10:52 [igt-dev] [PATCH i-g-t v7 00/54] Add allocator support in IGT Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 01/54] lib/igt_dummyload: Add support of using allocator in igt spinner Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 02/54] lib/intel_allocator: Add few helper functions for common use Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 03/54] lib/igt_gt: Add passing ahnd as an argument to igt_hang Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 04/54] lib/intel_batchbuffer: Ensure relocation code will be called Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 05/54] lib/intel_batchbuffer: Add allocator support in blitter fast copy Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 06/54] lib/intel_batchbuffer: Add allocator support in blitter src copy Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 07/54] lib/intel_batchbuffer: Try to avoid relocations in blitting Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 08/54] lib/huc_copy: Extend huc copy prototype to pass allocator handle Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 09/54] tests/gem_busy: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 10/54] tests/gem_create: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 11/54] tests/gem_ctx_engines: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 12/54] tests/gem_ctx_exec: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 13/54] tests/gem_ctx_freq: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 14/54] tests/gem_ctx_isolation: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 15/54] tests/gem_ctx_param: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 16/54] tests/gem_eio: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 17/54] tests/gem_exec_async: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 18/54] tests/gem_exec_fair: Add softpin support Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 19/54] tests/gem_exec_gttfill: Require relocation support Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 20/54] tests/gem_exec_lut_handle: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 21/54] tests/gem_exec_suspend: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 22/54] tests/gem_exec_parallel: Adopt to use alloctor Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 23/54] tests/gem_exec_params: Support gens without relocations Zbigniew Kempczyński
2021-08-10 10:52 ` Zbigniew Kempczyński [this message]
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 25/54] tests/gem_fenced_exec_thrash: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 26/54] tests/gem_lut_handle: Require relocation support Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 27/54] tests/gem_mmap: Add allocator support Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 28/54] tests/gem_mmap_gtt: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 29/54] tests/gem_mmap_offset: " Zbigniew Kempczyński
2021-08-10 10:52 ` [igt-dev] [PATCH i-g-t v7 30/54] tests/gem_mmap_wc: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 31/54] tests/gem_request_retire: Add allocator support Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 32/54] tests/gem_ringfill: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 33/54] tests/gem_spin_batch: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 34/54] tests/gem_tiled_fence_blits: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 35/54] tests/gem_unfence_active_buffers: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 36/54] tests/gem_unref_active_buffers: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 37/54] tests/gem_userptr_blits: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 38/54] tests/gem_wait: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 39/54] tests/gem_watchdog: Adopt to use no-reloc Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 40/54] tests/gem_workarounds: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 41/54] tests/i915_hangman: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 42/54] tests/i915_module_load: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 43/54] tests/i915_pm_rc6_residency: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 44/54] tests/i915_pm_rpm: Adopt to use no-reloc Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 45/54] tests/i915_pm_rps: Alter " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 46/54] tests/kms_busy: Adopt to use allocator Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 47/54] tests/kms_cursor_legacy: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 48/54] tests/kms_flip: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 49/54] tests/kms_vblank: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 50/54] tests/perf_pmu: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 51/54] tests/sysfs_heartbeat_interval: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 52/54] tests/sysfs_preempt_timeout: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 53/54] tests/sysfs_timeslice_duration: " Zbigniew Kempczyński
2021-08-10 10:53 ` [igt-dev] [PATCH i-g-t v7 54/54] HAX: remove gttfill for tgl ci Zbigniew Kempczyński
2021-08-10 11:53 ` [igt-dev] ✓ Fi.CI.BAT: success for Add allocator support in IGT Patchwork
2021-08-10 15:42 ` [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=20210810105323.31375-25-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@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 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.