[igt-dev] [PATCH i-g-t 7/9] tests/gem_exec_flush: Adopt to no-reloc

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Fri Aug 13 07:47:01 UTC 2021


Test uses "warming" execbuf which direct consequence is each child
will have objects pinned in gtt before core of the test is performed.
For gens with ppgtt we don't expect relocations so we can just add
EXEC_OBJECT_PINNED flag. We can do this due to each batch created
uses above offsets already.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
 tests/i915/gem_exec_flush.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tests/i915/gem_exec_flush.c b/tests/i915/gem_exec_flush.c
index 629fdd7af..40c58db2b 100644
--- a/tests/i915/gem_exec_flush.c
+++ b/tests/i915/gem_exec_flush.c
@@ -128,6 +128,7 @@ static void run(int fd, unsigned ring, int nchild, int timeout,
 		uint32_t *ptr;
 		uint32_t *map;
 		int i;
+		bool has_relocs = gem_has_relocations(fd);
 
 		memset(obj, 0, sizeof(obj));
 		obj[0].handle = gem_create(fd, 4096);
@@ -175,8 +176,20 @@ static void run(int fd, unsigned ring, int nchild, int timeout,
 		gem_write(fd, obj[2].handle, 0, &bbe, sizeof(bbe));
 		igt_require(__gem_execbuf(fd, &execbuf) == 0);
 
-		obj[1].relocation_count = 1;
-		obj[2].relocation_count = 1;
+		if (has_relocs) {
+			obj[1].relocation_count = 1;
+			obj[2].relocation_count = 1;
+		} else {
+			/*
+			 * For gens without relocations we already have
+			 * objects in appropriate place of gtt as warming
+			 * execbuf pins them so just set EXEC_OBJECT_PINNED
+			 * flag.
+			 */
+			obj[0].flags |= EXEC_OBJECT_PINNED;
+			obj[1].flags |= EXEC_OBJECT_PINNED;
+			obj[2].flags |= EXEC_OBJECT_PINNED;
+		}
 
 		ptr = gem_mmap__wc(fd, obj[1].handle, 0, 64*1024,
 				   PROT_WRITE | PROT_READ);
@@ -382,6 +395,7 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
 		uint32_t *ptr;
 		uint32_t *map;
 		int i;
+		bool has_relocs = gem_has_relocations(fd);
 
 		memset(obj, 0, sizeof(obj));
 		obj[0].handle = gem_create(fd, 4096);
@@ -407,7 +421,11 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
 		gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
 		igt_require(__gem_execbuf(fd, &execbuf) == 0);
 
-		obj[1].relocation_count = 1;
+		if (!has_relocs) {
+			obj[0].flags |= EXEC_OBJECT_PINNED | EXEC_OBJECT_WRITE;
+			obj[1].flags |= EXEC_OBJECT_PINNED;
+		}
+		obj[1].relocation_count = has_relocs ? 1 : 0;
 		obj[1].relocs_ptr = to_user_pointer(&reloc);
 
 		switch (mode) {
-- 
2.26.0



More information about the igt-dev mailing list