[PATCH i-g-t 10/13] NORELOC - gem_exec_store - store_cachelines() FIX

Andrzej Turko andrzej.turko at linux.intel.com
Fri Apr 30 11:07:03 UTC 2021


From: Andrzej Turko <andrzej.turko at intel.com>

---
 tests/i915/gem_exec_store.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/tests/i915/gem_exec_store.c b/tests/i915/gem_exec_store.c
index b6ceca16f..303e95be1 100644
--- a/tests/i915/gem_exec_store.c
+++ b/tests/i915/gem_exec_store.c
@@ -132,7 +132,7 @@ static void store_cachelines(int fd, const struct intel_execution_engine2 *e,
 	uint32_t *batch;
 	uint64_t ahnd, reloc_value;
 	int i;
-	bool do_relocs = !gem_uses_ppgtt(fd);
+	bool do_relocs = gem_has_relocations(fd);
 
 	reloc = calloc(NCACHELINES, sizeof(*reloc));
 	igt_assert(reloc);
@@ -149,13 +149,16 @@ static void store_cachelines(int fd, const struct intel_execution_engine2 *e,
 	igt_assert(obj);
 	for (i = 0; i < execbuf.buffer_count; i++) {
 		obj[i].handle = gem_create(fd, 4096);
-		obj[i].offset = intel_allocator_alloc(ahnd, obj[i].handle,
-						      4096, ALIGNMENT);
-		obj[i].offset = CANONICAL(obj[i].offset);
-		obj[i].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS |
-			       (do_relocs ? 0 : EXEC_OBJECT_PINNED);
-		if (i + 1 < execbuf.buffer_count && !do_relocs)
-			obj[i].flags |= EXEC_OBJECT_WRITE;
+
+		if (!do_relocs) {
+			obj[i].offset = intel_allocator_alloc(ahnd, obj[i].handle,
+							      4096, ALIGNMENT);
+			obj[i].offset = CANONICAL(obj[i].offset);
+			obj[i].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS |
+				       EXEC_OBJECT_PINNED;
+			if (i + 1 < execbuf.buffer_count)
+				obj[i].flags |= EXEC_OBJECT_WRITE;
+		}
 	}
 	if (do_relocs) {
 		obj[i-1].relocs_ptr = to_user_pointer(reloc);
@@ -167,13 +170,20 @@ static void store_cachelines(int fd, const struct intel_execution_engine2 *e,
 
 	i = 0;
 	for (unsigned n = 0; n < NCACHELINES; n++) {
+
 		reloc[n].target_handle = obj[n % (execbuf.buffer_count-1)].handle;
-		reloc[n].presumed_offset = obj[n % (execbuf.buffer_count-1)].offset;
-		reloc[n].offset = (i + 1)*sizeof(uint32_t);
 		reloc[n].delta = 4 * (n * 16 + n % 16);
-		reloc[n].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
-		reloc[n].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
-		reloc_value = reloc[n].presumed_offset + reloc[n].delta;
+
+		if (do_relocs) {
+			reloc[n].presumed_offset = -1;
+			reloc[n].offset = (i + 1)*sizeof(uint32_t);
+			reloc[n].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
+			reloc[n].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
+			reloc_value = 0;
+		} else {
+			reloc_value = obj[n % (execbuf.buffer_count-1)].offset +
+				      reloc[n].delta;
+		}
 
 		batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
 		if (gen >= 8) {
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list