[PATCH i-g-t 3/4] tests/gem_exec_reloc: Calculate softpin offsets from minimum page size

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Thu Oct 24 17:44:27 UTC 2019


From: Janusz Krzysztofik <janusz.krzysztofik at intel.com>

The basic-range subtest assumes 4kB minimum page size while calculating
softpin offsets.  On future backends with possibly larger minimum page
sizes this subtest may fail as softpin offsets may be incorrectly
aligned.

Replace hardcoded constants corresponding to the assumed 4kB value with
variables initialized with actual minimum page size and order.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at intel.com>
Cc: Katarzyna Dec <katarzyna.dec at intel.com>
Cc: Stuart Summers <stuart.summers at intel.com>
---
 tests/i915/gem_exec_reloc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/i915/gem_exec_reloc.c b/tests/i915/gem_exec_reloc.c
index 61f8b755..5e7df8ed 100644
--- a/tests/i915/gem_exec_reloc.c
+++ b/tests/i915/gem_exec_reloc.c
@@ -510,14 +510,16 @@ static void basic_range(int fd, unsigned flags)
 	uint64_t gtt_size = gem_aperture_size(fd);
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	igt_spin_t *spin = NULL;
+	int page_order = gem_min_page_size_order(fd);
+	uint64_t page_size = 1ull << page_order;
 	int count, n;
 
 	igt_require(gem_has_softpin(fd));
 
-	for (count = 12; gtt_size >> (count + 1); count++)
+	for (count = page_order; gtt_size >> (count + 1); count++)
 		;
 
-	count -= 12;
+	count -= page_order;
 
 	memset(obj, 0, sizeof(obj));
 	memset(reloc, 0, sizeof(reloc));
@@ -526,7 +528,7 @@ static void basic_range(int fd, unsigned flags)
 	n = 0;
 	for (int i = 0; i <= count; i++) {
 		obj[n].handle = gem_create(fd, 4096);
-		obj[n].offset = (1ull << (i + 12)) - 4096;
+		obj[n].offset = (1ull << (i + page_order)) - page_size;
 		obj[n].offset = gen8_canonical_addr(obj[n].offset);
 		obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 		gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe));
@@ -546,7 +548,7 @@ static void basic_range(int fd, unsigned flags)
 	}
 	for (int i = 1; i < count; i++) {
 		obj[n].handle = gem_create(fd, 4096);
-		obj[n].offset = 1ull << (i + 12);
+		obj[n].offset = 1ull << (i + page_order);
 		obj[n].offset = gen8_canonical_addr(obj[n].offset);
 		obj[n].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 		gem_write(fd, obj[n].handle, 0, &bbe, sizeof(bbe));
-- 
2.21.0



More information about the Intel-gfx-trybot mailing list