[PATCH i-g-t v2 03/10] tests/xe_svm: basic svm test

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed May 15 17:38:46 UTC 2024


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 at intel.com>
> Cc: Oak Zeng <oak.zeng at intel.com>
> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray at 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
> 


More information about the igt-dev mailing list