[PATCH i-g-t v2 04/10] tests/intel/xe_svm: svm_random_access
Bommu Krishnaiah
krishnaiah.bommu at intel.com
Tue May 14 07:10:20 UTC 2024
Verify GPU can randomly access any location in malloc'ed memory by using svm.
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu at intel.com>
Cc: Oak Zeng <oak.zeng at intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
---
tests/intel/xe_svm.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index 2daed1eff..1c90d2e10 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -26,6 +26,9 @@
* Description: verify SVM basic functionality by using malloc
* SUBTEST: svm-basic-mmap
* Description: verify SVM basic functionality by using mmap
+ * SUBTEST: svm-random-access
+ * Description: verify SVM basic functionality by using
+ * randomly access any location in malloc'ed memory
*/
#include <fcntl.h>
@@ -111,6 +114,37 @@ static void svm_basic(int fd, uint32_t vm, struct drm_xe_engine_class_instance *
free(dst);
}
+/**
+ * Verify GPU can randomly access any location in malloc'ed memory
+ */
+static void svm_random_access(int fd, uint32_t vm, struct drm_xe_engine_class_instance *eci)
+{
+ uint64_t gpu_va = 0x1a0000;
+ size_t bo_size = xe_bb_size(fd, PAGE_ALIGN_UFENCE);
+ uint32_t *dst, *dst_to_access;
+ uint32_t size = 1024*1024, sz_dw = size/4;
+
+ struct xe_buffer cmd_buf = {
+ .fd = fd,
+ .gpu_addr = (void *)(uintptr_t)gpu_va,
+ .vm = vm,
+ .size = bo_size,
+ .placement = vram_if_possible(fd, eci->gt_id),
+ .flag = DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
+ };
+
+ dst = malloc(size);
+ dst_to_access = dst + random()%sz_dw;
+
+ xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst_to_access, 0xc0ffee, eci);
+ xe_submit_cmd(&cmd_buf);
+
+ igt_assert_eq(*dst, 0xc0ffee);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ free(dst);
+}
+
igt_main
{
int fd;
@@ -137,6 +171,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_basic(fd, vm, hwe, true);
+ igt_subtest_f("svm-random-access")
+ xe_for_each_engine(fd, hwe)
+ svm_random_access(fd, vm, hwe);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
More information about the igt-dev
mailing list