All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality
@ 2023-06-26 10:51 sai.gowtham.ch
  2023-06-26 11:16 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
  2023-06-26 13:12 ` [igt-dev] [PATCH i-g-t] " Ch, Sai Gowtham
  0 siblings, 2 replies; 6+ messages in thread
From: sai.gowtham.ch @ 2023-06-26 10:51 UTC (permalink / raw)
  To: igt-dev, sai.gowtham.ch

From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>

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

Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
---
 tests/meson.build   |   1 +
 tests/xe/xe_store.c | 173 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 174 insertions(+)
 create mode 100644 tests/xe/xe_store.c

diff --git a/tests/meson.build b/tests/meson.build
index 85ea7e74..2874be77 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -267,6 +267,7 @@ xe_progs = [
 	'xe_pm',
 	'xe_prime_self_import',
 	'xe_query',
+	'xe_store',
 	'xe_vm',
 	'xe_waitfence',
 	'xe_spin_batch',
diff --git a/tests/xe/xe_store.c b/tests/xe/xe_store.c
new file mode 100644
index 00000000..bb2e5319
--- /dev/null
+++ b/tests/xe/xe_store.c
@@ -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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [igt-dev] ✗ Fi.CI.BUILD: failure for tests/xe/xe_store: Add xe_store test to check store dword functionality
  2023-06-26 10:51 [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality sai.gowtham.ch
@ 2023-06-26 11:16 ` Patchwork
  2023-06-26 13:12 ` [igt-dev] [PATCH i-g-t] " Ch, Sai Gowtham
  1 sibling, 0 replies; 6+ messages in thread
From: Patchwork @ 2023-06-26 11:16 UTC (permalink / raw)
  To: sai.gowtham.ch; +Cc: igt-dev

== 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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality
  2023-06-26 10:51 [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality sai.gowtham.ch
  2023-06-26 11:16 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
@ 2023-06-26 13:12 ` Ch, Sai Gowtham
  1 sibling, 0 replies; 6+ messages in thread
From: Ch, Sai Gowtham @ 2023-06-26 13:12 UTC (permalink / raw)
  To: igt-dev

Resending the patch series again,  Please ignore the patch.

--
Gowtham

> -----Original Message-----
> From: Ch, Sai Gowtham <sai.gowtham.ch@intel.com>
> Sent: Monday, June 26, 2023 4:21 PM
> To: igt-dev@lists.freedesktop.org; Ch, Sai Gowtham
> <sai.gowtham.ch@intel.com>
> Subject: [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword
> functionality
> 
> From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> 
> Adding xe_store test to valide store dword funtionality, this has basic test and
> test which runs on all the available engines.
> 
> Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> ---
>  tests/meson.build   |   1 +
>  tests/xe/xe_store.c | 173
> ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 174 insertions(+)
>  create mode 100644 tests/xe/xe_store.c
> 
> diff --git a/tests/meson.build b/tests/meson.build index 85ea7e74..2874be77
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -267,6 +267,7 @@ xe_progs = [
>  	'xe_pm',
>  	'xe_prime_self_import',
>  	'xe_query',
> +	'xe_store',
>  	'xe_vm',
>  	'xe_waitfence',
>  	'xe_spin_batch',
> diff --git a/tests/xe/xe_store.c b/tests/xe/xe_store.c new file mode 100644
> index 00000000..bb2e5319
> --- /dev/null
> +++ b/tests/xe/xe_store.c
> @@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality
@ 2023-06-30  6:45 sai.gowtham.ch
  0 siblings, 0 replies; 6+ messages in thread
From: sai.gowtham.ch @ 2023-06-30  6:45 UTC (permalink / raw)
  To: igt-dev, sai.gowtham.ch

From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>

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

Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
---
 tests/meson.build   |   1 +
 tests/xe/xe_store.c | 211 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 212 insertions(+)
 create mode 100644 tests/xe/xe_store.c

diff --git a/tests/meson.build b/tests/meson.build
index 85ea7e74e..2874be775 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -267,6 +267,7 @@ xe_progs = [
 	'xe_pm',
 	'xe_prime_self_import',
 	'xe_query',
+	'xe_store',
 	'xe_vm',
 	'xe_waitfence',
 	'xe_spin_batch',
diff --git a/tests/xe/xe_store.c b/tests/xe/xe_store.c
new file mode 100644
index 000000000..38cfed733
--- /dev/null
+++ b/tests/xe/xe_store.c
@@ -0,0 +1,211 @@
+#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: HW
+ * Functionality: intel-bb
+ * Test category: functionality test
+ */
+
+#define MAX_INSTANCE 9
+
+struct data {
+	uint32_t batch[16];
+	uint64_t pad;
+	uint32_t data;
+	uint64_t addr;
+};
+
+static void store_dword_batch(struct data *data, uint64_t addr)
+{
+	int b;
+	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));
+
+	data->addr = batch_addr;
+}
+
+/**
+ * SUBTEST: basic-store
+ * Description: Basic test to verify store dword.
+ * Run type: FULL
+ */
+static void store(int fd)
+{
+	struct drm_xe_sync sync = {
+		.flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL,
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	struct data *data;
+	struct drm_xe_engine_class_instance *hw_engine;
+	uint32_t vm;
+	uint32_t engine;
+	uint32_t syncobj;
+	size_t bo_size;
+	uint64_t addr = 0x100000;
+	uint32_t bo = 0;
+
+	syncobj = syncobj_create(fd, 0);
+	sync.handle = syncobj;
+
+	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));
+
+	hw_engine = xe_hw_engine(fd, 1);
+	bo = xe_bo_create(fd, hw_engine->gt_id, vm, bo_size);
+
+	xe_vm_bind_async(fd, vm, hw_engine->gt_id, bo, 0, addr, bo_size, &sync, 1);
+	data = xe_bo_map(fd, bo, bo_size);
+	store_dword_batch(data, addr);
+
+	engine = xe_engine_create(fd, vm, hw_engine, 0);
+	exec.engine_id = engine;
+	exec.address = data->addr;
+	sync.flags &= DRM_XE_SYNC_SIGNAL;
+	xe_exec(fd, &exec);
+
+	igt_assert(syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL));
+	igt_assert_eq(data->data, 0x123456);
+
+	syncobj_destroy(fd, syncobj);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	xe_engine_destroy(fd, engine);
+	xe_vm_destroy(fd, vm);
+}
+
+/**
+ * SUBTEST: basic-all
+ * Description: Test to verify store dword on all available engine.
+ * Run type: BAT
+ */
+static void store_all(int fd, int gt, int class)
+{
+	struct drm_xe_sync sync[2] = {
+		{ .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, },
+		{ .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL, }
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 2,
+		.syncs = to_user_pointer(&sync),
+	};
+
+	struct data *data;
+	uint32_t syncobjs[MAX_INSTANCE];
+	uint32_t engines[MAX_INSTANCE];
+	uint32_t vm;
+	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 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_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;
+
+	store_dword_batch(data, addr);
+
+	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;
+		syncobjs[i] = syncobj_create(fd, 0);
+	};
+
+	sync[0].handle = syncobj_create(fd, 0);
+	xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, sync, 1);
+
+	for (i = 0; i < num_placements; i++) {
+
+		store_dword_batch(data, addr);
+		sync[0].flags &= ~DRM_XE_SYNC_SIGNAL;
+		sync[1].flags |= DRM_XE_SYNC_SIGNAL;
+		sync[1].handle = syncobjs[i];
+
+		exec.engine_id = engines[i];
+		exec.address = data->addr;
+		xe_exec(fd, &exec);
+
+		igt_assert(syncobj_wait(fd, &syncobjs[i], 1, INT64_MAX, 0, NULL));
+		igt_assert_eq(data->data, 0x123456);
+	}
+
+	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
+	syncobj_destroy(fd, sync[0].handle);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	for (i = 0; i < num_placements; i++) {
+		syncobj_destroy(fd, syncobjs[i]);
+		xe_engine_destroy(fd, engines[i]);
+	}
+	xe_vm_destroy(fd, vm);
+}
+
+igt_main
+{
+	int fd, class, gt;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_XE);
+		xe_device_get(fd);
+	}
+
+	igt_subtest("basic-store")
+		store(fd);
+
+	igt_subtest("basic-all") {
+		xe_for_each_gt(fd, gt)
+			xe_for_each_hw_engine_class(class)
+				store_all(fd, gt, class);
+	}
+
+	igt_fixture {
+		xe_device_put(fd);
+		close(fd);
+	}
+}
-- 
2.39.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality
  2023-06-27 14:11 sai.gowtham.ch
@ 2023-06-28  9:51 ` Kumar, Janga Rahul
  0 siblings, 0 replies; 6+ messages in thread
From: Kumar, Janga Rahul @ 2023-06-28  9:51 UTC (permalink / raw)
  To: Ch, Sai Gowtham, igt-dev, Ch, Sai Gowtham



> -----Original Message-----
> From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of
> sai.gowtham.ch@intel.com
> Sent: 27 June 2023 19:41
> To: igt-dev@lists.freedesktop.org; Ch, Sai Gowtham
> <sai.gowtham.ch@intel.com>
> Subject: [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check
> store dword functionality
> 
> From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> 
> Adding xe_store test to valide store dword funtionality, this has basic test and
> test which runs on all the available engines.
> 
> Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> ---
>  tests/meson.build   |   1 +
>  tests/xe/xe_store.c | 197
> ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 198 insertions(+)
>  create mode 100644 tests/xe/xe_store.c
> 
> diff --git a/tests/meson.build b/tests/meson.build index 85ea7e74..2874be77
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -267,6 +267,7 @@ xe_progs = [
>  	'xe_pm',
>  	'xe_prime_self_import',
>  	'xe_query',
> +	'xe_store',
>  	'xe_vm',
>  	'xe_waitfence',
>  	'xe_spin_batch',
> diff --git a/tests/xe/xe_store.c b/tests/xe/xe_store.c new file mode 100644
> index 00000000..5765c3d8
> --- /dev/null
> +++ b/tests/xe/xe_store.c
Add Copyright information
> @@ -0,0 +1,197 @@
> +#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: HW
> + * Functionality: intel-bb
> + * Test category: functionality test
> + */
> +
> +#define MAX_INSTANCE 9
> +
> +struct batch
Change name to batch_info/data
 {
> +	uint32_t batch[16];
> +	uint64_t pad;
> +	uint32_t data;
> +	uint64_t addr;
> +};
> +
> +static void batch(struct batch *data, uint64_t addr)
Change name to store_dword_batch/cmd(). If possible move this library as store is used in most of igt's.
 {
> +	int b;
> +	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));
> +
> +	data->addr = batch_addr;
> +}
> +
> +/**
> + * SUBTEST: basic-store
> + * Description: Basic test to verify store dword.
> + * Run type: FULL
> + */
> +static void store(int fd)
> +{
> +	struct drm_xe_sync sync = {
> +		.flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL,
> +	};
> +	struct drm_xe_exec exec = {
> +		.num_batch_buffer = 1,
> +		.num_syncs = 1,
> +		.syncs = to_user_pointer(&sync),
> +	};
> +	struct batch *data;
> +	struct drm_xe_engine_class_instance *hw_engine;
> +	uint32_t vm;
> +	uint32_t engine;
> +	uint32_t syncobj;
> +	size_t bo_size;
> +	uint64_t addr = 0x100000;
> +	uint32_t bo = 0;
> +
> +	syncobj = syncobj_create(fd, 0);
> +	sync.handle = syncobj;
> +
> +	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));
> +
> +	hw_engine = xe_hw_engine(fd, 1);
> +	bo = xe_bo_create(fd, hw_engine->gt_id, vm, bo_size);
> +
> +	xe_vm_bind_async(fd, vm, hw_engine->gt_id, bo, 0, addr, bo_size,
> &sync, 1);
> +	data = xe_bo_map(fd, bo, bo_size);
> +	batch(data, addr);
> +
> +	engine = xe_engine_create(fd, vm, hw_engine, 0);
> +	exec.engine_id = engine;
> +	exec.address = data->addr;
> +	sync.flags &= DRM_XE_SYNC_SIGNAL;
> +	xe_exec(fd, &exec);
> +
> +	igt_assert(syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL));
> +	igt_assert_eq(data->data, 0x123456);
> +
> +	syncobj_destroy(fd, syncobj);
> +	munmap(data, bo_size);
> +	gem_close(fd, bo);
> +
> +	xe_engine_destroy(fd, engine);
> +	xe_vm_destroy(fd, vm);
> +}
> +
> +/**
> + * SUBTEST: basic-all
> + * Description: Test to verify store dword on all available engine.
> + * Run type: BAT
> + */
> +static void store_all(int fd, int gt, int class) {
> +	struct drm_xe_sync sync = {
> +		.flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL,
> +	};
> +	struct drm_xe_exec exec = {
> +		.num_batch_buffer = 1,
> +		.num_syncs = 1,
> +		.syncs = to_user_pointer(&sync),
> +	};
> +
> +	struct batch *data;
> +	uint32_t vm, syncobj;
> +	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 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));
> +
> +	syncobj = syncobj_create(fd, 0);
> +	sync.handle = syncobj;
> +
> +	bo = xe_bo_create(fd, 0, vm, bo_size);
> +	data = xe_bo_map(fd, bo, bo_size);
> +	xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, &sync, 1);
> +
> +	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;
> +	batch(data, addr);
> +
> +	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;
> +		exec.engine_id = engines[i];
> +		exec.address = data->addr;
> +		sync.flags &= DRM_XE_SYNC_SIGNAL;
> +		xe_exec(fd, &exec);
> +
> +		igt_assert(syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL));
> +		igt_assert_eq(data->data, 0x123456);
> +	}
> +
> +	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, &sync, 1);
> +	syncobj_destroy(fd, syncobj);
> +	munmap(data, bo_size);
> +	gem_close(fd, bo);
> +
> +	for (i = 0; i < num_placements; i++) {
> +		xe_engine_destroy(fd, engines[i]);
> +	}
> +	xe_vm_destroy(fd, vm);
> +}
> +
> +igt_main
> +{
> +	int fd, class, gt;
> +
> +	igt_fixture {
> +		fd = drm_open_driver(DRIVER_XE);
> +		xe_device_get(fd);
> +	}
> +
> +	igt_subtest("basic-store")
> +		store(fd);
> +
> +	igt_subtest("basic-all") {
> +		xe_for_each_gt(fd, gt)
> +			xe_for_each_hw_engine_class(class)
> +				store_all(fd, gt, class);
> +	}
> +
> +	igt_fixture
Add xe_device_put(fd);

Thanks,
Rahul
> +		close(fd);
> +}
> --
> 2.39.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality
@ 2023-06-27 14:11 sai.gowtham.ch
  2023-06-28  9:51 ` Kumar, Janga Rahul
  0 siblings, 1 reply; 6+ messages in thread
From: sai.gowtham.ch @ 2023-06-27 14:11 UTC (permalink / raw)
  To: igt-dev, sai.gowtham.ch

From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>

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

Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
---
 tests/meson.build   |   1 +
 tests/xe/xe_store.c | 197 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 198 insertions(+)
 create mode 100644 tests/xe/xe_store.c

diff --git a/tests/meson.build b/tests/meson.build
index 85ea7e74..2874be77 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -267,6 +267,7 @@ xe_progs = [
 	'xe_pm',
 	'xe_prime_self_import',
 	'xe_query',
+	'xe_store',
 	'xe_vm',
 	'xe_waitfence',
 	'xe_spin_batch',
diff --git a/tests/xe/xe_store.c b/tests/xe/xe_store.c
new file mode 100644
index 00000000..5765c3d8
--- /dev/null
+++ b/tests/xe/xe_store.c
@@ -0,0 +1,197 @@
+#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: HW
+ * Functionality: intel-bb
+ * Test category: functionality test
+ */
+
+#define MAX_INSTANCE 9
+
+struct batch {
+	uint32_t batch[16];
+	uint64_t pad;
+	uint32_t data;
+	uint64_t addr;
+};
+
+static void batch(struct batch *data, uint64_t addr)
+{
+	int b;
+	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));
+
+	data->addr = batch_addr;
+}
+
+/**
+ * SUBTEST: basic-store
+ * Description: Basic test to verify store dword.
+ * Run type: FULL
+ */
+static void store(int fd)
+{
+	struct drm_xe_sync sync = {
+		.flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL,
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	struct batch *data;
+	struct drm_xe_engine_class_instance *hw_engine;
+	uint32_t vm;
+	uint32_t engine;
+	uint32_t syncobj;
+	size_t bo_size;
+	uint64_t addr = 0x100000;
+	uint32_t bo = 0;
+
+	syncobj = syncobj_create(fd, 0);
+	sync.handle = syncobj;
+
+	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));
+
+	hw_engine = xe_hw_engine(fd, 1);
+	bo = xe_bo_create(fd, hw_engine->gt_id, vm, bo_size);
+
+	xe_vm_bind_async(fd, vm, hw_engine->gt_id, bo, 0, addr, bo_size, &sync, 1);
+	data = xe_bo_map(fd, bo, bo_size);
+	batch(data, addr);
+
+	engine = xe_engine_create(fd, vm, hw_engine, 0);
+	exec.engine_id = engine;
+	exec.address = data->addr;
+	sync.flags &= DRM_XE_SYNC_SIGNAL;
+	xe_exec(fd, &exec);
+
+	igt_assert(syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL));
+	igt_assert_eq(data->data, 0x123456);
+
+	syncobj_destroy(fd, syncobj);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	xe_engine_destroy(fd, engine);
+	xe_vm_destroy(fd, vm);
+}
+
+/**
+ * SUBTEST: basic-all
+ * Description: Test to verify store dword on all available engine.
+ * Run type: BAT
+ */
+static void store_all(int fd, int gt, int class)
+{
+	struct drm_xe_sync sync = {
+		.flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL,
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+
+	struct batch *data;
+	uint32_t vm, syncobj;
+	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 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));
+
+	syncobj = syncobj_create(fd, 0);
+	sync.handle = syncobj;
+
+	bo = xe_bo_create(fd, 0, vm, bo_size);
+	data = xe_bo_map(fd, bo, bo_size);
+	xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, &sync, 1);
+
+	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;
+	batch(data, addr);
+
+	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;
+		exec.engine_id = engines[i];
+		exec.address = data->addr;
+		sync.flags &= DRM_XE_SYNC_SIGNAL;
+		xe_exec(fd, &exec);
+
+		igt_assert(syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL));
+		igt_assert_eq(data->data, 0x123456);
+	}
+
+	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, &sync, 1);
+	syncobj_destroy(fd, syncobj);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	for (i = 0; i < num_placements; i++) {
+		xe_engine_destroy(fd, engines[i]);
+	}
+	xe_vm_destroy(fd, vm);
+}
+
+igt_main
+{
+	int fd, class, gt;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_XE);
+		xe_device_get(fd);
+	}
+
+	igt_subtest("basic-store")
+		store(fd);
+
+	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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-30  6:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 10:51 [igt-dev] [PATCH i-g-t] tests/xe/xe_store: Add xe_store test to check store dword functionality sai.gowtham.ch
2023-06-26 11:16 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
2023-06-26 13:12 ` [igt-dev] [PATCH i-g-t] " Ch, Sai Gowtham
2023-06-27 14:11 sai.gowtham.ch
2023-06-28  9:51 ` Kumar, Janga Rahul
2023-06-30  6:45 sai.gowtham.ch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.