Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Bommu Krishnaiah <krishnaiah.bommu@intel.com>,
	Oak Zeng <oak.zeng@intel.com>,
	Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Subject: [PATCH i-g-t v3 02/10] tests/intel/xe_svm: basic xe-basic test
Date: Fri, 17 May 2024 17:16:50 +0530	[thread overview]
Message-ID: <20240517114658.810283-3-krishnaiah.bommu@intel.com> (raw)
In-Reply-To: <20240517114658.810283-1-krishnaiah.bommu@intel.com>

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 | 99 ++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build    |  1 +
 2 files changed, 100 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..6302af95b
--- /dev/null
+++ b/tests/intel/xe_svm.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: MIT
+ /*
+  * Copyright © 2024 Intel Corporation
+  */
+
+/** @file xe_svm.c
+ *
+ * Test shared virtual memory.
+ *
+ * Shared virtual memory (SVM) 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-svm
+ * Description: Test shared virtual memory
+ * Sub-category: Memory management
+ * Functionality: svm
+ *
+ * SUBTEST: xe-basic
+ * Description: Basic test to verify store dword functionality using helper functions
+ */
+
+#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"
+
+/**
+ *  @brief Verifies basic workload execution on the GPU.
+ *
+ * This function tests writing a value to a GPU buffer using the helper functions
+ * for command submission and buffer management.
+ */
+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


  parent reply	other threads:[~2024-05-17 11:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17 11:46 [PATCH i-g-t v3 00/10] tests/intel/xe_svm: Add tests for Shared Virtual Memory (SVM) Bommu Krishnaiah
2024-05-17 11:46 ` [PATCH i-g-t v3 01/10] lib/xe/xe_util: Introduce helper functions for buffer creation and command submission etc Bommu Krishnaiah
2024-05-17 14:09   ` Zeng, Oak
2024-05-17 18:05   ` Kamil Konieczny
2024-05-17 11:46 ` Bommu Krishnaiah [this message]
2024-05-17 14:23   ` [PATCH i-g-t v3 02/10] tests/intel/xe_svm: basic xe-basic test Zeng, Oak
2024-05-20  8:51     ` Piecielska, Katarzyna
2024-05-17 11:46 ` [PATCH i-g-t v3 03/10] tests/intel/xe_svm: Add SVM basic tests using malloc and mmap Bommu Krishnaiah
2024-05-17 14:39   ` Zeng, Oak
2024-05-17 17:07     ` Bommu, Krishnaiah
2024-05-17 11:46 ` [PATCH i-g-t v3 04/10] tests/intel/xe_svm: add random access test for SVM Bommu Krishnaiah
2024-05-17 14:48   ` Zeng, Oak
2024-05-17 11:46 ` [PATCH i-g-t v3 05/10] tests/intel/xe_svm: add huge page " Bommu Krishnaiah
2024-05-18  2:01   ` Zeng, Oak
2024-05-17 11:46 ` [PATCH i-g-t v3 06/10] tests/intel/xe_svm: Add support for GPU atomic access test for svm Bommu Krishnaiah
2024-05-18  2:16   ` Zeng, Oak
2024-05-17 11:46 ` [PATCH i-g-t v3 07/10] tests/intel/xe_svm: Add svm-invalid-va test to verify SVM functionality with invalid address access Bommu Krishnaiah
2024-05-18  2:19   ` Zeng, Oak
2024-05-17 11:46 ` [PATCH i-g-t v3 08/10] tests/intel/xe_svm: Add svm-benchmark test to measure SVM performance with a simple benchmark Bommu Krishnaiah
2024-05-18  2:27   ` Zeng, Oak
2024-05-17 11:46 ` [PATCH i-g-t v3 09/10] tests/intel/xe_svm: Add svm-mprotect test to verify SVM functionality with read-only memory access Bommu Krishnaiah
2024-05-17 11:46 ` [PATCH i-g-t v3 10/10] tests/intel/xe_svm: Add svm-sparse-access test to verify sparsely accessing two memory locations with SVM Bommu Krishnaiah
2024-05-17 12:35 ` ✗ GitLab.Pipeline: warning for tests/intel/xe_svm: Add tests for Shared Virtual Memory (SVM) Patchwork
2024-05-17 12:52 ` ✓ CI.xeBAT: success " Patchwork
2024-05-17 13:06 ` ✓ Fi.CI.BAT: " Patchwork
2024-05-17 14:48 ` ✗ CI.xeFULL: failure " Patchwork
2024-05-17 20:00 ` ✗ Fi.CI.IGT: " Patchwork
2024-05-22 11:38 ` [PATCH i-g-t v3 00/10] " Matthew Brost
2024-05-22 11:42   ` Matthew Brost
2024-05-22 16:53     ` Zeng, Oak
2024-05-23 17:26       ` Matthew Brost
2024-05-24  3:12         ` Zeng, Oak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240517114658.810283-3-krishnaiah.bommu@intel.com \
    --to=krishnaiah.bommu@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=oak.zeng@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox