[PATCH i-g-t v2 36/66] tests/xe_eudebug: Test multiple bo sizes

Christoph Manszewski christoph.manszewski at intel.com
Tue Jul 30 11:44:53 UTC 2024


From: Jonathan Cavitt <jonathan.cavitt at intel.com>

Extend the basic vm access tests to allow for specifying the target bo
size per bo in the bind list. The size still has to be at least the
minimum, but can be overwritten to be larger.

Make sure that the vm is unbound during bind list destroy, to avoid
overlapping vmas.

Suggested-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
Cc: Christoph Manszewski <christoph.manszewski at intel.com>
---
 tests/intel/xe_eudebug.c | 45 ++++++++++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c
index 928dcdce4..db6d96a92 100644
--- a/tests/intel/xe_eudebug.c
+++ b/tests/intel/xe_eudebug.c
@@ -249,12 +249,13 @@ static union buf_id *vm_create_objects(int fd, uint32_t bo_placement, uint32_t v
 }
 
 static struct bind_list *create_bind_list(int fd, uint32_t bo_placement,
-					  uint32_t vm, unsigned int n)
+					  uint32_t vm, unsigned int n,
+					  unsigned int target_size)
 {
-	const unsigned int bo_size = max_t(bo_size, xe_get_default_alignment(fd), MIN_BO_SIZE);
+	unsigned int i = target_size ?: MIN_BO_SIZE;
+	const unsigned int bo_size = max_t(bo_size, xe_get_default_alignment(fd), i);
 	bool is_userptr = !bo_placement;
 	struct bind_list *bl;
-	unsigned int i;
 
 	bl = malloc(sizeof(*bl));
 	bl->fd = fd;
@@ -317,7 +318,7 @@ static void do_bind_list(struct xe_eudebug_client *c,
 		igt_assert(syncobj_wait(bl->fd, &sync->handle, 1, INT64_MAX, 0, NULL));
 }
 
-static void free_bind_list(struct bind_list *bl)
+static void free_bind_list(struct xe_eudebug_client *c, struct bind_list *bl)
 {
 	unsigned int i;
 
@@ -327,6 +328,9 @@ static void free_bind_list(struct bind_list *bl)
 		bo_check(bl->fd, &bl->bind_ops[i]);
 		if (bl->bind_ops[i].op == DRM_XE_VM_BIND_OP_MAP_USERPTR)
 			free(bl->bo[i].userptr);
+		xe_eudebug_client_vm_unbind(c, bl->fd, bl->vm, 0,
+					    bl->bind_ops[i].addr,
+					    bl->bind_ops[i].range);
 	}
 
 	free(bl->bind_ops);
@@ -359,7 +363,7 @@ static void vm_bind_client(int fd, struct xe_eudebug_client *c)
 
 		xe_vm_bind_async(fd, vm, 0, bo[1], rebind_bo_offset, addr[1], size, NULL, 0);
 
-		bl = create_bind_list(fd, system_memory(fd), vm, 4);
+		bl = create_bind_list(fd, system_memory(fd), vm, 4, 0);
 		xe_vm_bind_array(bl->fd, bl->vm, 0, bl->bind_ops, bl->n, NULL, 0);
 
 		xe_vm_unbind_all_async(fd, vm, 0, bo[0], NULL, 0);
@@ -387,7 +391,7 @@ static void vm_bind_client(int fd, struct xe_eudebug_client *c)
 		xe_eudebug_client_vm_bind(c, fd, vm, bo[1], 0, addr[1], bo_size);
 		xe_eudebug_client_vm_bind(c, fd, vm, bo[1], rebind_bo_offset, addr[1], size);
 
-		bl = create_bind_list(fd, system_memory(fd), vm, 4);
+		bl = create_bind_list(fd, system_memory(fd), vm, 4, 0);
 		do_bind_list(c, bl, NULL);
 	}
 
@@ -1378,7 +1382,7 @@ static void vm_access_client(struct xe_eudebug_client *c)
 	uint32_t bo_placement;
 	struct bind_list *bl;
 	uint32_t vm;
-	int fd, i;
+	int fd, i, j;
 
 	igt_debug("Using %s\n", xe_engine_class_string(hwe->engine_class));
 
@@ -1391,16 +1395,20 @@ static void vm_access_client(struct xe_eudebug_client *c)
 		bo_placement = 0;
 	else
 		bo_placement = vram_if_possible(fd, hwe->gt_id);
-	bl = create_bind_list(fd, bo_placement, vm, 4);
-	sync.handle = syncobj_create(bl->fd, 0);
-	do_bind_list(c, bl, &sync);
-	syncobj_destroy(bl->fd, sync.handle);
 
-	for (i = 0; i < bl->n; i++)
-		xe_eudebug_client_wait_stage(c, bl->bind_ops[i].addr);
+	for (j = 0; j < 5; j++) {
+		unsigned int target_size = MIN_BO_SIZE * (1 << j);
 
-	free_bind_list(bl);
+		bl = create_bind_list(fd, bo_placement, vm, 4, target_size);
+		sync.handle = syncobj_create(bl->fd, 0);
+		do_bind_list(c, bl, &sync);
+		syncobj_destroy(bl->fd, sync.handle);
 
+		for (i = 0; i < bl->n; i++)
+			xe_eudebug_client_wait_stage(c, bl->bind_ops[i].addr);
+
+		free_bind_list(c, bl);
+	}
 	xe_eudebug_client_vm_destroy(c, fd, vm);
 
 	xe_device_put(fd);
@@ -1482,11 +1490,16 @@ static void vm_trigger(struct xe_eudebug_debugger *d,
 /**
  * SUBTEST: basic-vm-access
  * Description:
- *      Exercise XE_EUDEBG_VM_OPEN with pread and pwrite into the vm fd
+ *      Exercise XE_EUDEBG_VM_OPEN with pread and pwrite into the
+ *      vm fd, concerning many different offsets inside the vm,
+ *      and many virtual addresses of the vm_bound object.
  *
  * SUBTEST: basic-vm-access-userptr
  * Description:
- *      Exercise XE_EUDEBG_VM_OPEN with pread and pwrite into the vm fd, but backed by userptr
+ *      Exercise XE_EUDEBG_VM_OPEN with pread and pwrite into the
+ *      vm fd, concerning many different offsets inside the vm,
+ *      and many virtual addresses of the vm_bound object, but backed
+ *      by userptr.
  */
 static void test_vm_access(int fd, unsigned int flags, int num_clients)
 {
-- 
2.34.1



More information about the igt-dev mailing list