[PATCH i-g-t] tests/intel/xe_vm: Test DRM_XE_VM_BIND_OP_UNMAP_ALL

José Roberto de Souza jose.souza at intel.com
Wed Feb 14 20:44:50 UTC 2024


There was no test making use of DRM_XE_VM_BIND_OP_UNMAP_ALL, so
here adding a simple one just binding and unbinding bo.

Cc: Francois Dugast <francois.dugast at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
 tests/intel/xe_vm.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index fe667e64d..1f7ab0f63 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -220,13 +220,41 @@ test_bind_once(int fd)
 			   1, &addr);
 }
 
+/**
+ * SUBTEST: unbind-all
+ * Description: bind and unbind with DRM_XE_VM_BIND_OP_UNMAP_ALL
+ * Functionality: unbind BO
+ * Test category: functionality test
+ */
+static void
+test_unbind_all(int fd)
+{
+	uint32_t bo_size = xe_get_default_alignment(fd);
+	uint32_t va_bits = xe_va_bits(fd);
+	uint64_t *addrs = (va_bits == 57) ? addrs_57b : addrs_48b;
+	struct drm_xe_sync sync = {
+		.type = DRM_XE_SYNC_TYPE_SYNCOBJ,
+		.flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		.handle = syncobj_create(fd, 0),
+	};
+	uint32_t vm, bo;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE, 0);
+	bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd, 0),
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+	xe_vm_bind_sync(fd, vm, bo, 0, addrs[0], bo_size);
+
+	xe_vm_unbind_all_async(fd, vm, 0, bo, &sync, 1);
+	igt_assert(syncobj_wait(fd, &sync.handle, 1, INT64_MAX, 0, NULL));
+	syncobj_destroy(fd, sync.handle);
+}
+
 /**
  * SUBTEST: bind-one-bo-many-times
  * Description: bind many times on one BO
  * Functionality: bind BO
  * Test category: functionality test
  */
-
 static void
 test_bind_one_bo_many_times(int fd)
 {
@@ -2090,6 +2118,9 @@ igt_main
 		}
 	}
 
+	igt_subtest("unbind-all")
+		test_unbind_all(fd);
+
 	igt_fixture
 		drm_close_driver(fd);
 }
-- 
2.43.1



More information about the igt-dev mailing list