All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>,
	Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t v3 01/52] lib/igt_dummyload: Add support of using allocator in igt spinner
Date: Mon, 26 Jul 2021 21:59:35 +0200	[thread overview]
Message-ID: <20210726200026.4815-2-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20210726200026.4815-1-zbigniew.kempczynski@intel.com>

For gens without relocations we need to use softpin with valid offsets
which do not overlap other execbuf objects. As spinner during creation
knows nothing about vm it has to run into allocator handle must be
passed to properly acquire offsets from allocator instance.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_dummyload.c | 74 ++++++++++++++++++++++++++++++++++++---------
 lib/igt_dummyload.h |  3 ++
 2 files changed, 63 insertions(+), 14 deletions(-)

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index 8a5ad5ee3..645db9222 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -35,6 +35,7 @@
 #include "i915/gem_engine_topology.h"
 #include "i915/gem_mman.h"
 #include "i915/gem_submission.h"
+#include "igt_aux.h"
 #include "igt_core.h"
 #include "igt_device.h"
 #include "igt_dummyload.h"
@@ -101,7 +102,7 @@ emit_recursive_batch(igt_spin_t *spin,
 	unsigned int flags[GEM_MAX_ENGINES];
 	unsigned int nengine;
 	int fence_fd = -1;
-	uint64_t addr;
+	uint64_t addr, addr_scratch, ahnd = opts->ahnd, objflags = 0;
 	uint32_t *cs;
 	int i;
 
@@ -119,11 +120,17 @@ emit_recursive_batch(igt_spin_t *spin,
 	 * are not allowed in the first 256KiB, for fear of negative relocations
 	 * that wrap.
 	 */
-	addr = gem_aperture_size(fd) / 2;
-	if (addr >> 31)
-		addr = 1u << 31;
-	addr += random() % addr / 2;
-	addr &= -4096;
+
+	if (!ahnd) {
+		addr = gem_aperture_size(fd) / 2;
+		if (addr >> 31)
+			addr = 1u << 31;
+		addr += random() % addr / 2;
+		addr &= -4096;
+	} else {
+		spin->ahnd = ahnd;
+		objflags |= EXEC_OBJECT_PINNED;
+	}
 
 	igt_assert(!(opts->ctx && opts->ctx_id));
 
@@ -164,16 +171,34 @@ emit_recursive_batch(igt_spin_t *spin,
 	execbuf->buffer_count++;
 	cs = spin->batch;
 
-	obj[BATCH].offset = addr;
+	if (ahnd)
+		addr = intel_allocator_alloc_with_strategy(ahnd, obj[BATCH].handle,
+							   BATCH_SIZE, 0,
+							   ALLOC_STRATEGY_LOW_TO_HIGH);
+	obj[BATCH].offset = CANONICAL(addr);
+	obj[BATCH].flags |= objflags;
+	if (obj[BATCH].offset >= (1ull << 32))
+		obj[BATCH].flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+
 	addr += BATCH_SIZE;
 
 	if (opts->dependency) {
 		igt_assert(!(opts->flags & IGT_SPIN_POLL_RUN));
+		if (ahnd)
+			addr_scratch = intel_allocator_alloc_with_strategy(ahnd, opts->dependency,
+									   BATCH_SIZE, 0,
+									   ALLOC_STRATEGY_LOW_TO_HIGH);
+		else
+			addr_scratch = addr;
 
 		obj[SCRATCH].handle = opts->dependency;
-		obj[SCRATCH].offset = addr;
+		obj[SCRATCH].offset = CANONICAL(addr_scratch);
+		obj[SCRATCH].flags |= objflags;
+		if (obj[SCRATCH].offset >= (1ull << 32))
+			obj[SCRATCH].flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+
 		if (!(opts->flags & IGT_SPIN_SOFTDEP)) {
-			obj[SCRATCH].flags = EXEC_OBJECT_WRITE;
+			obj[SCRATCH].flags |= EXEC_OBJECT_WRITE;
 
 			/* dummy write to dependency */
 			r = &relocs[obj[BATCH].relocation_count++];
@@ -212,8 +237,14 @@ emit_recursive_batch(igt_spin_t *spin,
 								       0, 4096,
 								       PROT_READ | PROT_WRITE);
 		}
+
+		if (ahnd)
+			addr = intel_allocator_alloc_with_strategy(ahnd,
+								   spin->poll_handle,
+								   BATCH_SIZE * 3, 0,
+								   ALLOC_STRATEGY_LOW_TO_HIGH);
 		addr += 4096; /* guard page */
-		obj[SCRATCH].offset = addr;
+		obj[SCRATCH].offset = CANONICAL(addr);
 		addr += 4096;
 
 		igt_assert_eq(spin->poll[SPIN_POLL_START_IDX], 0);
@@ -223,11 +254,15 @@ emit_recursive_batch(igt_spin_t *spin,
 		r->offset = sizeof(uint32_t) * 1;
 		r->delta = sizeof(uint32_t) * SPIN_POLL_START_IDX;
 
+		obj[SCRATCH].flags |= objflags;
+		if (obj[SCRATCH].offset >= (1ull << 32))
+			obj[SCRATCH].flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+
 		*cs++ = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
 
 		if (gen >= 8) {
 			*cs++ = r->presumed_offset + r->delta;
-			*cs++ = 0;
+			*cs++ = (r->presumed_offset + r->delta) >> 32;
 		} else if (gen >= 4) {
 			*cs++ = 0;
 			*cs++ = r->presumed_offset + r->delta;
@@ -314,10 +349,11 @@ emit_recursive_batch(igt_spin_t *spin,
 	r->offset = (cs + 1 - spin->batch) * sizeof(*cs);
 	r->read_domains = I915_GEM_DOMAIN_COMMAND;
 	r->delta = LOOP_START_OFFSET;
+
 	if (gen >= 8) {
 		*cs++ = MI_BATCH_BUFFER_START | 1 << 8 | 1;
 		*cs++ = r->presumed_offset + r->delta;
-		*cs++ = 0;
+		*cs++ = (r->presumed_offset + r->delta) >> 32;
 	} else if (gen >= 6) {
 		*cs++ = MI_BATCH_BUFFER_START | 1 << 8;
 		*cs++ = r->presumed_offset + r->delta;
@@ -351,6 +387,10 @@ emit_recursive_batch(igt_spin_t *spin,
 		execbuf->flags &= ~ENGINE_MASK;
 		execbuf->flags |= flags[i];
 
+		/* For allocator we have to rid of relocation_count */
+		for (int j = 0; j < ARRAY_SIZE(spin->obj) && ahnd; j++)
+			spin->obj[j].relocation_count = 0;
+
 		gem_execbuf_wr(fd, execbuf);
 
 		if (opts->flags & IGT_SPIN_FENCE_OUT) {
@@ -569,11 +609,17 @@ static void __igt_spin_free(int fd, igt_spin_t *spin)
 	if (spin->batch)
 		gem_munmap(spin->batch, BATCH_SIZE);
 
-	if (spin->poll_handle)
+	if (spin->poll_handle) {
 		gem_close(fd, spin->poll_handle);
+		if (spin->ahnd)
+			intel_allocator_free(spin->ahnd, spin->poll_handle);
+	}
 
-	if (spin->handle)
+	if (spin->handle) {
 		gem_close(fd, spin->handle);
+		if (spin->ahnd)
+			intel_allocator_free(spin->ahnd, spin->handle);
+	}
 
 	if (spin->out_fence >= 0)
 		close(spin->out_fence);
diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h
index 67e1a08ed..f02052614 100644
--- a/lib/igt_dummyload.h
+++ b/lib/igt_dummyload.h
@@ -58,6 +58,8 @@ typedef struct igt_spin {
 
 	unsigned int flags;
 #define SPIN_CLFLUSH (1 << 0)
+
+	uint64_t ahnd;
 } igt_spin_t;
 
 /**
@@ -78,6 +80,7 @@ typedef struct igt_spin_factory {
 	unsigned int engine;
 	unsigned int flags;
 	int fence;
+	uint64_t ahnd;
 } igt_spin_factory_t;
 
 #define IGT_SPIN_FENCE_IN      (1 << 0)
-- 
2.26.0

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

  reply	other threads:[~2021-07-26 20:00 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 19:59 [igt-dev] [PATCH i-g-t v3 00/52] Add allocator support in IGT Zbigniew Kempczyński
2021-07-26 19:59 ` Zbigniew Kempczyński [this message]
2021-08-03 23:07   ` [igt-dev] [PATCH i-g-t v3 01/52] lib/igt_dummyload: Add support of using allocator in igt spinner Dixit, Ashutosh
2021-08-04  6:19     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 02/52] lib/intel_allocator: Add few helper functions for common use Zbigniew Kempczyński
2021-08-03 21:01   ` Dixit, Ashutosh
2021-08-04  0:18     ` Dixit, Ashutosh
2021-08-04  6:13       ` Zbigniew Kempczyński
2021-08-05 18:53         ` Dixit, Ashutosh
2021-08-06  1:15           ` Dixit, Ashutosh
2021-08-06  5:51             ` Zbigniew Kempczyński
2021-08-06  5:35           ` Zbigniew Kempczyński
2021-08-06  5:52             ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 03/52] lib/igt_gt: Add passing ahnd as an argument to igt_hang Zbigniew Kempczyński
2021-08-03 23:15   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 04/52] lib/intel_batchbuffer: Ensure relocation code will be called Zbigniew Kempczyński
2021-08-03 23:34   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 05/52] lib/intel_batchbuffer: Add allocator support in blitter fast copy Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 06/52] lib/intel_batchbuffer: Add allocator support in blitter src copy Zbigniew Kempczyński
2021-08-04 23:26   ` Dixit, Ashutosh
2021-08-04 23:44     ` Dixit, Ashutosh
2021-08-05  8:50       ` Zbigniew Kempczyński
2021-08-05  7:28     ` Zbigniew Kempczyński
2021-08-05 19:47       ` Dixit, Ashutosh
2021-08-06  6:17         ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 07/52] lib/intel_batchbuffer: Try to avoid relocations in blitting Zbigniew Kempczyński
2021-08-04 23:42   ` Dixit, Ashutosh
2021-08-05  7:34     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 08/52] lib/huc_copy: Extend huc copy prototype to pass allocator handle Zbigniew Kempczyński
2021-08-05  0:31   ` Dixit, Ashutosh
2021-08-05  7:44     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 09/52] tests/gem_bad_reloc: Skip on gens where relocations are not supported Zbigniew Kempczyński
2021-08-05  0:33   ` Dixit, Ashutosh
2021-08-05  7:46     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 10/52] tests/gem_busy: Adopt to use allocator Zbigniew Kempczyński
2021-08-05  2:07   ` Dixit, Ashutosh
2021-08-05  8:02     ` Zbigniew Kempczyński
2021-08-05 21:14       ` Dixit, Ashutosh
2021-08-06  6:56         ` Zbigniew Kempczyński
2021-08-05  8:14     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 11/52] tests/gem_create: " Zbigniew Kempczyński
2021-08-05  2:14   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 12/52] tests/gem_ctx_engines: " Zbigniew Kempczyński
2021-08-05  2:40   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 13/52] tests/gem_ctx_exec: " Zbigniew Kempczyński
2021-08-05  3:06   ` Dixit, Ashutosh
2021-08-05  8:46     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 14/52] tests/gem_ctx_freq: " Zbigniew Kempczyński
2021-08-05  6:07   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 15/52] tests/gem_ctx_isolation: " Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 16/52] tests/gem_ctx_param: " Zbigniew Kempczyński
2021-08-05  7:18   ` Dixit, Ashutosh
2021-08-05 10:19     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 17/52] tests/gem_eio: " Zbigniew Kempczyński
2021-08-05 21:44   ` Dixit, Ashutosh
2021-08-06  7:16     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 18/52] tests/gem_exec_async: " Zbigniew Kempczyński
2021-08-06  1:43   ` Dixit, Ashutosh
2021-08-06  7:33     ` Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 19/52] tests/gem_exec_big: Require relocation support Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 20/52] tests/gem_exec_capture: Support gens without relocations Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 21/52] tests/gem_exec_gttfill: Require relocation support Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 22/52] tests/gem_exec_store: Support gens without relocations Zbigniew Kempczyński
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 23/52] tests/gem_exec_suspend: Adopt to use allocator Zbigniew Kempczyński
2021-08-06  2:15   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 24/52] tests/gem_exec_parallel: Adopt to use alloctor Zbigniew Kempczyński
2021-08-06  4:39   ` Dixit, Ashutosh
2021-07-26 19:59 ` [igt-dev] [PATCH i-g-t v3 25/52] tests/gem_exec_params: Support gens without relocations Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 26/52] tests/gem_mmap: Add allocator support Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 27/52] tests/gem_mmap_gtt: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 28/52] tests/gem_mmap_offset: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 29/52] tests/gem_mmap_wc: Adopt to use allocator Zbigniew Kempczyński
2021-08-06  4:51   ` Dixit, Ashutosh
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 30/52] tests/gem_request_retire: Add allocator support Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 31/52] tests/gem_ringfill: Adopt to use allocator Zbigniew Kempczyński
2021-08-06  5:04   ` Dixit, Ashutosh
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 32/52] tests/gem_softpin: Exercise eviction with softpinning Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 33/52] tests/gem_spin_batch: Adopt to use allocator Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 34/52] tests/gem_tiled_fence_blits: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 35/52] tests/gem_unfence_active_buffers: " Zbigniew Kempczyński
2021-08-06  5:44   ` Dixit, Ashutosh
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 36/52] tests/gem_unref_active_buffers: " Zbigniew Kempczyński
2021-08-06  5:46   ` Dixit, Ashutosh
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 37/52] tests/gem_wait: " Zbigniew Kempczyński
2021-08-06  5:48   ` Dixit, Ashutosh
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 38/52] tests/gem_watchdog: Adopt to use no-reloc Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 39/52] tests/gem_workarounds: Adopt to use allocator Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 40/52] tests/i915_hangman: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 41/52] tests/i915_module_load: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 42/52] tests/i915_pm_rc6_residency: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 43/52] tests/i915_pm_rpm: Adopt to use no-reloc Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 44/52] tests/i915_pm_rps: Alter " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 45/52] tests/kms_busy: Adopt to use allocator Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 46/52] tests/kms_cursor_legacy: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 47/52] tests/kms_flip: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 48/52] tests/kms_vblank: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 49/52] tests/perf_pmu: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 50/52] tests/sysfs_heartbeat_interval: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 51/52] tests/sysfs_preempt_timeout: " Zbigniew Kempczyński
2021-07-26 20:00 ` [igt-dev] [PATCH i-g-t v3 52/52] tests/sysfs_timeslice_duration: " Zbigniew Kempczyński
2021-07-26 21:33 ` [igt-dev] ✓ Fi.CI.BAT: success for Add allocator support in IGT (rev3) Patchwork
2021-07-27  2:14 ` [igt-dev] ✗ Fi.CI.IGT: 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=20210726200026.4815-2-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /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.