Skip to contentSkip to conversation

tests/xe/xe_store: Add xe_store test to check store dword functionality

PATCH In review [email protected] 2 participants 3 messages Jun 26, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/xe/xe_store: Add xe_store test to check store dword functionality

From: Sai Gowtham Ch <[email protected]>

Adding xe_store test to valide store dword funtionality, this has basic test and test which runs on all the available engines.

---
 tests/meson.build   |   1 +
 tests/xe/xe_store.c | 173 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 174 insertions(+)
 create mode 100644 tests/xe/xe_store.c
tests/meson.build +1 -0
index 85ea7e74..2874be77 100644
@@ -267,6 +267,7 @@ xe_progs = [
 	'xe_pm',
 	'xe_prime_self_import',
 	'xe_query',
+	'xe_store',
 	'xe_vm',
 	'xe_waitfence',
 	'xe_spin_batch',
tests/xe/xe_store.c new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
2.39.1
#1 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/xe/xe_store: Add xe_store test to check store dword functionality

== Series Details ==

== Series Details ==

Series: tests/xe/xe_store: Add xe_store test to check store dword functionality
URL : https://patchwork.freedesktop.org/series/119857/
State : failure

== Summary ==

IGT patchset build failed on latest successful build feb4fdbcce1e53cb1d483aad3d5ec4ff41092359 lib/intel_blt: Prepare blt library to support xe

[343/662] Linking target tests/xe_live_ktest.
[344/662] Linking target tests/xe_mmap.
[345/662] Linking target tests/xe_mmio.
[346/662] Linking target tests/xe_module_load.
[347/662] Compiling C object 'tests/59830eb@@xe_store@exe/xe_xe_store.c.o'.
FAILED: tests/59830eb@@xe_store@exe/xe_xe_store.c.o
cc -Itests/59830eb@@xe_store@exe -Itests -I../../../usr/src/igt-gpu-tools/tests -I../../../usr/src/igt-gpu-tools/include -I../../../usr/src/igt-gpu-tools/include/drm-uapi -I../../../usr/src/igt-gpu-tools/include/linux-uapi -Ilib -I../../../usr/src/igt-gpu-tools/lib -I../../../usr/src/igt-gpu-tools/lib/stubs/syscalls -I. -I../../../usr/src/igt-gpu-tools/ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/x86_64-linux-gnu -I/usr/include/valgrind -I/usr/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -pthread -MD -MQ 'tests/59830eb@@xe_store@exe/xe_xe_store.c.o' -MF 'tests/59830eb@@xe_store@exe/xe_xe_store.c.o.d' -o 'tests/59830eb@@xe_store@exe/xe_xe_store.c.o' -c ../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c ../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c: In function ‘store’:
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:47:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

   47 |  uint64_t batch_offset = (char *)&(data->batch) - (char *)data;
      |  ^~~~~~~~
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c: In function ‘store_all’:
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:105:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  105 |  uint64_t batch_offset = (char *)&(data->batch) - (char *)data;
      |  ^~~~~~~~
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:137:20: error: ‘engine’ undeclared (first use in this function); did you mean ‘engines’?
  137 |   xe_exec_wait(fd, engine[i], batch_addr);
      |                    ^~~~~~
      |                    engines
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:137:20: note: each undeclared identifier is reported only once for each function it appears in
In file included from ../../../usr/src/igt-gpu-tools/lib/drmtest.h:39,
                 from ../../../usr/src/igt-gpu-tools/lib/igt.h:27,
                 from ../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:1:

../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:138:24: error: invalid type argument of ‘->’ (have ‘struct <anonymous>’)
138 | igt_assert_eq(data[i]->data, 0xc0ffee);
| ^~
../../../usr/src/igt-gpu-tools/lib/igt_core.h:737:15: note: in definition of macro ‘igt_assert_cmpint’
737 | int __n1 = (n1), __n2 = (n2); \
| ^~
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:138:3: note: in expansion of macro ‘igt_assert_eq’

  138 |   igt_assert_eq(data[i]->data, 0xc0ffee);
      |   ^~~~~~~~~~~~~
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:86:11: warning: variable ‘engines’ set but not used [-Wunused-but-set-variable]
   86 |  uint32_t engines[MAX_INSTANCE];
      |           ^~~~~~~

In file included from ../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:4:
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c: In function ‘__igt_unique____real_main151’:
../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:166:22: error: ‘gt’ undeclared (first use in this function)
166 | xe_for_each_gt(fd, gt)
| ^~
../../../usr/src/igt-gpu-tools/lib/xe/xe_query.h:70:7: note: in definition of macro ‘xe_for_each_gt’
70 | for (__gt = 0; __gt < xe_number_gt(__fd); ++__gt)

      |       ^~~~

../../../usr/src/igt-gpu-tools/tests/xe/xe_store.c:167:32: error: ‘class’ undeclared (first use in this function)
167 | xe_for_each_hw_engine_class(class)
| ^~~~~
../../../usr/src/igt-gpu-tools/lib/xe/xe_query.h:67:7: note: in definition of macro ‘xe_for_each_hw_engine_class’

   67 |  for (__class = 0; __class < DRM_XE_ENGINE_CLASS_COMPUTE + 1; \
      |       ^~~~~~~

ninja: build stopped: subcommand failed.

#2 lore raw
In reply to [email protected]

Resending the patch series again, Please ignore the patch.

--
Gowtham

Quoted 211 lines

-----Original Message-----
From: Ch, Sai Gowtham <[email protected]>
Sent: Monday, June 26, 2023 4:21 PM
To: [email protected]; Ch, Sai Gowtham <[email protected]>
Subject: [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality

From: Sai Gowtham Ch <[email protected]>

Adding xe_store test to valide store dword funtionality, this has basic test and test which runs on all the available engines.

---
 tests/meson.build   |   1 +
 tests/xe/xe_store.c | 173
++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 174 insertions(+)
 create mode 100644 tests/xe/xe_store.c
tests/meson.build index 85ea7e74..2874be77 renamed from tests/meson.build +0 -0

100644

tests/meson.build +1 -0
@@ -267,6 +267,7 @@ xe_progs = [
 	'xe_pm',
 	'xe_prime_self_import',
 	'xe_query',
+	'xe_store',
 	'xe_vm',
 	'xe_waitfence',
 	'xe_spin_batch',
tests/xe/xe_store.c new file +171 -1
index 00000000..bb2e5319
@@ -0,0 +1,173 @@
+#include "igt.h"
+#include "lib/igt_syncobj.h"
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
+#include "xe_drm.h"
+
+/**
+ * TEST: Tests to verify store dword functionality.
+ * Category: Software building block
+ * Sub-category: spin
+ * Functionality: intel-bb
+ * Test category: functionality test
+ */
+
+#define MAX_INSTANCE 9
+
+/**
+ * SUBTEST: basic-store
+ * Description: Basic test to verify store dword.
+ * Run type: FULL
+ */
+static void store(int fd, struct drm_xe_engine_class_instance *hwe) {
+	struct {
+		uint32_t batch[16];
+		uint64_t pad;
+		uint32_t data;
+	} *data;
+	uint32_t vm;
+	uint32_t engine;
+	size_t bo_size;
+	uint64_t addr = 0x100000;
+	uint32_t bo = 0;
+	int b;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+
+	bo_size = sizeof(*data);
+	bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+				xe_get_default_alignment(fd));
+
+	bo = xe_bo_create(fd, 0, vm, bo_size);
+	data = xe_bo_map(fd, bo, bo_size);
+
+	xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+	uint64_t batch_offset = (char *)&(data->batch) - (char *)data;
+	uint64_t batch_addr = addr + batch_offset;
+	uint64_t sdi_offset = (char *)&(data->data) - (char *)data;
+	uint64_t sdi_addr = addr + sdi_offset;
+
+	b = 0;
+	data->batch[b++] = MI_STORE_DWORD_IMM_GEN4;
+	data->batch[b++] = sdi_addr;
+	data->batch[b++] = sdi_addr >> 32;
+	data->batch[b++] = 0x123456;
+	data->batch[b++] = MI_BATCH_BUFFER_END;
+	igt_assert(b <= ARRAY_SIZE(data->batch));
+
+	engine = xe_engine_create(fd, vm, hwe, 0);
+	xe_exec_wait(fd, engine, batch_addr);
+
+	igt_assert_eq(data->data, 0x123456);
+
+	xe_vm_unbind_sync(fd, vm, 0, addr, bo_size);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	xe_engine_destroy(fd, engine);
+	xe_vm_destroy(fd, vm);
+}
+
+/**
+ * SUBTEST: spin-basic
+ * Description: Test to verify store dword on all available engine.
+ * Run type: BAT
+ */
+static void store_all(int fd, int gt, int class) {
+	struct {
+		uint32_t batch[16];
+		uint64_t pad;
+		uint32_t data;
+	} *data;
+	uint32_t vm;
+	uint32_t engines[MAX_INSTANCE];
+	size_t bo_size;
+	uint64_t addr = 0x100000;
+	uint32_t bo = 0;
+	struct drm_xe_engine_class_instance eci[MAX_INSTANCE];
+	struct drm_xe_engine_class_instance *hwe;
+	int b, i, num_placements = 0;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_ASYNC_BIND_OPS, 0);
+
+	bo_size = sizeof(*data);
+	bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+				xe_get_default_alignment(fd));
+
+	bo = xe_bo_create(fd, 0, vm, bo_size);
+	data = xe_bo_map(fd, bo, bo_size);
+
+	xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+	uint64_t batch_offset = (char *)&(data->batch) - (char *)data;
+	uint64_t batch_addr = addr + batch_offset;
+	uint64_t sdi_offset = (char *)&(data->data) - (char *)data;
+	uint64_t sdi_addr = addr + sdi_offset;
+
+	b = 0;
+	data->batch[b++] = MI_STORE_DWORD_IMM_GEN4;
+	data->batch[b++] = sdi_addr;
+	data->batch[b++] = sdi_addr >> 32;
+	data->batch[b++] = 0xc0ffee;
+	data->batch[b++] = MI_BATCH_BUFFER_END;
+	igt_assert(b <= ARRAY_SIZE(data->batch));
+
+	xe_for_each_hw_engine(fd, hwe) {
+		if (hwe->engine_class != class || hwe->gt_id != gt)
+			continue;
+		eci[num_placements++] = *hwe;
+	}
+	if (num_placements < 2)
+		return;
+
+	for (i = 0; i < num_placements; i++) {
+		struct drm_xe_engine_create create = {
+			.vm_id = vm,
+			.width = 1,
+			.num_placements = num_placements,
+			.instances = to_user_pointer(eci),
+		};
+
+		igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_ENGINE_CREATE,
+					&create), 0);
+		engines[i] = create.engine_id;
+		xe_exec_wait(fd, engine[i], batch_addr);
+		igt_assert_eq(data[i]->data, 0xc0ffee);
+	}
+
+	xe_vm_unbind_sync(fd, vm, 0, addr, bo_size);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	for (i = 0; i < num_placements; i++) {
+		xe_engine_destroy(fd, engine[i]);
+	}
+	xe_vm_destroy(fd, vm);
+}
+
+igt_main
+{
+	struct drm_xe_engine_class_instance *hwe;
+	int fd;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_XE);
+		xe_device_get(fd);
+	}
+
+	igt_subtest("basic-store")
+		xe_for_each_hw_engine(fd, hwe)
+			store(fd, hwe);
+
+	igt_subtest("basic-all") {
+		xe_for_each_gt(fd, gt)
+			xe_for_each_hw_engine_class(class)
+				store_all(fd, gt, class);
+	}
+
+	igt_fixture
+		close(fd);
+}
--

2.39.1