All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] tests/i915_module_load: obj size based on the engine count
@ 2021-02-05  9:07 Ramalingam C
  2021-02-05  9:53 ` Chris Wilson
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ramalingam C @ 2021-02-05  9:07 UTC (permalink / raw)
  To: igt-dev; +Cc: Chris wilson

Calculate obj size for the sanity check of module reload
based on the engines count.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
CC: Chris wilson <chris.p.wilson@intel.com>
---
 tests/i915/i915_module_load.c | 37 +++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index 06522ba6191b..00494bcb3480 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -46,7 +46,7 @@ static void store_all(int fd)
 	struct drm_i915_gem_relocation_entry reloc[2 * ARRAY_SIZE(engines)];
 	struct drm_i915_gem_execbuffer2 execbuf;
 	const struct intel_execution_engine2 *e;
-	uint32_t batch[16];
+	uint32_t batch[16], obj_size;
 	uint64_t offset;
 	unsigned nengine;
 	int value;
@@ -56,10 +56,19 @@ static void store_all(int fd)
 	execbuf.buffers_ptr = (uintptr_t)obj;
 	execbuf.buffer_count = 2;
 
+	nengine = 0;
+	__for_each_physical_engine(fd, e) {
+		if (!gem_class_can_store_dword(fd, e->class))
+			continue;
+		nengine++;
+	}
+
+	obj_size = 2 * (nengine + 1) *sizeof(batch);
+
 	memset(reloc, 0, sizeof(reloc));
 	memset(obj, 0, sizeof(obj));
-	obj[0].handle = gem_create(fd, 4096);
-	obj[1].handle = gem_create(fd, 4096);
+	obj[0].handle = gem_create(fd, obj_size);
+	obj[1].handle = gem_create(fd, obj_size);
 	obj[1].relocation_count = 1;
 
 	offset = sizeof(uint32_t);
@@ -79,24 +88,22 @@ static void store_all(int fd)
 	batch[value = ++i] = 0xc0ffee;
 	batch[++i] = MI_BATCH_BUFFER_END;
 
-	nengine = 0;
+	i = 0;
 	intel_detect_and_clear_missed_interrupts(fd);
 	__for_each_physical_engine(fd, e) {
 		if (!gem_class_can_store_dword(fd, e->class))
 			continue;
 
-		igt_assert(2 * (nengine + 1) * sizeof(batch) <= 4096);
-
-		engines[nengine] = e->flags;
+		engines[i] = e->flags;
 		if (gen < 6)
-			engines[nengine] |= I915_EXEC_SECURE;
-		execbuf.flags = engines[nengine];
+			engines[i] |= I915_EXEC_SECURE;
+		execbuf.flags = engines[i];
 
-		j = 2*nengine;
+		j = 2*i;
 		reloc[j].target_handle = obj[0].handle;
 		reloc[j].presumed_offset = ~0;
 		reloc[j].offset = j*sizeof(batch) + offset;
-		reloc[j].delta = nengine*sizeof(uint32_t);
+		reloc[j].delta = i*sizeof(uint32_t);
 		reloc[j].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
 		reloc[j].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
 		obj[1].relocs_ptr = (uintptr_t)&reloc[j];
@@ -107,22 +114,22 @@ static void store_all(int fd)
 		execbuf.batch_start_offset = j*sizeof(batch);
 		gem_execbuf(fd, &execbuf);
 
-		j = 2*nengine + 1;
+		j = 2*i + 1;
 		reloc[j].target_handle = obj[0].handle;
 		reloc[j].presumed_offset = ~0;
 		reloc[j].offset = j*sizeof(batch) + offset;
-		reloc[j].delta = nengine*sizeof(uint32_t);
+		reloc[j].delta = i*sizeof(uint32_t);
 		reloc[j].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
 		reloc[j].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
 		obj[1].relocs_ptr = (uintptr_t)&reloc[j];
 
-		batch[value] = nengine;
+		batch[value] = i;
 		gem_write(fd, obj[1].handle, j*sizeof(batch),
 			  batch, sizeof(batch));
 		execbuf.batch_start_offset = j*sizeof(batch);
 		gem_execbuf(fd, &execbuf);
 
-		nengine++;
+		i++;
 	}
 	gem_sync(fd, obj[1].handle);
 
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-05 18:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05  9:07 [igt-dev] [PATCH i-g-t] tests/i915_module_load: obj size based on the engine count Ramalingam C
2021-02-05  9:53 ` Chris Wilson
2021-02-05 10:06 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2021-02-05 10:10 ` [Intel-gfx] [PATCH i-g-t] i915/module_load: Tidy up gem_exec_store workalike Chris Wilson
2021-02-05 10:10   ` [igt-dev] " Chris Wilson
2021-02-05 17:43   ` [Intel-gfx] " Ramalingam C
2021-02-05 17:43     ` [igt-dev] " Ramalingam C
2021-02-05 12:04 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/i915_module_load: obj size based on the engine count (rev2) Patchwork
2021-02-05 18:48 ` [igt-dev] ✓ Fi.CI.IGT: success for tests/i915_module_load: obj size based on the engine count Patchwork

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.