* [PATCH i-g-t v2 00/10] helper function
@ 2024-05-14 7:10 Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 01/10] lib/xe/xe_util: Introduce helper functions for buffer creation and command submission etc Bommu Krishnaiah
` (12 more replies)
0 siblings, 13 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah
Introduce helper functions for object creation, binding, submission,
and destruction, applicable for SVM and other tests
xe-basic test is validating the helper function introduced in 'lib/xe/xe_util: helper function'
svm test cases:
svm-basic-malloc
svm-basic-mmap
svm-random-access
svm-huge-page
svm-atomic-access
svm-atomic-access
svm_invalid_va
svm-mprotect
svm-benchmark
svm-sparse-access
svm kernel implimentation:
https://gitlab.freedesktop.org/oak/xe-kernel-driver-svm.git
branch: origin/drm-xe-next-svm-unify-userptr
Bommu Krishnaiah (10):
lib/xe/xe_util: Introduce helper functions for buffer creation and
command submission etc
tests/intel/xe_svm: basic xe_svm test
tests/xe_svm: basic svm test
tests/intel/xe_svm: svm_random_access
tests/intel/xe_svm: svm-huge-page
tests/intel/xe_svm: svm_atomic_access
tests/intel/xe_svm: svm-invalid-va
tests/intel/xe_svm: svm_benchmark
tests/intel/xe_svm: svm_mprotect
tests/intel/xe_svm: svm-sparse-access
include/drm-uapi/xe_drm.h | 2 +
lib/xe/xe_util.c | 186 +++++++++++++++++
lib/xe/xe_util.h | 40 ++++
tests/intel/xe_svm.c | 427 ++++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
5 files changed, 656 insertions(+)
create mode 100644 tests/intel/xe_svm.c
--
2.25.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 01/10] lib/xe/xe_util: Introduce helper functions for buffer creation and command submission etc
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 02/10] tests/intel/xe_svm: basic xe_svm test Bommu Krishnaiah
` (11 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Introduce helper functions for buffer creation, binding, command submission, and
destruction, applicable for SVM and other tests.
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
lib/xe/xe_util.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++
lib/xe/xe_util.h | 33 +++++++++++++
2 files changed, 158 insertions(+)
diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
index 050162b5e..1bdb5fa08 100644
--- a/lib/xe/xe_util.c
+++ b/lib/xe/xe_util.c
@@ -10,6 +10,131 @@
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
#include "xe/xe_util.h"
+#include "lib/svga/vm_basic_types.h"
+
+/*submit a command
+ * wait for cmmand to cmplete from gpu
+ * verify ufence value
+ */
+int64_t __xe_submit_cmd(struct xe_buffer *cmdbuf)
+{
+ int64_t timeout = ONE_SEC;
+
+ struct drm_xe_sync sync[1] = {
+ { .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+ .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .timeline_value = USER_FENCE_VALUE,
+ .addr = xe_cmdbuf_exec_ufence_gpuva(cmdbuf),},
+ };
+ struct drm_xe_exec exec = {
+ .num_batch_buffer = 1,
+ .num_syncs = 1,
+ .syncs = to_user_pointer(&sync),
+ .exec_queue_id = cmdbuf->exec_queue,
+ .address = (uint64_t)cmdbuf->gpu_addr,
+ };
+
+ xe_exec(cmdbuf->fd, &exec);
+ return __xe_wait_ufence(cmdbuf->fd, xe_cmdbuf_exec_ufence_cpuva(cmdbuf),USER_FENCE_VALUE, cmdbuf->exec_queue, &timeout);
+}
+
+void xe_submit_cmd(struct xe_buffer *cmdbuf)
+{
+ int64_t ret;
+
+ ret = __xe_submit_cmd(cmdbuf);
+ igt_assert_eq(ret, 0);
+}
+
+/*create a buffer, map it to cpu and gpu */
+void xe_create_buffer(struct xe_buffer *buffer)
+{
+ struct drm_xe_sync sync[1] = {
+ { .type = DRM_XE_SYNC_TYPE_USER_FENCE, .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .timeline_value = USER_FENCE_VALUE },
+ };
+
+ buffer->bind_queue = xe_bind_exec_queue_create(buffer->fd, buffer->vm, 0);
+ buffer->bind_ufence = aligned_alloc(xe_get_default_alignment(buffer->fd), PAGE_ALIGN_UFENCE);
+ sync->addr = (uint64_t)buffer->bind_ufence;
+
+ if (!buffer->is_userptr) {
+ buffer->bo = xe_bo_create(buffer->fd, 0, buffer->size, buffer->placement, buffer->flag);
+ buffer->cpu_addr = xe_bo_map(buffer->fd, buffer->bo, buffer->size);
+ xe_vm_bind_async(buffer->fd, buffer->vm, buffer->bind_queue, buffer->bo, 0, (uint64_t)buffer->gpu_addr, buffer->size, sync, 1);
+ } else {
+ buffer->cpu_addr = aligned_alloc(xe_get_default_alignment(buffer->fd), buffer->size);
+ xe_vm_bind_userptr_async(buffer->fd, buffer->vm, buffer->bind_queue, to_user_pointer(buffer->cpu_addr), (uint64_t)buffer->gpu_addr, buffer->size, sync, 1);
+ }
+
+ xe_wait_ufence(buffer->fd, (uint64_t *)buffer->bind_ufence, USER_FENCE_VALUE, buffer->bind_queue, ONE_SEC);
+}
+
+/* destroy buffers which is created in xe_create_buffer */
+void xe_destroy_buffer(struct xe_buffer *buffer)
+{
+ struct drm_xe_sync sync[1] = {
+ { .type = DRM_XE_SYNC_TYPE_USER_FENCE, .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .timeline_value = USER_FENCE_VALUE },
+ };
+ sync->addr = (uint64_t)buffer->bind_ufence;
+
+ xe_vm_unbind_async(buffer->fd, buffer->vm, buffer->bind_queue, 0, (uint64_t)buffer->gpu_addr, buffer->size, sync, 1);
+ xe_wait_ufence(buffer->fd, (uint64_t *)buffer->bind_ufence, USER_FENCE_VALUE, buffer->bind_queue, ONE_SEC);
+
+ munmap(buffer->cpu_addr, buffer->size);
+ if (!buffer->is_userptr)
+ gem_close(buffer->fd, buffer->bo);
+ else
+ free(buffer->cpu_addr);
+
+ free(buffer->bind_ufence);
+ xe_exec_queue_destroy(buffer->fd, buffer->bind_queue);
+}
+
+/*
+a command buffer is a buffer in GT0's vram, filled with gpu commands,
+plus some memory for a ufence used to sync command submission
+*/
+void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val)
+{
+ int i = 0;
+
+ batch[i] = MI_STORE_DWORD_IMM_GEN4;
+ batch[++i] = dst_va;
+ batch[++i] = dst_va >> 32;
+ batch[++i] = val;
+ batch[++i] = MI_BATCH_BUFFER_END;
+}
+
+void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func, uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci)
+{
+ //make some room for a exec_ufence, which will be used to sync the
+ //submission of this command....
+
+ cmd_buf->size = xe_bb_size(cmd_buf->fd, cmd_buf->size + PAGE_ALIGN_UFENCE);
+ xe_create_buffer(cmd_buf);
+ cmd_buf->exec_queue = xe_exec_queue_create(cmd_buf->fd, cmd_buf->vm, eci, 0);
+ fill_func(cmd_buf->cpu_addr, dst_va, val);
+}
+
+void xe_destroy_cmdbuf(struct xe_buffer *cmd_buf)
+{
+ xe_exec_queue_destroy(cmd_buf->fd, cmd_buf->exec_queue);
+ xe_destroy_buffer(cmd_buf);
+}
+
+uint64_t xe_cmdbuf_exec_ufence_gpuva(struct xe_buffer *cmd_buf)
+{
+ /* the last 8 bytes of the cmd buffer is used as ufence */
+ return (uint64_t)cmd_buf->gpu_addr + cmd_buf->size - 8;
+}
+
+uint64_t *xe_cmdbuf_exec_ufence_cpuva(struct xe_buffer *cmd_buf)
+{
+ /* the last 8 bytes of the cmd buffer is used as ufence */
+ return cmd_buf->cpu_addr + cmd_buf->size - 8;
+}
static bool __region_belongs_to_regions_type(struct drm_xe_mem_region *region,
uint32_t *mem_regions_type,
diff --git a/lib/xe/xe_util.h b/lib/xe/xe_util.h
index 6480ea01a..c38f79e60 100644
--- a/lib/xe/xe_util.h
+++ b/lib/xe/xe_util.h
@@ -12,6 +12,39 @@
#include <stdint.h>
#include <xe_drm.h>
+#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
+#define ONE_SEC MS_TO_NS(1000)
+#define PAGE_ALIGN_UFENCE 4096
+
+struct xe_buffer {
+ void *cpu_addr;
+ void *gpu_addr;
+ /*the user fence used to vm bind this buffer*/
+ uint32_t *bind_ufence;
+ uint64_t size;
+ uint32_t flag;
+ uint32_t vm;
+ uint32_t bo;
+ uint32_t placement;
+ uint32_t bind_queue;
+ /*only a cmd buffer has a exec queue*/
+ uint32_t exec_queue;
+ int fd;
+ bool is_userptr;
+};
+
+typedef void (*cmdbuf_fill_func_t) (uint32_t *batch, uint64_t dst_gpu_va, uint32_t val);
+void xe_create_buffer(struct xe_buffer *buffer);
+void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func,
+ uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci);
+uint64_t xe_cmdbuf_exec_ufence_gpuva(struct xe_buffer *cmd_buf);
+uint64_t *xe_cmdbuf_exec_ufence_cpuva(struct xe_buffer *cmd_buf);
+void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val);
+void xe_submit_cmd(struct xe_buffer *cmdbuf);
+int64_t __xe_submit_cmd(struct xe_buffer *cmdbuf);
+void xe_destroy_buffer(struct xe_buffer *buffer);
+void xe_destroy_cmdbuf(struct xe_buffer *cmd_buf);
+
#define XE_IS_SYSMEM_MEMORY_REGION(fd, region) \
(xe_region_class(fd, region) == DRM_XE_MEM_REGION_CLASS_SYSMEM)
#define XE_IS_VRAM_MEMORY_REGION(fd, region) \
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 02/10] tests/intel/xe_svm: basic xe_svm test
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 01/10] lib/xe/xe_util: Introduce helper functions for buffer creation and command submission etc Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test Bommu Krishnaiah
` (10 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Add basic test to validate helper functions introduced in
'lib/xe/xe_util: helper function'. This test writes values
to the destination buffer using GPU (MI_STORE_DWORD_IMM_GEN4).
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
tests/intel/xe_svm.c | 92 ++++++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
2 files changed, 93 insertions(+)
create mode 100644 tests/intel/xe_svm.c
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
new file mode 100644
index 000000000..7d0892a3d
--- /dev/null
+++ b/tests/intel/xe_svm.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: MIT
+ /*
+ * Copyright © 2024 Intel Corporation
+ */
+
+/** @file xe_svm.c
+ *
+ * Test shared virtual memory.
+ *
+ * Shared virtual memory (svm in short) is a xe driver feature
+ * which provide shared virtual address space b/t CPU and GPU
+ * program. This means application writer can just malloc or mmap,
+ * and use the returned ptr for both CPU and GPU program.
+ */
+
+/**
+ * TEST: xe_basic
+ * Description: Basic test to verify store dword by using helper funtions
+ */
+
+#include <fcntl.h>
+#include <string.h>
+
+#include "igt.h"
+#include "lib/igt_syncobj.h"
+#include "lib/intel_reg.h"
+#include "lib/xe/xe_util.h"
+#include "xe_drm.h"
+
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
+
+/**
+ * Verifies xe basic work load on gpu
+ */
+static void xe_basic(int fd, uint32_t vm, struct drm_xe_engine_class_instance *eci)
+{
+ uint64_t gpu_va = 0x1a0000;
+ uint32_t val = 0xc0ffee;
+ size_t bo_size = xe_bb_size(fd, PAGE_ALIGN_UFENCE);
+
+ struct xe_buffer dst_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,
+ };
+
+ struct xe_buffer cmd_buf = {
+ .fd = fd,
+ .gpu_addr = (void *)(uintptr_t)gpu_va + bo_size,
+ .vm = vm,
+ .size = bo_size,
+ .placement = vram_if_possible(fd, eci->gt_id),
+ .flag = DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
+ };
+
+ xe_create_buffer(&dst_buf);
+ xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst_buf.gpu_addr, val, eci);
+ xe_submit_cmd(&cmd_buf);
+
+ igt_assert_eq(*(uint32_t *)dst_buf.cpu_addr, val);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ xe_destroy_buffer(&dst_buf);
+}
+
+igt_main
+{
+ int fd;
+ uint32_t vm;
+ struct drm_xe_engine_class_instance *hwe;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_XE);
+ igt_require(xe_supports_faults(fd));
+ vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
+ }
+
+
+ igt_subtest_f("xe-basic")
+ xe_for_each_engine(fd, hwe)
+ xe_basic(fd, vm, hwe);
+
+ igt_fixture {
+ xe_vm_destroy(fd, vm);
+ drm_close_driver(fd);
+ }
+}
+
diff --git a/tests/meson.build b/tests/meson.build
index 758ae090c..be792a4fd 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -314,6 +314,7 @@ intel_xe_progs = [
'xe_vm',
'xe_waitfence',
'xe_spin_batch',
+ 'xe_svm',
'xe_sysfs_defaults',
'xe_sysfs_scheduler',
]
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 01/10] lib/xe/xe_util: Introduce helper functions for buffer creation and command submission etc Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 02/10] tests/intel/xe_svm: basic xe_svm test Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-15 17:38 ` Kamil Konieczny
2024-05-14 7:10 ` [PATCH i-g-t v2 04/10] tests/intel/xe_svm: svm_random_access Bommu Krishnaiah
` (9 subsequent siblings)
12 siblings, 1 reply; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Test will verify SVM basic functionality, by allocating a memory with
system allocator(malloc() or mmap()) and accessing in GPU.
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
include/drm-uapi/xe_drm.h | 2 ++
tests/intel/xe_svm.c | 57 +++++++++++++++++++++++++++++++++++++--
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h
index 0b709b374..228bc2974 100644
--- a/include/drm-uapi/xe_drm.h
+++ b/include/drm-uapi/xe_drm.h
@@ -973,6 +973,8 @@ struct drm_xe_vm_bind_op {
#define DRM_XE_VM_BIND_FLAG_IMMEDIATE (1 << 1)
#define DRM_XE_VM_BIND_FLAG_NULL (1 << 2)
#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)
+#define DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR (1 << 4)
+
/** @flags: Bind flags */
__u32 flags;
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index 7d0892a3d..2daed1eff 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -14,8 +14,18 @@
*/
/**
- * TEST: xe_basic
+ * TEST: xe_svm
+ * Description: Test shared virtual memory
+ * Sub-category: Memory management
+ * Functionality: svm
+ * Run type: FULL
+ *
+ * SUBTEST: xe_basic
* Description: Basic test to verify store dword by using helper funtions
+ * SUBTEST: svm-basic-malloc
+ * Description: verify SVM basic functionality by using malloc
+ * SUBTEST: svm-basic-mmap
+ * Description: verify SVM basic functionality by using mmap
*/
#include <fcntl.h>
@@ -67,6 +77,40 @@ static void xe_basic(int fd, uint32_t vm, struct drm_xe_engine_class_instance *e
xe_destroy_buffer(&dst_buf);
}
+/**
+ * Use malloc or mmap memory for direct GPU submission
+ */
+static void svm_basic(int fd, uint32_t vm, struct drm_xe_engine_class_instance *eci, bool test_mmap)
+{
+ uint64_t gpu_va = 0x1a0000;
+ size_t bo_size = xe_bb_size(fd, PAGE_ALIGN_UFENCE);
+ uint32_t *dst;
+
+ 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,
+ };
+
+ if (test_mmap)
+ dst = mmap(NULL, 4, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ else
+ dst = aligned_alloc(xe_get_default_alignment(fd), 4);
+
+ xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst, 0xc0ffee, eci);
+ xe_submit_cmd(&cmd_buf);
+ igt_assert_eq(*dst, 0xc0ffee);
+ xe_destroy_cmdbuf(&cmd_buf);
+
+ if (test_mmap)
+ munmap(dst, 4);
+ else
+ free(dst);
+}
+
igt_main
{
int fd;
@@ -77,13 +121,22 @@ igt_main
fd = drm_open_driver(DRIVER_XE);
igt_require(xe_supports_faults(fd));
vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
+ __xe_vm_bind_assert(fd, vm, 0, 0, 0, 0, 0x1ull << 47, DRM_XE_VM_BIND_OP_MAP,
+ DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR, 0, 0, 0, 0);
}
-
igt_subtest_f("xe-basic")
xe_for_each_engine(fd, hwe)
xe_basic(fd, vm, hwe);
+ igt_subtest_f("svm-basic-malloc")
+ xe_for_each_engine(fd, hwe)
+ svm_basic(fd, vm, hwe, false);
+
+ igt_subtest_f("svm-basic-mmap")
+ xe_for_each_engine(fd, hwe)
+ svm_basic(fd, vm, hwe, true);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 04/10] tests/intel/xe_svm: svm_random_access
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (2 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 05/10] tests/intel/xe_svm: svm-huge-page Bommu Krishnaiah
` (8 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify GPU can randomly access any location in malloc'ed memory by using svm.
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 05/10] tests/intel/xe_svm: svm-huge-page
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (3 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 04/10] tests/intel/xe_svm: svm_random_access Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 06/10] tests/intel/xe_svm: svm_atomic_access Bommu Krishnaiah
` (7 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify GPU can huge page access by using svm.
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
tests/intel/xe_svm.c | 52 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index 1c90d2e10..4f2818cc8 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -27,8 +27,9 @@
* 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
+ * Description: verify SVM basic functionality by using randomly access any location in malloc'ed memory
+ * SUBTEST: svm-huge-page
+ * Description: verify SVM basic functionality by using huge page access
*/
#include <fcntl.h>
@@ -145,6 +146,49 @@ static void svm_random_access(int fd, uint32_t vm, struct drm_xe_engine_class_in
free(dst);
}
+/**
+ * Test the behavior of transparent huge page.
+ * Allocate 2MB of aligned memory so huge page
+ * is used. What happens if driver only migrate
+ * 1 4k page of that buffer to GPU?
+ *
+ * Test result shows that the huge page is splitted
+ * into small pages and only one 4k page is
+ * migrated.
+ */
+static void svm_thp(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 size = 1<<21;
+ uint32_t *dst;
+ int ret;
+
+ 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,
+ };
+
+ ret = posix_memalign((void **)&dst, size, size);
+ igt_assert_eq(ret, 0);
+ /** TODO huge page advice cause the system hang
+ * when process exit...Very possible a hmm bug
+ **/
+ memset(dst, 0xbe, size);
+
+ xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst, 0xc0ffee, eci);
+ xe_submit_cmd(&cmd_buf);
+
+ igt_assert_eq(*dst, 0xc0ffee);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ free(dst);
+}
+
igt_main
{
int fd;
@@ -175,6 +219,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_random_access(fd, vm, hwe);
+ igt_subtest_f("svm-huge-page")
+ xe_for_each_engine(fd, hwe)
+ svm_thp(fd, vm, hwe);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 06/10] tests/intel/xe_svm: svm_atomic_access
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (4 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 05/10] tests/intel/xe_svm: svm-huge-page Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 8:14 ` Lisovskiy, Stanislav
2024-05-14 7:10 ` [PATCH i-g-t v2 07/10] tests/intel/xe_svm: svm-invalid-va Bommu Krishnaiah
` (6 subsequent siblings)
12 siblings, 1 reply; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify GPU atomic access any location in malloc'ed memory by using svm
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
lib/xe/xe_util.c | 17 +++++++++++++++++
lib/xe/xe_util.h | 1 +
tests/intel/xe_svm.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
index 1bdb5fa08..0e28c0093 100644
--- a/lib/xe/xe_util.c
+++ b/lib/xe/xe_util.c
@@ -107,6 +107,23 @@ void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val)
batch[++i] = MI_BATCH_BUFFER_END;
}
+/*
+a command buffer is a buffer in GT0's vram, filled with gpu commands,
+plus some memory for a ufence used to sync command submission
+*/
+void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val)
+{
+ int i = 0;
+
+ //suppress compiler warning
+ (void)(val);
+
+ batch[i] = MI_STORE_DWORD_IMM_GEN4;
+ batch[++i] = dst_va;
+ batch[++i] = dst_va >> 32;
+ batch[++i] = MI_BATCH_BUFFER_END;
+}
+
void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func, uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci)
{
//make some room for a exec_ufence, which will be used to sync the
diff --git a/lib/xe/xe_util.h b/lib/xe/xe_util.h
index c38f79e60..46e1ccc9a 100644
--- a/lib/xe/xe_util.h
+++ b/lib/xe/xe_util.h
@@ -40,6 +40,7 @@ void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func,
uint64_t xe_cmdbuf_exec_ufence_gpuva(struct xe_buffer *cmd_buf);
uint64_t *xe_cmdbuf_exec_ufence_cpuva(struct xe_buffer *cmd_buf);
void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val);
+void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val);
void xe_submit_cmd(struct xe_buffer *cmdbuf);
int64_t __xe_submit_cmd(struct xe_buffer *cmdbuf);
void xe_destroy_buffer(struct xe_buffer *buffer);
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index 4f2818cc8..421d7fd1a 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -30,6 +30,8 @@
* Description: verify SVM basic functionality by using randomly access any location in malloc'ed memory
* SUBTEST: svm-huge-page
* Description: verify SVM basic functionality by using huge page access
+ * SUBTEST: svm-atomic-access
+ * Description: verify SVM basic functionality by using GPU atomic access any location in malloc'ed memory
*/
#include <fcntl.h>
@@ -189,6 +191,39 @@ static void svm_thp(int fd, uint32_t vm, struct drm_xe_engine_class_instance *ec
free(dst);
}
+/**
+ * Test GPU atomic access any location in malloc'ed memory
+ */
+static void svm_atomic_access(int fd, uint32_t vm, struct drm_xe_engine_class_instance *eci)
+{
+ uint64_t gpu_va = 0x1a0000;
+ int val = 0xc0ffee;
+ 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 = aligned_alloc(xe_get_default_alignment(fd), size);
+ dst_to_access = dst + random()%sz_dw;
+ *dst_to_access = val;
+
+ xe_create_cmdbuf(&cmd_buf, insert_atomic_inc, (uint64_t)dst_to_access, val, eci);
+ xe_submit_cmd(&cmd_buf);
+
+ igt_assert_eq(*dst_to_access, val + 1);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ free(dst);
+}
+
igt_main
{
int fd;
@@ -223,6 +258,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_thp(fd, vm, hwe);
+ igt_subtest_f("svm-atomic-access")
+ xe_for_each_engine(fd, hwe)
+ svm_atomic_access(fd, vm, hwe);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 07/10] tests/intel/xe_svm: svm-invalid-va
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (5 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 06/10] tests/intel/xe_svm: svm_atomic_access Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 08/10] tests/intel/xe_svm: svm_benchmark Bommu Krishnaiah
` (5 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify SVM functionality while accessing invalid address
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
tests/intel/xe_svm.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index 421d7fd1a..b846ca71a 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -32,6 +32,8 @@
* Description: verify SVM basic functionality by using huge page access
* SUBTEST: svm-atomic-access
* Description: verify SVM basic functionality by using GPU atomic access any location in malloc'ed memory
+ * SUBTEST: svm_invalid_va
+ * Description: verify SVM functionality while accessing invalid address
*/
#include <fcntl.h>
@@ -224,6 +226,34 @@ static void svm_atomic_access(int fd, uint32_t vm, struct drm_xe_engine_class_in
free(dst);
}
+/**
+ * Submit a GPU command to access an invalid address.
+ * Driver should detect a catstrophic error.
+ */
+static void svm_invalid_va(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;
+
+ 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 = (uint32_t *)0x1fffffffffff000;
+
+ xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst, 0xc0ffee, eci);
+ igt_assert_eq(__xe_submit_cmd(&cmd_buf), -EIO); // for invalid address __xe_wait_ufence will return -EIO
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ free(dst);
+}
+
igt_main
{
int fd;
@@ -262,6 +292,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_atomic_access(fd, vm, hwe);
+ igt_subtest_f("svm-invalid-va")
+ xe_for_each_engine(fd, hwe)
+ svm_invalid_va(fd, vm, hwe);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 08/10] tests/intel/xe_svm: svm_benchmark
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (6 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 07/10] tests/intel/xe_svm: svm-invalid-va Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 09/10] tests/intel/xe_svm: svm_mprotect Bommu Krishnaiah
` (4 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify SVM performance with simple benchmark test
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
lib/xe/xe_util.c | 29 ++++++++++++++++++++++++++++
lib/xe/xe_util.h | 5 +++++
tests/intel/xe_svm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+)
diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
index 0e28c0093..a02ee5324 100644
--- a/lib/xe/xe_util.c
+++ b/lib/xe/xe_util.c
@@ -124,6 +124,24 @@ void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val)
batch[++i] = MI_BATCH_BUFFER_END;
}
+/** Insert commands to batch buffer to memset dst_va buffer with val
+ */
+void insert_memset(uint32_t *batch, uint64_t dst_va, uint64_t size, uint32_t val)
+{
+#define PVC_MEM_SET_CMD (2 << 29 | 0x5b << 22)
+#define MS_MATRIX (1 << 17)
+ const int page_shift = 12;
+
+ *batch++ = PVC_MEM_SET_CMD | MS_MATRIX | (7 - 2);
+ *batch++ = BIT(page_shift) - 1;
+ *batch++ = (size >> page_shift) - 1;
+ *batch++ = BIT(page_shift) - 1;
+ *batch++ = lower_32_bits(dst_va);
+ *batch++ = upper_32_bits(dst_va);
+ *batch++ = (uint32_t)val << 24;
+ *batch++ = MI_BATCH_BUFFER_END;
+}
+
void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func, uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci)
{
//make some room for a exec_ufence, which will be used to sync the
@@ -135,6 +153,17 @@ void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func, u
fill_func(cmd_buf->cpu_addr, dst_va, val);
}
+void xe_create_cmdbuf_fill_two_dw(struct xe_buffer *cmd_buf, cmdbuf_fill_two_dw_func_t fill_func, uint64_t dst_va, uint64_t dst_va1, uint32_t val, struct drm_xe_engine_class_instance *eci)
+{
+ //make some room for a exec_ufence, which will be used to sync the
+ //submission of this command....
+
+ cmd_buf->size = xe_bb_size(cmd_buf->fd, cmd_buf->size + PAGE_ALIGN_UFENCE);
+ xe_create_buffer(cmd_buf);
+ cmd_buf->exec_queue = xe_exec_queue_create(cmd_buf->fd, cmd_buf->vm, eci, 0);
+ fill_func(cmd_buf->cpu_addr, dst_va, dst_va1, val);
+}
+
void xe_destroy_cmdbuf(struct xe_buffer *cmd_buf)
{
xe_exec_queue_destroy(cmd_buf->fd, cmd_buf->exec_queue);
diff --git a/lib/xe/xe_util.h b/lib/xe/xe_util.h
index 46e1ccc9a..50f2a4bc4 100644
--- a/lib/xe/xe_util.h
+++ b/lib/xe/xe_util.h
@@ -34,13 +34,18 @@ struct xe_buffer {
};
typedef void (*cmdbuf_fill_func_t) (uint32_t *batch, uint64_t dst_gpu_va, uint32_t val);
+typedef void (*cmdbuf_fill_two_dw_func_t) (uint32_t *batch, uint64_t dst_gpu_va,
+ uint64_t dst_gpu_va1, uint32_t val);
void xe_create_buffer(struct xe_buffer *buffer);
void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func,
uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci);
+void xe_create_cmdbuf_fill_two_dw(struct xe_buffer *cmd_buf, cmdbuf_fill_two_dw_func_t fill_func,
+ uint64_t dst_va, uint64_t dst_va1, uint32_t val, struct drm_xe_engine_class_instance *eci);
uint64_t xe_cmdbuf_exec_ufence_gpuva(struct xe_buffer *cmd_buf);
uint64_t *xe_cmdbuf_exec_ufence_cpuva(struct xe_buffer *cmd_buf);
void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val);
void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val);
+void insert_memset(uint32_t *batch, uint64_t dst_va, uint64_t size, uint32_t val);
void xe_submit_cmd(struct xe_buffer *cmdbuf);
int64_t __xe_submit_cmd(struct xe_buffer *cmdbuf);
void xe_destroy_buffer(struct xe_buffer *buffer);
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index b846ca71a..0b573e0c9 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -34,6 +34,8 @@
* Description: verify SVM basic functionality by using GPU atomic access any location in malloc'ed memory
* SUBTEST: svm_invalid_va
* Description: verify SVM functionality while accessing invalid address
+ * SUBTEST: svm-benchmark
+ * Description: verify SVM performance with simple benchmark test
*/
#include <fcntl.h>
@@ -254,6 +256,46 @@ static void svm_invalid_va(int fd, uint32_t vm, struct drm_xe_engine_class_insta
free(dst);
}
+/**
+ * A simple benchmark test.
+ * Use GPU to memset a buffer with specific value and
+ * measure memset end to end bandwidth.
+ *
+ * By comparing the output of those two tests, we can have
+ * a very basic concept of the performance of sytem allocator
+ * compared to runtime allocator.
+ */
+static void svm_benchmark(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, size = 1 << 26;
+ struct timespec start_time;
+ double bandwidth;
+
+ 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,
+ };
+
+ igt_gettime(&start_time);
+ dst = aligned_alloc(xe_get_default_alignment(fd), size);
+
+ xe_create_cmdbuf_fill_two_dw(&cmd_buf, insert_memset, (uint64_t)dst, (uint64_t)size, 0x12, eci);
+ xe_submit_cmd(&cmd_buf);
+ igt_assert_eq(*dst, 0x12121212);
+ xe_destroy_cmdbuf(&cmd_buf);
+
+ free(dst);
+
+ bandwidth = (double)(size>>20)*NSEC_PER_SEC/igt_nsec_elapsed(&start_time);
+ igt_info("engine class %d, engine id %d memset E2E bandwidth(include sync overhead) %.3f MiB/s\n", eci->engine_class, eci->engine_instance, bandwidth);
+}
+
igt_main
{
int fd;
@@ -296,6 +338,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_invalid_va(fd, vm, hwe);
+ igt_subtest_f("svm-benchmark")
+ xe_for_each_engine(fd, hwe)
+ svm_benchmark(fd, vm, hwe);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 09/10] tests/intel/xe_svm: svm_mprotect
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (7 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 08/10] tests/intel/xe_svm: svm_benchmark Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 10/10] tests/intel/xe_svm: svm-sparse-access Bommu Krishnaiah
` (3 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify SVM functionality while accessing read only memory
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@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 0b573e0c9..e8989afaa 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -34,6 +34,8 @@
* Description: verify SVM basic functionality by using GPU atomic access any location in malloc'ed memory
* SUBTEST: svm_invalid_va
* Description: verify SVM functionality while accessing invalid address
+ * SUBTEST: svm-mprotect
+ * Description: verify SVM functionality while accessing read only memory
* SUBTEST: svm-benchmark
* Description: verify SVM performance with simple benchmark test
*/
@@ -256,6 +258,38 @@ static void svm_invalid_va(int fd, uint32_t vm, struct drm_xe_engine_class_insta
free(dst);
}
+/**
+ * Use mprotect to mark a chunk of memory to be read only and submit
+ * GPU command to write to this read only memory. GPU write should
+ * fail and driver should detect an invalid access error.
+ */
+static void svm_mprotect(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;
+ uint32_t size = 65536;
+
+ 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 = aligned_alloc(size, size);
+ mprotect(dst, size, PROT_READ);
+
+ xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst, 0xc0ffee, eci);
+
+ igt_assert_eq(__xe_submit_cmd(&cmd_buf), -EIO);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ free(dst);
+}
+
/**
* A simple benchmark test.
* Use GPU to memset a buffer with specific value and
@@ -338,6 +372,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_invalid_va(fd, vm, hwe);
+ igt_subtest_f("svm-mprotect")
+ xe_for_each_engine(fd, hwe)
+ svm_mprotect(fd, vm, hwe);
+
igt_subtest_f("svm-benchmark")
xe_for_each_engine(fd, hwe)
svm_benchmark(fd, vm, hwe);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH i-g-t v2 10/10] tests/intel/xe_svm: svm-sparse-access
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (8 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 09/10] tests/intel/xe_svm: svm_mprotect Bommu Krishnaiah
@ 2024-05-14 7:10 ` Bommu Krishnaiah
2024-05-14 7:52 ` ✗ Fi.CI.BUILD: failure for helper function (rev2) Patchwork
` (2 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Bommu Krishnaiah @ 2024-05-14 7:10 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Verify Sparsely access two memory locations with svm
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
---
lib/xe/xe_util.c | 15 +++++++++++++++
lib/xe/xe_util.h | 1 +
tests/intel/xe_svm.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
index a02ee5324..fc07c14b7 100644
--- a/lib/xe/xe_util.c
+++ b/lib/xe/xe_util.c
@@ -142,6 +142,21 @@ void insert_memset(uint32_t *batch, uint64_t dst_va, uint64_t size, uint32_t val
*batch++ = MI_BATCH_BUFFER_END;
}
+void insert_two_stores(uint32_t *batch, uint64_t dst_va, uint64_t dst_va1, uint32_t val)
+{
+ int i = 0;
+
+ batch[i] = MI_STORE_DWORD_IMM;
+ batch[++i] = dst_va;
+ batch[++i] = dst_va >> 32;
+ batch[++i] = val;
+ batch[++i] = MI_STORE_DWORD_IMM;
+ batch[++i] = dst_va1;
+ batch[++i] = dst_va1 >> 32;
+ batch[++i] = val;
+ batch[++i] = MI_BATCH_BUFFER_END;
+}
+
void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func, uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci)
{
//make some room for a exec_ufence, which will be used to sync the
diff --git a/lib/xe/xe_util.h b/lib/xe/xe_util.h
index 50f2a4bc4..f463cca3b 100644
--- a/lib/xe/xe_util.h
+++ b/lib/xe/xe_util.h
@@ -46,6 +46,7 @@ uint64_t *xe_cmdbuf_exec_ufence_cpuva(struct xe_buffer *cmd_buf);
void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val);
void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val);
void insert_memset(uint32_t *batch, uint64_t dst_va, uint64_t size, uint32_t val);
+void insert_two_stores(uint32_t *batch, uint64_t dst_va, uint64_t dst_va1, uint32_t val);
void xe_submit_cmd(struct xe_buffer *cmdbuf);
int64_t __xe_submit_cmd(struct xe_buffer *cmdbuf);
void xe_destroy_buffer(struct xe_buffer *buffer);
diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
index e8989afaa..fbda6aaea 100644
--- a/tests/intel/xe_svm.c
+++ b/tests/intel/xe_svm.c
@@ -38,6 +38,8 @@
* Description: verify SVM functionality while accessing read only memory
* SUBTEST: svm-benchmark
* Description: verify SVM performance with simple benchmark test
+ * SUBTEST: svm-sparse-access
+ * Description: verify Sparsely access two memory locations with svm
*/
#include <fcntl.h>
@@ -330,6 +332,39 @@ static void svm_benchmark(int fd, uint32_t vm, struct drm_xe_engine_class_instan
igt_info("engine class %d, engine id %d memset E2E bandwidth(include sync overhead) %.3f MiB/s\n", eci->engine_class, eci->engine_instance, bandwidth);
}
+/**
+ * Sparsely access two memory locations
+ */
+static void svm_sparse_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 size = 1024*1024, sz_dw = size/4;
+ uint32_t *dst, *dst_to_access, *dst_to_access1;
+
+ 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 + (sz_dw>>1);
+ dst_to_access1 = dst + (sz_dw>>2);
+
+ xe_create_cmdbuf_fill_two_dw(&cmd_buf, insert_two_stores, (uint64_t)dst_to_access, (uint64_t)dst_to_access1, 0xc0ffee, eci);
+ xe_submit_cmd(&cmd_buf);
+
+ igt_assert_eq(*dst_to_access, 0xc0ffee);
+ igt_assert_eq(*dst_to_access1, 0xc0ffee);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ free(dst);
+}
+
igt_main
{
int fd;
@@ -380,6 +415,10 @@ igt_main
xe_for_each_engine(fd, hwe)
svm_benchmark(fd, vm, hwe);
+ igt_subtest_f("svm-sparse-access")
+ xe_for_each_engine(fd, hwe)
+ svm_sparse_access(fd, vm, hwe);
+
igt_fixture {
xe_vm_destroy(fd, vm);
drm_close_driver(fd);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* ✗ Fi.CI.BUILD: failure for helper function (rev2)
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (9 preceding siblings ...)
2024-05-14 7:10 ` [PATCH i-g-t v2 10/10] tests/intel/xe_svm: svm-sparse-access Bommu Krishnaiah
@ 2024-05-14 7:52 ` Patchwork
2024-05-14 7:58 ` ✗ GitLab.Pipeline: warning " Patchwork
2024-05-15 17:29 ` [PATCH i-g-t v2 00/10] helper function Kamil Konieczny
12 siblings, 0 replies; 16+ messages in thread
From: Patchwork @ 2024-05-14 7:52 UTC (permalink / raw)
To: Bommu Krishnaiah; +Cc: igt-dev
== Series Details ==
Series: helper function (rev2)
URL : https://patchwork.freedesktop.org/series/133096/
State : failure
== Summary ==
IGT patchset build failed on latest successful build
be9b9992805df48e785b40ac2c4d001fb680a2c1 tests/kms_ccs: Test XRGB2101010
Tail of build.log:
[1647/1682] Linking target runner/igt_results.
[1648/1682] Linking target tools/lsgpu.
[1649/1682] Linking target tools/msm_dp_compliance.
[1650/1682] Linking target runner/testdata/no-subtests.
[1651/1682] Linking target runner/testdata/successtest.
[1652/1682] Linking target runner/testdata/abort-simple.
[1653/1682] Generating gem_stress.testlist with a meson_exe.py custom command.
[1654/1682] Linking target runner/testdata/dynamic.
[1655/1682] Linking target runner/igt_resume.
[1656/1682] Linking target runner/igt_runner.
[1657/1682] Linking target runner/runner_json_test.
[1658/1682] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_mtlgt3.c.o'.
[1659/1682] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt1.c.o'.
[1660/1682] Compiling C object 'runner/527aa9f@@runner_test@exe/runner_tests.c.o'.
[1661/1682] Linking target runner/runner_test.
[1662/1682] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt2.c.o'.
[1663/1682] Compiling C object 'lib/76b5a35@@i915_perf@sha/meson-generated_.._i915_perf_metrics_acmgt3.c.o'.
[1664/1682] Linking target lib/libi915_perf.so.1.5.
[1665/1682] Generating symbol file 'lib/76b5a35@@i915_perf@sha/libi915_perf.so.1.5.symbols'.
[1666/1682] Linking target tools/i915-perf/i915-perf-configs.
[1667/1682] Linking target tools/i915-perf/i915-perf-recorder.
[1668/1682] Linking target tools/i915-perf/i915-perf-reader.
[1669/1682] Linking target tests/core_hotunplug.
[1670/1682] Linking target tests/gem_barrier_race.
[1671/1682] Linking target tests/perf.
[1672/1682] Generating core_hotunplug.testlist with a meson_exe.py custom command.
[1673/1682] Generating gem_barrier_race.testlist with a meson_exe.py custom command.
[1674/1682] Generating perf.testlist with a meson_exe.py custom command.
[1675/1682] Generating xe_tests.rst with a custom command.
FAILED: docs/testplan/xe_tests.rst
/usr/src/igt-gpu-tools/scripts/igt_doc.py --config /usr/src/igt-gpu-tools/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /opt/igt/build
Warning: igt@xe_svm@svm-atomic-access Category documentation is missing
Warning: igt@xe_svm@svm-basic-malloc Category documentation is missing
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
[1676/1682] Generating i915_tests.rst with a custom command.
[1677/1682] Generating kms_tests.rst with a custom command.
[1678/1682] Generating intel-ci-tests with a custom command.
ninja: build stopped: subcommand failed.
^ permalink raw reply [flat|nested] 16+ messages in thread
* ✗ GitLab.Pipeline: warning for helper function (rev2)
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (10 preceding siblings ...)
2024-05-14 7:52 ` ✗ Fi.CI.BUILD: failure for helper function (rev2) Patchwork
@ 2024-05-14 7:58 ` Patchwork
2024-05-15 17:29 ` [PATCH i-g-t v2 00/10] helper function Kamil Konieczny
12 siblings, 0 replies; 16+ messages in thread
From: Patchwork @ 2024-05-14 7:58 UTC (permalink / raw)
To: Bommu Krishnaiah; +Cc: igt-dev
== Series Details ==
Series: helper function (rev2)
URL : https://patchwork.freedesktop.org/series/133096/
State : warning
== Summary ==
Pipeline status: FAILED.
see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1177054 for the overview.
build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697849):
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1715673253:step_script
section_start:1715673253:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673254:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-armhf has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697851):
^
../lib/xe/xe_util.c: In function ‘xe_destroy_buffer’:
../lib/xe/xe_util.c:80:15: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
sync->addr = (uint64_t)buffer->bind_ufence;
^
../lib/xe/xe_util.c:82:68: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
xe_vm_unbind_async(buffer->fd, buffer->vm, buffer->bind_queue, 0, (uint64_t)buffer->gpu_addr, buffer->size, sync, 1);
^
../lib/xe/xe_util.c: In function ‘xe_cmdbuf_exec_ufence_gpuva’:
../lib/xe/xe_util.c:191:9: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
return (uint64_t)cmd_buf->gpu_addr + cmd_buf->size - 8;
^
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1715673195:step_script
section_start:1715673195:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673196:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697853):
^
../lib/xe/xe_util.c: In function ‘xe_destroy_buffer’:
../lib/xe/xe_util.c:80:15: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
sync->addr = (uint64_t)buffer->bind_ufence;
^
../lib/xe/xe_util.c:82:68: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
xe_vm_unbind_async(buffer->fd, buffer->vm, buffer->bind_queue, 0, (uint64_t)buffer->gpu_addr, buffer->size, sync, 1);
^
../lib/xe/xe_util.c: In function ‘xe_cmdbuf_exec_ufence_gpuva’:
../lib/xe/xe_util.c:191:9: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
return (uint64_t)cmd_buf->gpu_addr + cmd_buf->size - 8;
^
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1715673195:step_script
section_start:1715673195:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673196:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697844):
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1715673241:step_script
section_start:1715673241:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673242:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697848):
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1715673267:step_script
section_start:1715673267:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673268:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697847):
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1715673249:step_script
section_start:1715673249:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673249:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697845):
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1715673238:step_script
section_start:1715673238:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673239:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/58697846):
Warning: igt@xe_svm@svm-basic-mmap Category documentation is missing
Warning: igt@xe_svm@svm-benchmark Category documentation is missing
Warning: igt@xe_svm@svm-huge-page Category documentation is missing
Warning: igt@xe_svm@svm-mprotect Category documentation is missing
Warning: igt@xe_svm@svm-random-access Category documentation is missing
Warning: igt@xe_svm@svm-sparse-access Category documentation is missing
Warning: igt@xe_svm@svm_invalid_va Category documentation is missing
Warning: igt@xe_svm@xe_basic Category documentation is missing
Warning: Documented igt@xe_svm@svm_invalid_va doesn't exist on source files
Warning: Documented igt@xe_svm@xe_basic doesn't exist on source files
Warning: Missing documentation for igt@xe_svm@svm-invalid-va
Warning: Missing documentation for igt@xe_svm@xe-basic
Please refer: docs/test_documentation.md for more details
ninja: build stopped: subcommand failed.
section_end:1715673238:step_script
section_start:1715673238:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1715673239:cleanup_file_variables
ERROR: Job failed: exit code 1
== Logs ==
For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1177054
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH i-g-t v2 06/10] tests/intel/xe_svm: svm_atomic_access
2024-05-14 7:10 ` [PATCH i-g-t v2 06/10] tests/intel/xe_svm: svm_atomic_access Bommu Krishnaiah
@ 2024-05-14 8:14 ` Lisovskiy, Stanislav
0 siblings, 0 replies; 16+ messages in thread
From: Lisovskiy, Stanislav @ 2024-05-14 8:14 UTC (permalink / raw)
To: Bommu Krishnaiah; +Cc: igt-dev, Oak Zeng, Himal Prasad Ghimiray
On Tue, May 14, 2024 at 12:40:22PM +0530, Bommu Krishnaiah wrote:
> Verify GPU atomic access any location in malloc'ed memory by using svm
Shouldn't we somehow also explicitly ensure, that GPU malloc'ed memory
access is indeed atomic?
Current test just checks that GPU actually does the increment.
However if that is supposed to be atomic, we probably need to do
something like modifying it from multiple threads and then end result,
should be then incremented twice or something like that?
Otherwise not clear, what is meant by "atomicity" here.
Stan
>
> Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
> Cc: Oak Zeng <oak.zeng@intel.com>
> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> lib/xe/xe_util.c | 17 +++++++++++++++++
> lib/xe/xe_util.h | 1 +
> tests/intel/xe_svm.c | 39 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 57 insertions(+)
>
> diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
> index 1bdb5fa08..0e28c0093 100644
> --- a/lib/xe/xe_util.c
> +++ b/lib/xe/xe_util.c
> @@ -107,6 +107,23 @@ void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val)
> batch[++i] = MI_BATCH_BUFFER_END;
> }
>
> +/*
> +a command buffer is a buffer in GT0's vram, filled with gpu commands,
> +plus some memory for a ufence used to sync command submission
> +*/
> +void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val)
> +{
> + int i = 0;
> +
> + //suppress compiler warning
> + (void)(val);
> +
> + batch[i] = MI_STORE_DWORD_IMM_GEN4;
> + batch[++i] = dst_va;
> + batch[++i] = dst_va >> 32;
> + batch[++i] = MI_BATCH_BUFFER_END;
> +}
> +
> void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func, uint64_t dst_va, uint32_t val, struct drm_xe_engine_class_instance *eci)
> {
> //make some room for a exec_ufence, which will be used to sync the
> diff --git a/lib/xe/xe_util.h b/lib/xe/xe_util.h
> index c38f79e60..46e1ccc9a 100644
> --- a/lib/xe/xe_util.h
> +++ b/lib/xe/xe_util.h
> @@ -40,6 +40,7 @@ void xe_create_cmdbuf(struct xe_buffer *cmd_buf, cmdbuf_fill_func_t fill_func,
> uint64_t xe_cmdbuf_exec_ufence_gpuva(struct xe_buffer *cmd_buf);
> uint64_t *xe_cmdbuf_exec_ufence_cpuva(struct xe_buffer *cmd_buf);
> void insert_store(uint32_t *batch, uint64_t dst_va, uint32_t val);
> +void insert_atomic_inc(uint32_t *batch, uint64_t dst_va, uint32_t val);
> void xe_submit_cmd(struct xe_buffer *cmdbuf);
> int64_t __xe_submit_cmd(struct xe_buffer *cmdbuf);
> void xe_destroy_buffer(struct xe_buffer *buffer);
> diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
> index 4f2818cc8..421d7fd1a 100644
> --- a/tests/intel/xe_svm.c
> +++ b/tests/intel/xe_svm.c
> @@ -30,6 +30,8 @@
> * Description: verify SVM basic functionality by using randomly access any location in malloc'ed memory
> * SUBTEST: svm-huge-page
> * Description: verify SVM basic functionality by using huge page access
> + * SUBTEST: svm-atomic-access
> + * Description: verify SVM basic functionality by using GPU atomic access any location in malloc'ed memory
> */
>
> #include <fcntl.h>
> @@ -189,6 +191,39 @@ static void svm_thp(int fd, uint32_t vm, struct drm_xe_engine_class_instance *ec
> free(dst);
> }
>
> +/**
> + * Test GPU atomic access any location in malloc'ed memory
> + */
> +static void svm_atomic_access(int fd, uint32_t vm, struct drm_xe_engine_class_instance *eci)
> +{
> + uint64_t gpu_va = 0x1a0000;
> + int val = 0xc0ffee;
> + 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 = aligned_alloc(xe_get_default_alignment(fd), size);
> + dst_to_access = dst + random()%sz_dw;
> + *dst_to_access = val;
> +
> + xe_create_cmdbuf(&cmd_buf, insert_atomic_inc, (uint64_t)dst_to_access, val, eci);
> + xe_submit_cmd(&cmd_buf);
> +
> + igt_assert_eq(*dst_to_access, val + 1);
> +
> + xe_destroy_cmdbuf(&cmd_buf);
> + free(dst);
> +}
> +
> igt_main
> {
> int fd;
> @@ -223,6 +258,10 @@ igt_main
> xe_for_each_engine(fd, hwe)
> svm_thp(fd, vm, hwe);
>
> + igt_subtest_f("svm-atomic-access")
> + xe_for_each_engine(fd, hwe)
> + svm_atomic_access(fd, vm, hwe);
> +
> igt_fixture {
> xe_vm_destroy(fd, vm);
> drm_close_driver(fd);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH i-g-t v2 00/10] helper function
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
` (11 preceding siblings ...)
2024-05-14 7:58 ` ✗ GitLab.Pipeline: warning " Patchwork
@ 2024-05-15 17:29 ` Kamil Konieczny
12 siblings, 0 replies; 16+ messages in thread
From: Kamil Konieczny @ 2024-05-15 17:29 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah
Hi Bommu,
On 2024-05-14 at 12:40:16 +0530, Bommu Krishnaiah wrote:
> Introduce helper functions for object creation, binding, submission,
> and destruction, applicable for SVM and other tests
>
> xe-basic test is validating the helper function introduced in 'lib/xe/xe_util: helper function'
>
> svm test cases:
> svm-basic-malloc
> svm-basic-mmap
> svm-random-access
> svm-huge-page
> svm-atomic-access
> svm-atomic-access
> svm_invalid_va
---- ^
No underscores in tests names.
> svm-mprotect
> svm-benchmark
> svm-sparse-access
>
> svm kernel implimentation:
> https://gitlab.freedesktop.org/oak/xe-kernel-driver-svm.git
> branch: origin/drm-xe-next-svm-unify-userptr
>
Please improve and then resend with another subject, 'helper function'
is misleading. What about 'Add tests for Shared Virtual Memory (SVM)'?
>
> Bommu Krishnaiah (10):
> lib/xe/xe_util: Introduce helper functions for buffer creation and
> command submission etc
> tests/intel/xe_svm: basic xe_svm test
> tests/xe_svm: basic svm test
> tests/intel/xe_svm: svm_random_access
-------------------------- ^
svm-random-access
> tests/intel/xe_svm: svm-huge-page
> tests/intel/xe_svm: svm_atomic_access
-------------------------- ^
svm-atomic-access
> tests/intel/xe_svm: svm-invalid-va
> tests/intel/xe_svm: svm_benchmark
svm-benchmark
> tests/intel/xe_svm: svm_mprotect
svm-mprotect
> tests/intel/xe_svm: svm-sparse-access
Regards,
Kamil
>
> include/drm-uapi/xe_drm.h | 2 +
> lib/xe/xe_util.c | 186 +++++++++++++++++
> lib/xe/xe_util.h | 40 ++++
> tests/intel/xe_svm.c | 427 ++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 5 files changed, 656 insertions(+)
> create mode 100644 tests/intel/xe_svm.c
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test
2024-05-14 7:10 ` [PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test Bommu Krishnaiah
@ 2024-05-15 17:38 ` Kamil Konieczny
0 siblings, 0 replies; 16+ messages in thread
From: Kamil Konieczny @ 2024-05-15 17:38 UTC (permalink / raw)
To: igt-dev; +Cc: Bommu Krishnaiah, Oak Zeng, Himal Prasad Ghimiray
Hi Bommu,
On 2024-05-14 at 12:40:19 +0530, Bommu Krishnaiah wrote:
please imprve subject:
[PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test
imho better:
[PATCH i-g-t v2 03/10] tests/intel/xe_svm: add basic svm test
> Test will verify SVM basic functionality, by allocating a memory with
> system allocator(malloc() or mmap()) and accessing in GPU.
Please describe it more here, how you will verify it.
imho basic test could just access it using pointer from malloc.
>
> Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
> Cc: Oak Zeng <oak.zeng@intel.com>
> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> include/drm-uapi/xe_drm.h | 2 ++
> tests/intel/xe_svm.c | 57 +++++++++++++++++++++++++++++++++++++--
> 2 files changed, 57 insertions(+), 2 deletions(-)
>
> diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h
> index 0b709b374..228bc2974 100644
> --- a/include/drm-uapi/xe_drm.h
> +++ b/include/drm-uapi/xe_drm.h
> @@ -973,6 +973,8 @@ struct drm_xe_vm_bind_op {
> #define DRM_XE_VM_BIND_FLAG_IMMEDIATE (1 << 1)
> #define DRM_XE_VM_BIND_FLAG_NULL (1 << 2)
> #define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)
> +#define DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR (1 << 4)
> +
> /** @flags: Bind flags */
> __u32 flags;
>
> diff --git a/tests/intel/xe_svm.c b/tests/intel/xe_svm.c
> index 7d0892a3d..2daed1eff 100644
> --- a/tests/intel/xe_svm.c
> +++ b/tests/intel/xe_svm.c
> @@ -14,8 +14,18 @@
> */
>
> /**
> - * TEST: xe_basic
> + * TEST: xe_svm
Do not do this, make this correct from beginning in
previous patch.
> + * Description: Test shared virtual memory
> + * Sub-category: Memory management
> + * Functionality: svm
> + * Run type: FULL
Add also Mega feature:
> + *
> + * SUBTEST: xe_basic
-------------- ^^^
imho this would be svm-basic-gpu-access
> * Description: Basic test to verify store dword by using helper funtions
Add newline.
> + * SUBTEST: svm-basic-malloc
> + * Description: verify SVM basic functionality by using malloc
Add newline.
> + * SUBTEST: svm-basic-mmap
> + * Description: verify SVM basic functionality by using mmap
> */
>
> #include <fcntl.h>
> @@ -67,6 +77,40 @@ static void xe_basic(int fd, uint32_t vm, struct drm_xe_engine_class_instance *e
> xe_destroy_buffer(&dst_buf);
> }
>
> +/**
> + * Use malloc or mmap memory for direct GPU submission
> + */
> +static void svm_basic(int fd, uint32_t vm, struct drm_xe_engine_class_instance *eci, bool test_mmap)
> +{
> + uint64_t gpu_va = 0x1a0000;
> + size_t bo_size = xe_bb_size(fd, PAGE_ALIGN_UFENCE);
> + uint32_t *dst;
> +
> + 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,
> + };
> +
> + if (test_mmap)
> + dst = mmap(NULL, 4, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
> + else
> + dst = aligned_alloc(xe_get_default_alignment(fd), 4);
> +
> + xe_create_cmdbuf(&cmd_buf, insert_store, (uint64_t)dst, 0xc0ffee, eci);
> + xe_submit_cmd(&cmd_buf);
> + igt_assert_eq(*dst, 0xc0ffee);
> + xe_destroy_cmdbuf(&cmd_buf);
> +
> + if (test_mmap)
> + munmap(dst, 4);
> + else
> + free(dst);
> +}
> +
> igt_main
> {
> int fd;
> @@ -77,13 +121,22 @@ igt_main
> fd = drm_open_driver(DRIVER_XE);
> igt_require(xe_supports_faults(fd));
> vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
> + __xe_vm_bind_assert(fd, vm, 0, 0, 0, 0, 0x1ull << 47, DRM_XE_VM_BIND_OP_MAP,
> + DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR, 0, 0, 0, 0);
> }
>
> -
Remove this in previous patch.
Regards,
Kamil
> igt_subtest_f("xe-basic")
> xe_for_each_engine(fd, hwe)
> xe_basic(fd, vm, hwe);
>
> + igt_subtest_f("svm-basic-malloc")
> + xe_for_each_engine(fd, hwe)
> + svm_basic(fd, vm, hwe, false);
> +
> + igt_subtest_f("svm-basic-mmap")
> + xe_for_each_engine(fd, hwe)
> + svm_basic(fd, vm, hwe, true);
> +
> igt_fixture {
> xe_vm_destroy(fd, vm);
> drm_close_driver(fd);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-05-15 17:38 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14 7:10 [PATCH i-g-t v2 00/10] helper function Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 01/10] lib/xe/xe_util: Introduce helper functions for buffer creation and command submission etc Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 02/10] tests/intel/xe_svm: basic xe_svm test Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test Bommu Krishnaiah
2024-05-15 17:38 ` Kamil Konieczny
2024-05-14 7:10 ` [PATCH i-g-t v2 04/10] tests/intel/xe_svm: svm_random_access Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 05/10] tests/intel/xe_svm: svm-huge-page Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 06/10] tests/intel/xe_svm: svm_atomic_access Bommu Krishnaiah
2024-05-14 8:14 ` Lisovskiy, Stanislav
2024-05-14 7:10 ` [PATCH i-g-t v2 07/10] tests/intel/xe_svm: svm-invalid-va Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 08/10] tests/intel/xe_svm: svm_benchmark Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 09/10] tests/intel/xe_svm: svm_mprotect Bommu Krishnaiah
2024-05-14 7:10 ` [PATCH i-g-t v2 10/10] tests/intel/xe_svm: svm-sparse-access Bommu Krishnaiah
2024-05-14 7:52 ` ✗ Fi.CI.BUILD: failure for helper function (rev2) Patchwork
2024-05-14 7:58 ` ✗ GitLab.Pipeline: warning " Patchwork
2024-05-15 17:29 ` [PATCH i-g-t v2 00/10] helper function Kamil Konieczny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox