[i-g-t 1/1] tests/intel/xe_exec_threads: wait for all submissions to complete
fei.yang at intel.com
fei.yang at intel.com
Sat Oct 26 01:01:02 UTC 2024
From: Fei Yang <fei.yang at intel.com>
In test_compute_mode, there is an one second sleep waiting for all
the submissions to complete, but that is not reliable especially
on pre-si platforms where the GPU could be a lot slower. Instead we
should wait for the ufence to make sure the GPU is inactive before
unbinding the BO.
Signed-off-by: Fei Yang <fei.yang at intel.com>
---
tests/intel/xe_exec_threads.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/tests/intel/xe_exec_threads.c b/tests/intel/xe_exec_threads.c
index 413d6626b..b73d3df2b 100644
--- a/tests/intel/xe_exec_threads.c
+++ b/tests/intel/xe_exec_threads.c
@@ -340,7 +340,7 @@ test_compute_mode(int fd, uint32_t vm, uint64_t addr, uint64_t userptr,
xe_exec(fd, &exec);
if (flags & REBIND && i && !(i & 0x1f)) {
- for (j = i - 0x20; j <= i; ++j)
+ for (j = i - 0x20; j < i; ++j)
xe_wait_ufence(fd, &data[j].exec_sync,
USER_FENCE_VALUE,
exec_queues[e], fence_timeout);
@@ -370,7 +370,7 @@ test_compute_mode(int fd, uint32_t vm, uint64_t addr, uint64_t userptr,
* physical memory on next mmap call triggering
* an invalidate.
*/
- for (j = i == 0x20 ? 0 : i - 0x1f; j <= i; ++j)
+ for (j = i - 0x20; j < i; ++j)
xe_wait_ufence(fd, &data[j].exec_sync,
USER_FENCE_VALUE,
exec_queues[e],
@@ -404,16 +404,26 @@ test_compute_mode(int fd, uint32_t vm, uint64_t addr, uint64_t userptr,
}
}
- j = flags & INVALIDATE ?
- (flags & RACE ? n_execs / 2 + 1 : n_execs - 1) : 0;
+ j = 0; /* wait for all submissions to complete */
+ if (flags & INVALIDATE)
+ /*
+ * For !RACE cases xe_wait_ufence has been called in above for-loop
+ * except the last batch of submissions (0x20 submissions in a batch).
+ * For RACE cases we will need to wait for all the submissions to
+ * complete here.
+ */
+ j = (flags & RACE) ? 0 : (n_execs - 0x20);
+ else if (flags & REBIND)
+ /*
+ * For REBIND cases xe_wait_ufence has been called in above for-loop
+ * except the last batch of submissions (0x20 submissions in a batch).
+ */
+ j = n_execs - 0x20;
+
for (i = j; i < n_execs; i++)
xe_wait_ufence(fd, &data[i].exec_sync, USER_FENCE_VALUE,
exec_queues[i % n_exec_queues], fence_timeout);
- /* Wait for all execs to complete */
- if (flags & INVALIDATE)
- sleep(1);
-
sync[0].addr = to_user_pointer(&data[0].vm_sync);
xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, 0, fence_timeout);
--
2.25.1
More information about the igt-dev
mailing list