[PATCH v2 2/2] tests/intel/xe_vm: Add bind array -ENOBUFS section
Matthew Brost
matthew.brost at intel.com
Fri Jul 19 19:46:13 UTC 2024
Add section which has a large enough array of binds which triggers BB
suballocation failure. Verify -ENOBUFS is returned in this case.
v2:
- Use do_ioctl_err (Matthew Auld)
- Move xe_vm_bind_array_err to xe_vm.c
v3:
- Fix sign of error usage
Cc: Matthew Auld <matthew.auld at intel.com>
Signed-off-by: Matthew Brost <matthew.brost at intel.com>
---
tests/intel/xe_vm.c | 51 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 12 deletions(-)
diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index a5f25acc7e..cff71487e4 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -869,7 +869,7 @@ static void xe_vm_bind_array_err(int fd, uint32_t vm, uint32_t exec_queue,
}
#define BIND_ARRAY_BIND_EXEC_QUEUE_FLAG (0x1 << 0)
-
+#define BIND_ARRAY_ENOBUFS_FLAG (0x1 << 1)
/**
* SUBTEST: bind-array-twice
@@ -882,6 +882,11 @@ static void xe_vm_bind_array_err(int fd, uint32_t vm, uint32_t exec_queue,
* Functionality: bind exec_queues
* Test category: functionality test
*
+ * SUBTEST: bind-array-enobufs
+ * Description: Test bind array which too large are trigger -ENOBUFs error
+ * Functionality: bind exec_queues
+ * Test category: functionality test
+ *
* SUBTEST: bind-array-exec_queue-twice
* Description: Test bind array exec_queue twice
* Functionality: bind exec_queues
@@ -894,10 +899,10 @@ static void xe_vm_bind_array_err(int fd, uint32_t vm, uint32_t exec_queue,
*/
static void
test_bind_array(int fd, struct drm_xe_engine_class_instance *eci, int n_execs,
- unsigned int flags)
+ uint64_t addr, size_t bo_size, unsigned int flags)
{
uint32_t vm;
- uint64_t addr = 0x1a0000, base_addr = 0x1a0000;
+ uint64_t base_addr = addr;
struct drm_xe_sync sync[2] = {
{ .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
{ .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
@@ -907,9 +912,7 @@ test_bind_array(int fd, struct drm_xe_engine_class_instance *eci, int n_execs,
.syncs = to_user_pointer(sync),
};
uint32_t exec_queue, bind_exec_queue = 0;
-#define BIND_ARRAY_MAX_N_EXEC 16
- struct drm_xe_vm_bind_op bind_ops[BIND_ARRAY_MAX_N_EXEC] = { };
- size_t bo_size;
+ struct drm_xe_vm_bind_op *bind_ops;
uint32_t bo = 0;
struct {
uint32_t batch[16];
@@ -918,10 +921,11 @@ test_bind_array(int fd, struct drm_xe_engine_class_instance *eci, int n_execs,
} *data;
int i, b;
- igt_assert(n_execs <= BIND_ARRAY_MAX_N_EXEC);
+ bind_ops = malloc(sizeof(*bind_ops) * n_execs);
+ igt_assert(bind_ops);
vm = xe_vm_create(fd, 0, 0);
- bo_size = sizeof(*data) * n_execs;
+ bo_size = bo_size ?: sizeof(*data) * n_execs;
bo_size = xe_bb_size(fd, bo_size);
bo = xe_bo_create(fd, vm, bo_size,
@@ -949,6 +953,22 @@ test_bind_array(int fd, struct drm_xe_engine_class_instance *eci, int n_execs,
}
sync[0].handle = syncobj_create(fd, 0);
+ if (flags & BIND_ARRAY_ENOBUFS_FLAG) {
+ struct xe_cork cork;
+
+ xe_cork_init(fd, eci, &cork);
+
+ sync[1].handle = xe_cork_sync_handle(&cork);
+ sync[1].flags &= ~DRM_XE_SYNC_FLAG_SIGNAL;
+
+ xe_vm_bind_array_err(fd, vm, bind_exec_queue, bind_ops,
+ n_execs, sync, 2, ENOBUFS);
+ xe_cork_end(&cork);
+ xe_cork_wait_done(&cork);
+ xe_cork_fini(&cork);
+ n_execs = n_execs / 2;
+ }
+
xe_vm_bind_array(fd, vm, bind_exec_queue, bind_ops, n_execs, sync, 1);
addr = base_addr;
@@ -1008,6 +1028,7 @@ test_bind_array(int fd, struct drm_xe_engine_class_instance *eci, int n_execs,
munmap(data, bo_size);
gem_close(fd, bo);
xe_vm_destroy(fd, vm);
+ free(bind_ops);
}
/**
@@ -2397,20 +2418,26 @@ igt_main
igt_subtest("bind-array-twice")
xe_for_each_engine(fd, hwe)
- test_bind_array(fd, hwe, 2, 0);
+ test_bind_array(fd, hwe, 2, 0x1a0000, 0, 0);
igt_subtest("bind-array-many")
xe_for_each_engine(fd, hwe)
- test_bind_array(fd, hwe, 16, 0);
+ test_bind_array(fd, hwe, 16, 0x1a0000, 0, 0);
+
+ igt_subtest("bind-array-enobufs")
+ xe_for_each_engine(fd, hwe)
+ test_bind_array(fd, hwe, xe_has_vram(fd) ? 1024 : 512,
+ 0x1a0000, SZ_2M,
+ BIND_ARRAY_ENOBUFS_FLAG);
igt_subtest("bind-array-exec_queue-twice")
xe_for_each_engine(fd, hwe)
- test_bind_array(fd, hwe, 2,
+ test_bind_array(fd, hwe, 2, 0x1a0000, 0,
BIND_ARRAY_BIND_EXEC_QUEUE_FLAG);
igt_subtest("bind-array-exec_queue-many")
xe_for_each_engine(fd, hwe)
- test_bind_array(fd, hwe, 16,
+ test_bind_array(fd, hwe, 16, 0x1a0000, 0,
BIND_ARRAY_BIND_EXEC_QUEUE_FLAG);
igt_subtest("bind-array-conflict")
--
2.34.1
More information about the igt-dev
mailing list