Skip to contentSkip to conversation

tests/intel/xe_exec_compute_mode: Add non-blocking subtest

PATCH In review [email protected] 3 participants 5 messages Jan 5, 2024 – Jan 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/intel/xe_exec_compute_mode: Add non-blocking subtest

From: Sai Gowtham Ch <[email protected]>

Fill the ring with maximum workload and expecte kernel to return -EWOULDBLOCK error.

v2: Fixing batch buffer submission, updating sync mapping addresses
of VM, SPIN & EXEC for better readability. (Matthew Brost)

---
 tests/intel/xe_exec_compute_mode.c | 111 +++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)
tests/intel/xe_exec_compute_mode.c +111 -0
index b935ee0bc..6ebfa1a86 100644
@@ -19,6 +19,7 @@
 
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
+#include "xe/xe_spin.h"
 #include <string.h>
 
 #define MAX_N_EXECQUEUES 	16
@@ -289,6 +290,112 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
 		close(map_fd);
 }
 
+/**
+ * SUBTEST: non-blocking
+ * Description: Fill the ring and check we get expected errors.
+ * Test category: functionality test
+ */
+#define ONE_SEC	MS_TO_NS(1000)
+#define VM_DATA		0
+#define SPIN_DATA	1
+#define EXEC_DATA	2
+#define DATA_COUNT	3
+static void non_block(int fd, int expect)
+{
+	uint64_t addr = 0x1a0000;
+	struct drm_xe_sync sync[1] = {
+		{ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+		  .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		  .timeline_value = USER_FENCE_VALUE},
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	struct {
+		struct xe_spin spin;
+		uint32_t batch[16];
+		uint64_t vm_sync;
+		uint32_t data;
+		uint64_t exec_sync;
+	} *data = NULL;
+	struct xe_spin_opts spin_opts = { .addr = addr, .preempt = false };
+	struct drm_xe_engine *engine;
+	uint64_t batch_offset = (char *)&data[EXEC_DATA].batch - (char *)data;
+	uint64_t batch_addr = addr + batch_offset;
+	uint64_t sdi_offset = (char *)&data[EXEC_DATA].data - (char *)data;
+	uint64_t sdi_addr = addr + sdi_offset;
+	size_t bo_size;
+	uint32_t vm;
+	uint32_t exec_queue;
+	int value = 0x123456;
+	uint32_t bo = 0;
+	int b, err;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
+	bo_size = sizeof(*data) * DATA_COUNT;
+	bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd), xe_get_default_alignment(fd));
+
+	engine = xe_engine(fd, 1);
+	bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd, engine->instance.gt_id), 0);
+
+	data = xe_bo_map(fd, bo, bo_size);
+	memset(data, 0, bo_size);
+	exec_queue = xe_exec_queue_create(fd, vm, &engine->instance, 0);
+
+	sync[0].addr = to_user_pointer(&data[VM_DATA].vm_sync);
+	xe_vm_bind_async(fd, vm, engine->instance.gt_id, bo, 0,
+			       addr, bo_size, sync, 1);
+	xe_wait_ufence(fd, &data[VM_DATA].vm_sync, USER_FENCE_VALUE, 0, ONE_SEC);
+	data[VM_DATA].vm_sync = 0;
+
+	xe_spin_init(&data[SPIN_DATA].spin, &spin_opts);
+	sync[0].addr = addr + (char *)&data[SPIN_DATA].exec_sync - (char *)data;
+	exec.exec_queue_id = exec_queue;
+	exec.address = spin_opts.addr;
+	xe_exec(fd, &exec);
+	xe_spin_wait_started(&data[SPIN_DATA].spin);
+
+	b = 0;
+	data[0].batch[b++] = MI_STORE_DWORD_IMM_GEN4;
+	data[0].batch[b++] = sdi_addr;
+	data[0].batch[b++] = sdi_addr >> 32;
+	data[0].batch[b++] = value;
+	data[0].batch[b++] = MI_BATCH_BUFFER_END;
+	igt_assert(b <= ARRAY_SIZE(data->batch));
+
+	sync[0].addr = addr + (char *)&data[EXEC_DATA].exec_sync - (char *)data;
+	exec.num_syncs = 0;
+	exec.exec_queue_id = exec_queue;
+	exec.address = batch_addr;
+
+	while (1) {
+		err = __xe_exec(fd, &exec);
+
+		if (err == -EWOULDBLOCK)
+			break;
+	}
+	igt_assert_eq(err, expect);
+
+	xe_spin_end(&data[SPIN_DATA].spin);
+	xe_wait_ufence(fd, &data[SPIN_DATA].exec_sync, USER_FENCE_VALUE, 0, ONE_SEC);
+	usleep(50000);
+
+	exec.num_syncs = 1;
+	xe_exec(fd, &exec);
+	xe_wait_ufence(fd, &data[EXEC_DATA].exec_sync, USER_FENCE_VALUE, 0, ONE_SEC);
+
+	sync[0].addr = to_user_pointer(&data[VM_DATA].vm_sync);
+	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
+	xe_wait_ufence(fd, &data[VM_DATA].vm_sync, USER_FENCE_VALUE, 0, ONE_SEC);
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	xe_exec_queue_destroy(fd, exec_queue);
+	xe_vm_destroy(fd, vm);
+}
+
 igt_main
 {
 	struct drm_xe_engine_class_instance *hwe;
@@ -346,6 +453,10 @@ igt_main
 					  s->flags);
 	}
 
+	igt_subtest("non-blocking")
+		non_block(fd, -EWOULDBLOCK);
+
+
 	igt_fixture
 		drm_close_driver(fd);
 }
Signature · 1 line
2.39.1
#1 lore raw

✗ Fi.CI.BAT: failure for tests/intel/xe_exec_compute_mode: Add non-blocking subtest

== Series Details ==

== Series Details ==

Series: tests/intel/xe_exec_compute_mode: Add non-blocking subtest
URL : https://patchwork.freedesktop.org/series/128282/
State : failure

== Summary ==

CI Bug Log - changes from IGT_7659 -> IGTPW_10481
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_10481 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in IGTPW_10481, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/index.html

Participating hosts (39 -> 36)
------------------------------

Missing (3): bat-dg2-8 bat-atsm-1 fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_10481:

### IGT changes ###

#### Possible regressions ####

* igt@i915_suspend@basic-s3-without-i915:
- bat-jsl-3: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7659/bat-jsl-3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/bat-jsl-3/igt@[email protected]

Known issues
------------

Here are the changes found in IGTPW_10481 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_suspend@basic-s0@smem:
- bat-jsl-3: [PASS][3] -> [INCOMPLETE][4] ([i915#9883])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7659/bat-jsl-3/igt@gem_exec_suspend@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/bat-jsl-3/igt@gem_exec_suspend@[email protected]

* igt@gem_lmem_swapping@random-engines:
- fi-bsw-n3050: NOTRUN -> [SKIP][5] ([fdo#109271]) +15 other tests skip
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/fi-bsw-n3050/igt@[email protected]

* igt@i915_module_load@load:
- bat-adlp-6: [PASS][6] -> [INCOMPLETE][7] ([i915#8449])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7659/bat-adlp-6/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/bat-adlp-6/igt@[email protected]

* igt@kms_pm_backlight@basic-brightness@edp-1:
- bat-rplp-1: NOTRUN -> [ABORT][8] ([i915#8668])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/bat-rplp-1/igt@kms_pm_backlight@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@hangcheck:
- {bat-rpls-3}: [DMESG-WARN][9] ([i915#5591]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7659/bat-rpls-3/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/bat-rpls-3/igt@i915_selftest@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [ABORT][11] ([i915#8668] / [i915#9368]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7659/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#5591]: https://gitlab.freedesktop.org/drm/intel/issues/5591
[i915#8449]: https://gitlab.freedesktop.org/drm/intel/issues/8449
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#9368]: https://gitlab.freedesktop.org/drm/intel/issues/9368
[i915#9883]: https://gitlab.freedesktop.org/drm/intel/issues/9883

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_7659 -> IGTPW_10481

CI-20190529: 20190529
CI_DRM_14080: d7426b5fc261046501ca418fe0e69ad1d6ba59be @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_10481: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/index.html
IGT_7659: dcc68cc6c562866584feac3ffadab65dfa9a402b @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

Testlist changes
----------------

+igt@xe_exec_compute_mode@non-blocking

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/index.html

#2 lore raw

✓ CI.xeBAT: success for tests/intel/xe_exec_compute_mode: Add non-blocking subtest

In reply to [email protected]
== Series Details ==

== Series Details ==

Series: tests/intel/xe_exec_compute_mode: Add non-blocking subtest
URL : https://patchwork.freedesktop.org/series/128282/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7659_BAT -> XEIGTPW_10481_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (2 -> 4)
------------------------------

Additional (2): bat-dg2-oem2 bat-adlp-7

Known issues
------------

Here are the changes found in XEIGTPW_10481_BAT that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-dg2-oem2: NOTRUN -> [SKIP][1] ([Intel XE#623])
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- bat-dg2-oem2: NOTRUN -> [SKIP][2] ([Intel XE#455])
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]

* igt@kms_dsc@dsc-basic@pipe-a-edp-1:
- bat-adlp-7: NOTRUN -> [FAIL][3] ([Intel XE#1066]) +1 other test fail
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@kms_dsc@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@a-edp1:
- bat-adlp-7: NOTRUN -> [FAIL][4] ([Intel XE#480]) +1 other test fail
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@kms_flip@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-dg2-oem2: NOTRUN -> [SKIP][5] ([i915#5274])
[5]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- bat-dg2-oem2: NOTRUN -> [FAIL][6] ([Intel XE#608])
[6]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]
- bat-adlp-7: NOTRUN -> [DMESG-WARN][7] ([Intel XE#1033])
[7]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-nv12:
- bat-dg2-oem2: NOTRUN -> [FAIL][8] ([Intel XE#400] / [Intel XE#616]) +2 other tests fail
[8]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]

* igt@xe_create@create-execqueues-leak:
- bat-atsm-2: [PASS][9] -> [FAIL][10] ([Intel XE#1099])
[9]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7659/bat-atsm-2/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-atsm-2/igt@[email protected]

* igt@xe_evict@evict-beng-small-external:
- bat-adlp-7: NOTRUN -> [SKIP][11] ([Intel XE#261] / [Intel XE#688]) +15 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]

* igt@xe_evict_ccs@evict-overcommit-simple:
- bat-adlp-7: NOTRUN -> [SKIP][12] ([Intel XE#688]) +1 other test skip
[12]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]

* igt@xe_exec_fault_mode@many-basic:
- bat-dg2-oem2: NOTRUN -> [SKIP][13] ([Intel XE#288]) +32 other tests skip
[13]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]

* igt@xe_exec_fault_mode@twice-userptr:
- bat-adlp-7: NOTRUN -> [SKIP][14] ([Intel XE#288]) +32 other tests skip
[14]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]

* igt@xe_huc_copy@huc_copy:
- bat-dg2-oem2: NOTRUN -> [SKIP][15] ([Intel XE#255])
[15]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@xe_huc_copy@huc_copy.html

* igt@xe_mmap@vram:
- bat-adlp-7: NOTRUN -> [SKIP][16] ([Intel XE#1008])
[16]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]

* igt@xe_pat@pat-index-xe2:
- bat-adlp-7: NOTRUN -> [SKIP][17] ([Intel XE#977])
[17]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]
- bat-dg2-oem2: NOTRUN -> [SKIP][18] ([Intel XE#977])
[18]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]

* igt@xe_pat@pat-index-xehpc:
- bat-dg2-oem2: NOTRUN -> [SKIP][19] ([Intel XE#979]) +1 other test skip
[19]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-dg2-oem2/igt@[email protected]
- bat-adlp-7: NOTRUN -> [SKIP][20] ([Intel XE#979]) +1 other test skip
[20]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/bat-adlp-7/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[Intel XE#1008]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/1008
[Intel XE#1033]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/1033
[Intel XE#1066]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/1066
[Intel XE#1099]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/1099
[Intel XE#255]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/255
[Intel XE#261]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/261
[Intel XE#288]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/288
[Intel XE#400]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/400
[Intel XE#455]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/455
[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480
[Intel XE#608]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/608
[Intel XE#616]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/616
[Intel XE#623]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/623
[Intel XE#688]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/688
[Intel XE#929]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/929
[Intel XE#977]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/977
[Intel XE#979]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/979
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274

Build changes
-------------

* IGT: IGT_7659 -> IGTPW_10481
* Linux: xe-602-2f34bf674c7dad8d0cb6ae92d4e56805d63d0513 -> xe-603-cca0607b6f6a21bee68c092ed7ad9f3322e54523

IGTPW_10481: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10481/index.html
IGT_7659: dcc68cc6c562866584feac3ffadab65dfa9a402b @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-602-2f34bf674c7dad8d0cb6ae92d4e56805d63d0513: 2f34bf674c7dad8d0cb6ae92d4e56805d63d0513 xe-603-cca0607b6f6a21bee68c092ed7ad9f3322e54523: cca0607b6f6a21bee68c092ed7ad9f3322e54523

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10481/index.html

#3 lore raw
In reply to [email protected]
Quoted 163 lines

-----Original Message-----
From: igt-dev <[email protected]> On Behalf Of [email protected]
Sent: Saturday, January 6, 2024 2:12 AM
To: [email protected]; Brost, Matthew <[email protected]>; Ch, Sai Gowtham <[email protected]>
Subject: [PATCH i-g-t] tests/intel/xe_exec_compute_mode: Add non-blocking subtest

From: Sai Gowtham Ch <[email protected]>

Fill the ring with maximum workload and expecte kernel to return - EWOULDBLOCK error.

v2: Fixing batch buffer submission, updating sync mapping addresses
of VM, SPIN & EXEC for better readability. (Matthew Brost)

---
 tests/intel/xe_exec_compute_mode.c | 111
+++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)
tests/intel/xe_exec_compute_mode.c +64 -0
index b935ee0bc..6ebfa1a86 100644
@@ -19,6 +19,7 @@
 
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
+#include "xe/xe_spin.h"
 #include <string.h>
 
 #define MAX_N_EXECQUEUES 	16
@@ -289,6 +290,112 @@ test_exec(int fd, struct
 drm_xe_engine_class_instance *eci,
 		close(map_fd);
 }
 
+/**
+ * SUBTEST: non-blocking
+ * Description: Fill the ring and check we get expected errors.
+ * Test category: functionality test
+ */
+#define ONE_SEC	MS_TO_NS(1000)
+#define VM_DATA		0
+#define SPIN_DATA	1
+#define EXEC_DATA	2
+#define DATA_COUNT	3
+static void non_block(int fd, int expect) {
+	uint64_t addr = 0x1a0000;
+	struct drm_xe_sync sync[1] = {
+		{ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+		  .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		  .timeline_value = USER_FENCE_VALUE},
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	struct {
+		struct xe_spin spin;
+		uint32_t batch[16];
+		uint64_t vm_sync;
+		uint32_t data;
+		uint64_t exec_sync;
+	} *data = NULL;
+	struct xe_spin_opts spin_opts = { .addr = addr, .preempt = false };
+	struct drm_xe_engine *engine;
+	uint64_t batch_offset = (char *)&data[EXEC_DATA].batch - (char
 *)data;
+	uint64_t batch_addr = addr + batch_offset;
+	uint64_t sdi_offset = (char *)&data[EXEC_DATA].data - (char *)data;
+	uint64_t sdi_addr = addr + sdi_offset;
+	size_t bo_size;
+	uint32_t vm;
+	uint32_t exec_queue;
+	int value = 0x123456;
+	uint32_t bo = 0;
+	int b, err;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
+	bo_size = sizeof(*data) * DATA_COUNT;
+	bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+xe_get_default_alignment(fd));
+
+	engine = xe_engine(fd, 1);
+	bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd,
+engine->instance.gt_id), 0);
+
+	data = xe_bo_map(fd, bo, bo_size);
+	memset(data, 0, bo_size);
+	exec_queue = xe_exec_queue_create(fd, vm, &engine->instance, 0);
+
+	sync[0].addr = to_user_pointer(&data[VM_DATA].vm_sync);
+	xe_vm_bind_async(fd, vm, engine->instance.gt_id, bo, 0,
+			       addr, bo_size, sync, 1);
+	xe_wait_ufence(fd, &data[VM_DATA].vm_sync, USER_FENCE_VALUE,
 0, ONE_SEC);
+	data[VM_DATA].vm_sync = 0;
+
+	xe_spin_init(&data[SPIN_DATA].spin, &spin_opts);
+	sync[0].addr = addr + (char *)&data[SPIN_DATA].exec_sync - (char

*)data;

tests/intel/xe_exec_compute_mode.c +14 -0
+	exec.exec_queue_id = exec_queue;
+	exec.address = spin_opts.addr;
+	xe_exec(fd, &exec);
+	xe_spin_wait_started(&data[SPIN_DATA].spin);
+
+	b = 0;
+	data[0].batch[b++] = MI_STORE_DWORD_IMM_GEN4;
+	data[0].batch[b++] = sdi_addr;
+	data[0].batch[b++] = sdi_addr >> 32;
+	data[0].batch[b++] = value;
+	data[0].batch[b++] = MI_BATCH_BUFFER_END;
+	igt_assert(b <= ARRAY_SIZE(data->batch));
+
+	sync[0].addr = addr + (char *)&data[EXEC_DATA].exec_sync - (char

*)data;

tests/intel/xe_exec_compute_mode.c +14 -0
+	exec.num_syncs = 0;
+	exec.exec_queue_id = exec_queue;
+	exec.address = batch_addr;
+
+	while (1) {
+		err = __xe_exec(fd, &exec);
+
+		if (err == -EWOULDBLOCK)
+			break;
+	}
+	igt_assert_eq(err, expect);
+
+	xe_spin_end(&data[SPIN_DATA].spin);
+	xe_wait_ufence(fd, &data[SPIN_DATA].exec_sync,

USER_FENCE_VALUE, 0, ONE_SEC);

tests/intel/xe_exec_compute_mode.c +5 -0
+	usleep(50000);
+
+	exec.num_syncs = 1;
+	xe_exec(fd, &exec);
+	xe_wait_ufence(fd, &data[EXEC_DATA].exec_sync,

USER_FENCE_VALUE, 0,

tests/intel/xe_exec_compute_mode.c +5 -0
+ONE_SEC);
+
+	sync[0].addr = to_user_pointer(&data[VM_DATA].vm_sync);
+	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
+	xe_wait_ufence(fd, &data[VM_DATA].vm_sync, USER_FENCE_VALUE,

0, ONE_SEC);

tests/intel/xe_exec_compute_mode.c +7 -0
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	xe_exec_queue_destroy(fd, exec_queue);
+	xe_vm_destroy(fd, vm);
+}
+
 igt_main
 {
 	struct drm_xe_engine_class_instance *hwe; @@ -346,6 +453,10 @@

igt_main

tests/intel/xe_exec_compute_mode.c igt_main · line 458

Quoted 6 lines
tests/intel/xe_exec_compute_mode.c +3 -0
 					  s->flags);
 	}
 
+	igt_subtest("non-blocking")
+		non_block(fd, -EWOULDBLOCK);
+

LGTM.
Priyanka Dandamudi <[email protected]>

Quoted 6 lines
tests/intel/xe_exec_compute_mode.c +1 -1
+
 	igt_fixture
 		drm_close_driver(fd);
 }
--

2.39.1

#4 lore raw
Quoted 188 lines

-----Original Message-----
From: Dandamudi, Priyanka
Sent: Monday, January 8, 2024 1:12 PM
To: [email protected]; [email protected]; Brost, Matthew <[email protected]>; Ch, Sai Gowtham <[email protected]>
Subject: RE: [PATCH i-g-t] tests/intel/xe_exec_compute_mode: Add non- blocking subtest

Quoted 6 lines

-----Original Message-----
From: igt-dev <[email protected]> On Behalf Of [email protected]
Sent: Saturday, January 6, 2024 2:12 AM
To: [email protected]; Brost, Matthew <[email protected]>; Ch, Sai Gowtham

<[email protected]>

Quoted 155 lines

Subject: [PATCH i-g-t] tests/intel/xe_exec_compute_mode: Add non-blocking subtest

From: Sai Gowtham Ch <[email protected]>

Fill the ring with maximum workload and expecte kernel to return - EWOULDBLOCK error.

v2: Fixing batch buffer submission, updating sync mapping addresses
of VM, SPIN & EXEC for better readability. (Matthew Brost)

---
 tests/intel/xe_exec_compute_mode.c | 111
+++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)
tests/intel/xe_exec_compute_mode.c +64 -0
index b935ee0bc..6ebfa1a86 100644
@@ -19,6 +19,7 @@
 
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
+#include "xe/xe_spin.h"
 #include <string.h>
 
 #define MAX_N_EXECQUEUES 	16
@@ -289,6 +290,112 @@ test_exec(int fd, struct
 drm_xe_engine_class_instance *eci,
 		close(map_fd);
 }
 
+/**
+ * SUBTEST: non-blocking
+ * Description: Fill the ring and check we get expected errors.
+ * Test category: functionality test
+ */
+#define ONE_SEC	MS_TO_NS(1000)
+#define VM_DATA		0
+#define SPIN_DATA	1
+#define EXEC_DATA	2
+#define DATA_COUNT	3
+static void non_block(int fd, int expect) {
+	uint64_t addr = 0x1a0000;
+	struct drm_xe_sync sync[1] = {
+		{ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+		  .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		  .timeline_value = USER_FENCE_VALUE},
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	struct {
+		struct xe_spin spin;
+		uint32_t batch[16];
+		uint64_t vm_sync;
+		uint32_t data;
+		uint64_t exec_sync;
+	} *data = NULL;
+	struct xe_spin_opts spin_opts = { .addr = addr, .preempt = false };
+	struct drm_xe_engine *engine;
+	uint64_t batch_offset = (char *)&data[EXEC_DATA].batch - (char
 *)data;
+	uint64_t batch_addr = addr + batch_offset;
+	uint64_t sdi_offset = (char *)&data[EXEC_DATA].data - (char *)data;
+	uint64_t sdi_addr = addr + sdi_offset;
+	size_t bo_size;
+	uint32_t vm;
+	uint32_t exec_queue;
+	int value = 0x123456;
+	uint32_t bo = 0;
+	int b, err;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
+	bo_size = sizeof(*data) * DATA_COUNT;
+	bo_size = ALIGN(bo_size + xe_cs_prefetch_size(fd),
+xe_get_default_alignment(fd));
+
+	engine = xe_engine(fd, 1);
+	bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd,
+engine->instance.gt_id), 0);
+
+	data = xe_bo_map(fd, bo, bo_size);
+	memset(data, 0, bo_size);
+	exec_queue = xe_exec_queue_create(fd, vm, &engine->instance, 0);
+
+	sync[0].addr = to_user_pointer(&data[VM_DATA].vm_sync);
+	xe_vm_bind_async(fd, vm, engine->instance.gt_id, bo, 0,
+			       addr, bo_size, sync, 1);
+	xe_wait_ufence(fd, &data[VM_DATA].vm_sync, USER_FENCE_VALUE,
 0, ONE_SEC);
+	data[VM_DATA].vm_sync = 0;
+
+	xe_spin_init(&data[SPIN_DATA].spin, &spin_opts);
+	sync[0].addr = addr + (char *)&data[SPIN_DATA].exec_sync - (char

*)data;

tests/intel/xe_exec_compute_mode.c +14 -0
+	exec.exec_queue_id = exec_queue;
+	exec.address = spin_opts.addr;
+	xe_exec(fd, &exec);
+	xe_spin_wait_started(&data[SPIN_DATA].spin);
+
+	b = 0;
+	data[0].batch[b++] = MI_STORE_DWORD_IMM_GEN4;
+	data[0].batch[b++] = sdi_addr;
+	data[0].batch[b++] = sdi_addr >> 32;
+	data[0].batch[b++] = value;
+	data[0].batch[b++] = MI_BATCH_BUFFER_END;
+	igt_assert(b <= ARRAY_SIZE(data->batch));
+
+	sync[0].addr = addr + (char *)&data[EXEC_DATA].exec_sync - (char

*)data;

tests/intel/xe_exec_compute_mode.c +14 -0
+	exec.num_syncs = 0;
+	exec.exec_queue_id = exec_queue;
+	exec.address = batch_addr;
+
+	while (1) {
+		err = __xe_exec(fd, &exec);
+
+		if (err == -EWOULDBLOCK)
+			break;
+	}
+	igt_assert_eq(err, expect);
+
+	xe_spin_end(&data[SPIN_DATA].spin);
+	xe_wait_ufence(fd, &data[SPIN_DATA].exec_sync,

USER_FENCE_VALUE, 0, ONE_SEC);

tests/intel/xe_exec_compute_mode.c +5 -0
+	usleep(50000);
+
+	exec.num_syncs = 1;
+	xe_exec(fd, &exec);
+	xe_wait_ufence(fd, &data[EXEC_DATA].exec_sync,

USER_FENCE_VALUE, 0,

tests/intel/xe_exec_compute_mode.c +5 -0
+ONE_SEC);
+
+	sync[0].addr = to_user_pointer(&data[VM_DATA].vm_sync);
+	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
+	xe_wait_ufence(fd, &data[VM_DATA].vm_sync, USER_FENCE_VALUE,

0, ONE_SEC);

tests/intel/xe_exec_compute_mode.c +7 -0
+	munmap(data, bo_size);
+	gem_close(fd, bo);
+
+	xe_exec_queue_destroy(fd, exec_queue);
+	xe_vm_destroy(fd, vm);
+}
+
 igt_main
 {
 	struct drm_xe_engine_class_instance *hwe; @@ -346,6 +453,10 @@

igt_main

tests/intel/xe_exec_compute_mode.c igt_main · line 458

Quoted 6 lines
tests/intel/xe_exec_compute_mode.c +3 -0
 					  s->flags);
 	}
 
+	igt_subtest("non-blocking")
+		non_block(fd, -EWOULDBLOCK);
+

LGTM.

Quoted 6 lines
tests/intel/xe_exec_compute_mode.c +1 -1
+
 	igt_fixture
 		drm_close_driver(fd);
 }
--

2.39.1