[PATCH i-g-t 08/13] NORELOC - gem_exec_store - store_all() FIX

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


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

Signed-off-by: Andrzej Turko <andrzej.turko at intel.com>
---
 tests/i915/gem_exec_store.c | 52 +++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/tests/i915/gem_exec_store.c b/tests/i915/gem_exec_store.c
index 129bb42be..4b2ae886a 100644
--- a/tests/i915/gem_exec_store.c
+++ b/tests/i915/gem_exec_store.c
@@ -225,7 +225,7 @@ static void store_all(int fd)
 	unsigned nengine;
 	int value, address;
 	int i, j;
-	bool do_relocs = !gem_uses_ppgtt(fd);
+	bool do_relocs = gem_has_relocations(fd);
 
 	nengine = 0;
 	__for_each_physical_engine(fd, engine) {
@@ -254,22 +254,24 @@ static void store_all(int fd)
 
 	memset(obj, 0, sizeof(obj));
 	obj[0].handle = gem_create(fd, nengine*sizeof(uint32_t));
-	obj[0].offset = intel_allocator_alloc(ahnd, obj[0].handle,
-					      nengine*sizeof(uint32_t),
-					      ALIGNMENT);
-	obj[0].offset = CANONICAL(obj[0].offset);
-	obj[0].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 	obj[1].handle = gem_create(fd, 2*nengine*sizeof(batch));
-	obj[1].offset = intel_allocator_alloc(ahnd, obj[1].handle,
-					      2*nengine*sizeof(batch),
-					      ALIGNMENT);
-	obj[1].offset = CANONICAL(obj[1].offset);
-	obj[1].flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+
 	if (do_relocs) {
 		obj[1].relocation_count = 1;
 	} else {
-		obj[0].flags |= EXEC_OBJECT_PINNED | EXEC_OBJECT_WRITE;
-		obj[1].flags |= EXEC_OBJECT_PINNED;
+		obj[0].offset = intel_allocator_alloc(ahnd, obj[0].handle,
+						      nengine*sizeof(uint32_t),
+						      ALIGNMENT);
+		obj[0].offset = CANONICAL(obj[0].offset);
+		obj[0].flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS |
+				EXEC_OBJECT_PINNED | EXEC_OBJECT_WRITE;
+
+		obj[1].offset = intel_allocator_alloc(ahnd, obj[1].handle,
+						      2*nengine*sizeof(batch),
+						      ALIGNMENT);
+		obj[1].offset = CANONICAL(obj[1].offset);
+		obj[1].flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS |
+				EXEC_OBJECT_PINNED;
 	}
 
 	offset = sizeof(uint32_t);
@@ -301,19 +303,19 @@ static void store_all(int fd)
 		j = 2*nengine;
 		if (do_relocs) {
 			reloc[j].target_handle = obj[0].handle;
-			reloc[j].presumed_offset = obj[0].offset;
+			reloc[j].presumed_offset = ~0;
 			reloc[j].offset = j*sizeof(batch) + offset;
 			reloc[j].delta = nengine*sizeof(uint32_t);
 			reloc[j].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
 			reloc[j].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
 			obj[1].relocs_ptr = to_user_pointer(&reloc[j]);
+		} else {
+			reloc_value = obj[0].offset + nengine*sizeof(uint32_t);
+			batch[address] = reloc_value;
+			if (gen >= 8)
+				batch[address + 1] = reloc_value >> 32;
 		}
-
 		batch[value] = 0xdeadbeef;
-		reloc_value = obj[0].offset + nengine*sizeof(uint32_t);
-		batch[address] = reloc_value;
-		if (gen >= 8)
-			batch[address + 1] = reloc_value >> 32;
 
 		gem_write(fd, obj[1].handle, j*sizeof(batch),
 			  batch, sizeof(batch));
@@ -323,19 +325,19 @@ static void store_all(int fd)
 		j = 2*nengine + 1;
 		if (do_relocs) {
 			reloc[j].target_handle = obj[0].handle;
-			reloc[j].presumed_offset = obj[0].offset;
+			reloc[j].presumed_offset = ~0;
 			reloc[j].offset = j*sizeof(batch) + offset;
 			reloc[j].delta = nengine*sizeof(uint32_t);
 			reloc[j].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
 			reloc[j].write_domain = I915_GEM_DOMAIN_INSTRUCTION;
 			obj[1].relocs_ptr = to_user_pointer(&reloc[j]);
+		} else {
+			reloc_value = obj[0].offset + nengine*sizeof(uint32_t);
+			batch[address] = reloc_value;
+			if (gen>=8)
+				batch[address + 1] = reloc_value >> 32;
 		}
-
 		batch[value] = nengine;
-		reloc_value = obj[0].offset + nengine*sizeof(uint32_t);
-		batch[address] = reloc_value;
-		if (gen>=8)
-			batch[address + 1] = reloc_value >> 32;
 
 		gem_write(fd, obj[1].handle, j*sizeof(batch),
 			  batch, sizeof(batch));
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list