Skip to contentSkip to conversation

lib/xe/xe_spin: Integrate igt_spin_new with Xe.

PATCH In review [email protected] 4 participants 8 messages May 10, 2023 – May 11, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/xe/xe_spin: Integrate igt_spin_new with Xe.

From: Sai Gowtham Ch <[email protected]>

Extending the spin_create implementation and allocator handle support in xe, where it submits dummy work loads to engine. This Implementation is wrapped around vm_bind and unbind as we are supposed to do it manually for xe.

Cc Bhanuprakash Modem <[email protected]>
Cc Zbigniew Kempczyński <[email protected]>
---
 lib/igt_dummyload.c | 24 ++++++++++++----
 lib/igt_dummyload.h | 10 +++++++
 lib/xe/xe_spin.c    | 67 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 102 insertions(+), 6 deletions(-)
lib/igt_dummyload.c +18 -6
index 740a58f3..6e89b72d 100644
@@ -46,6 +46,7 @@
 #include "intel_reg.h"
 #include "ioctl_wrappers.h"
 #include "sw_sync.h"
+#include "xe/xe_spin.h"
 
 /**
  * SECTION:igt_dummyload
@@ -447,7 +448,10 @@ spin_create(int fd, const struct igt_spin_factory *opts)
 igt_spin_t *
 __igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 {
-	return spin_create(fd, opts);
+	if (is_xe_device(fd))
+		return xe_spin_create(fd, opts);
+	else
+		return spin_create(fd, opts);
 }
 
 /**
@@ -467,6 +471,11 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 {
 	igt_spin_t *spin;
 
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	}
+
 	if ((opts->flags & IGT_SPIN_POLL_RUN) && opts->engine != ALL_ENGINES) {
 		unsigned int class;
 
@@ -647,11 +656,14 @@ void igt_spin_free(int fd, igt_spin_t *spin)
 	if (!spin)
 		return;
 
-	pthread_mutex_lock(&list_lock);
-	igt_list_del(&spin->link);
-	pthread_mutex_unlock(&list_lock);
-
-	__igt_spin_free(fd, spin);
+	if (is_xe_device(fd)) {
+		xe_spin_free(fd, spin);
+	} else {
+		pthread_mutex_lock(&list_lock);
+		igt_list_del(&spin->link);
+		pthread_mutex_unlock(&list_lock);
+		__igt_spin_free(fd, spin);
+	}
 }
 
 void igt_terminate_spins(void)
lib/igt_dummyload.h +10 -0
index b247ab02..c2900a8f 100644
@@ -51,6 +51,7 @@ typedef struct igt_spin_factory {
 	uint32_t dependency;
 	uint64_t dependency_size;
 	unsigned int engine;
+	struct drm_xe_engine_class_instance *hwe;
 	unsigned int flags;
 	int fence;
 	uint64_t ahnd;
@@ -83,6 +84,15 @@ typedef struct igt_spin {
 #define SPIN_CLFLUSH (1 << 0)
 
 	struct igt_spin_factory opts;
+
+	uint32_t start;
+	uint32_t end;
+	size_t bo_size;
+	uint64_t address;
+	unsigned int engine;
+	uint32_t vm;
+	uint32_t syncobj;
+
 } igt_spin_t;
 
 
lib/xe/xe_spin.c +67 -0

79 lines not on this page · raw message

lib/xe/xe_spin.h +7 -0
index 73f9a026..48867eb8 100644
@@ -13,19 +13,26 @@
 #include <stdbool.h>
 
 #include "xe_query.h"
+#include "lib/igt_dummyload.h"
 
 /* Mapped GPU object */
+
 struct xe_spin {
 	uint32_t batch[16];
 	uint64_t pad;
 	uint32_t start;
 	uint32_t end;
+
 };
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt);
 void xe_spin_init(struct xe_spin *spin, uint64_t addr, bool preempt);
 bool xe_spin_started(struct xe_spin *spin);
+void xe_spin_sync_wait(int fd, struct igt_spin *spin);
 void xe_spin_wait_started(struct xe_spin *spin);
 void xe_spin_end(struct xe_spin *spin);
+void xe_spin_free(int fd, struct igt_spin *spin);
 
 struct xe_cork {
 	struct xe_spin *spin;
Signature · 1 line
2.39.1
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for lib/xe/xe_spin: Integrate igt_spin_new with Xe. (rev4)

== Series Details ==

== Series Details ==

Series: lib/xe/xe_spin: Integrate igt_spin_new with Xe. (rev4)
URL : https://patchwork.freedesktop.org/series/116880/
State : success

== Summary ==

CI Bug Log - changes from IGT_7284 -> IGTPW_8937
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

Participating hosts (40 -> 39)
------------------------------

Missing (1): fi-snb-2520m

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live@reset:
- bat-rpls-2: [PASS][1] -> [ABORT][2] ([i915#4983] / [i915#7461] / [i915#7913] / [i915#8347])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/bat-rpls-2/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-rpls-2/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@slpc:
- bat-rpls-1: NOTRUN -> [DMESG-WARN][3] ([i915#6367] / [i915#7953])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- bat-rpls-1: NOTRUN -> [ABORT][4] ([i915#6687] / [i915#7953] / [i915#7978])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-rpls-1/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-dg2-11: NOTRUN -> [SKIP][5] ([i915#1845] / [i915#5354]) +2 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-dg2-11/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence@pipe-d-dp-1:
- bat-dg2-8: [PASS][6] -> [FAIL][7] ([i915#7932])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/bat-dg2-8/igt@kms_pipe_crc_basic@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-dg2-8/igt@kms_pipe_crc_basic@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@requests:
- {bat-mtlp-6}: [ABORT][8] ([i915#4983] / [i915#7920] / [i915#7953]) -> [PASS][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/bat-mtlp-6/igt@i915_selftest@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-mtlp-6/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@reset:
- bat-rpls-1: [ABORT][10] ([i915#4983] / [i915#7461] / [i915#7953] / [i915#8347] / [i915#8384]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/bat-rpls-1/igt@i915_selftest@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/bat-rpls-1/igt@i915_selftest@[email protected]

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

[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#6687]: https://gitlab.freedesktop.org/drm/intel/issues/6687
[i915#7461]: https://gitlab.freedesktop.org/drm/intel/issues/7461
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#7920]: https://gitlab.freedesktop.org/drm/intel/issues/7920
[i915#7932]: https://gitlab.freedesktop.org/drm/intel/issues/7932
[i915#7953]: https://gitlab.freedesktop.org/drm/intel/issues/7953
[i915#7978]: https://gitlab.freedesktop.org/drm/intel/issues/7978
[i915#8347]: https://gitlab.freedesktop.org/drm/intel/issues/8347
[i915#8384]: https://gitlab.freedesktop.org/drm/intel/issues/8384

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

* CI: CI-20190529 -> None
* IGT: IGT_7284 -> IGTPW_8937

CI-20190529: 20190529
CI_DRM_13128: 31e3463b0edba64934bfd9e8fdbebeab1676d3eb @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8937: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/index.html
IGT_7284: 8c017d37b521276c113ad590521636eba8d7009c @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

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

+++ 0 lines
--- 216 lines

== Logs ==

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

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for lib/xe/xe_spin: Integrate igt_spin_new with Xe. (rev4)

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

== Series Details ==

Series: lib/xe/xe_spin: Integrate igt_spin_new with Xe. (rev4)
URL : https://patchwork.freedesktop.org/series/116880/
State : success

== Summary ==

CI Bug Log - changes from IGT_7284_full -> IGTPW_8937_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

Participating hosts (7 -> 7)
------------------------------

No changes in participating hosts

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_fair@basic-none-share@rcs0:
- shard-glk: NOTRUN -> [FAIL][1] ([i915#2842])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk2/igt@gem_exec_fair@[email protected]

* igt@gem_lmem_swapping@random-engines:
- shard-apl: NOTRUN -> [SKIP][2] ([fdo#109271] / [i915#4613])
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl3/igt@[email protected]

* igt@gem_lmem_swapping@verify-random-ccs:
- shard-glk: NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#4613])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk6/igt@[email protected]

* igt@gen9_exec_parse@allowed-single:
- shard-apl: [PASS][4] -> [ABORT][5] ([i915#5566])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-apl1/igt@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl4/igt@[email protected]
- shard-glk: NOTRUN -> [ABORT][6] ([i915#5566])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk6/igt@[email protected]

* igt@kms_big_fb@4-tiled-32bpp-rotate-90:
- shard-apl: NOTRUN -> [SKIP][7] ([fdo#109271]) +45 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl1/igt@[email protected]

* igt@kms_ccs@pipe-c-bad-aux-stride-y_tiled_gen12_mc_ccs:
- shard-apl: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#3886]) +1 similar issue
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl4/igt@kms_ccs@pipe-c-bad-aux-stride-y_tiled_gen12_mc_ccs.html

* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
- shard-apl: [PASS][9] -> [FAIL][10] ([i915#2346])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-apl6/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl6/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

* igt@kms_flip@2x-plain-flip-ts-check-interruptible@ac-hdmi-a1-hdmi-a2:
- shard-glk: [PASS][11] -> [FAIL][12] ([i915#2122])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-glk4/igt@kms_flip@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk3/igt@kms_flip@[email protected]

* igt@kms_frontbuffer_tracking@psr-2p-primscrn-pri-shrfb-draw-mmap-wc:
- shard-glk: NOTRUN -> [SKIP][13] ([fdo#109271]) +27 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk7/igt@kms_frontbuffer_tracking@psr-2p-primscrn-pri-shrfb-draw-mmap-wc.html

* igt@kms_plane_alpha_blend@alpha-opaque-fb@pipe-a-hdmi-a-1:
- shard-glk: NOTRUN -> [FAIL][14] ([i915#4573]) +1 similar issue
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk2/igt@kms_plane_alpha_blend@[email protected]

#### Possible fixes ####

* igt@gem_ctx_exec@basic-nohangcheck:
- {shard-tglu}: [FAIL][15] ([i915#6268]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-tglu-7/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-tglu-3/igt@[email protected]

* igt@gem_ctx_freq@sysfs:
- {shard-dg1}: [FAIL][17] ([i915#6786]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-dg1-16/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-dg1-18/igt@[email protected]

* igt@gem_ctx_isolation@preservation-s3@rcs0:
- shard-apl: [ABORT][19] -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-apl1/igt@gem_ctx_isolation@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl1/igt@gem_ctx_isolation@[email protected]

* igt@gem_ctx_persistence@smoketest:
- {shard-rkl}: [FAIL][21] ([i915#5099]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-4/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-2/igt@[email protected]

* igt@gem_eio@unwedge-stress:
- {shard-tglu}: [TIMEOUT][23] ([i915#3063] / [i915#7941]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-tglu-8/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-tglu-6/igt@[email protected]

* igt@gem_exec_endless@dispatch@rcs0:
- {shard-rkl}: [TIMEOUT][25] ([i915#3778]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-3/igt@gem_exec_endless@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-3/igt@gem_exec_endless@[email protected]

* igt@gem_exec_fair@basic-deadline:
- shard-glk: [FAIL][27] ([i915#2846]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-glk4/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk1/igt@[email protected]

* igt@gem_exec_fair@basic-none@bcs0:
- {shard-rkl}: [FAIL][29] ([i915#2842]) -> [PASS][30] +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-2/igt@gem_exec_fair@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-4/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace-share@rcs0:
- shard-glk: [FAIL][31] ([i915#2842]) -> [PASS][32] +3 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-glk7/igt@gem_exec_fair@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk6/igt@gem_exec_fair@[email protected]
- {shard-tglu}: [FAIL][33] ([i915#2842]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-tglu-5/igt@gem_exec_fair@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-tglu-2/igt@gem_exec_fair@[email protected]

* igt@gem_lmem_swapping@smem-oom@lmem0:
- {shard-dg1}: [DMESG-WARN][35] ([i915#4936] / [i915#5493]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-dg1-13/igt@gem_lmem_swapping@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-dg1-16/igt@gem_lmem_swapping@[email protected]

* igt@i915_pm_dc@dc9-dpms:
- shard-apl: [SKIP][37] ([fdo#109271]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-apl7/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl2/igt@[email protected]

* igt@i915_pm_rpm@dpms-lpsp:
- {shard-rkl}: [SKIP][39] ([i915#1397]) -> [PASS][40] +4 similar issues
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-1/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-7/igt@[email protected]

* igt@kms_atomic_transition@plane-all-transition@pipe-b-hdmi-a-1:
- shard-glk: [INCOMPLETE][41] -> [PASS][42]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-glk5/igt@kms_atomic_transition@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk4/igt@kms_atomic_transition@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions:
- shard-glk: [FAIL][43] ([i915#2346]) -> [PASS][44]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-glk7/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk6/igt@[email protected]
- shard-apl: [FAIL][45] ([i915#2346]) -> [PASS][46]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-apl4/igt@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-apl4/igt@[email protected]

* igt@kms_cursor_legacy@single-move@pipe-b:
- {shard-rkl}: [INCOMPLETE][47] ([i915#8011]) -> [PASS][48] +1 similar issue
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-7/igt@kms_cursor_legacy@[email protected]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-3/igt@kms_cursor_legacy@[email protected]

* igt@kms_flip@flip-vs-expired-vblank@b-hdmi-a1:
- shard-glk: [FAIL][49] ([i915#79]) -> [PASS][50]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-glk2/igt@kms_flip@[email protected]
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-glk9/igt@kms_flip@[email protected]

* igt@kms_rotation_crc@primary-y-tiled-reflect-x-180:
- {shard-rkl}: [ABORT][51] ([i915#7461] / [i915#8311]) -> [PASS][52]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-3/igt@[email protected]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-3/igt@[email protected]

* igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
- {shard-tglu}: [ABORT][53] ([i915#5122] / [i915#7953]) -> [PASS][54]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-tglu-5/igt@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-tglu-3/igt@[email protected]

* igt@perf_pmu@idle@rcs0:
- {shard-dg1}: [FAIL][55] ([i915#4349]) -> [PASS][56] +3 similar issues
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-dg1-17/igt@perf_pmu@[email protected]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-dg1-13/igt@perf_pmu@[email protected]
- {shard-rkl}: [FAIL][57] ([i915#4349]) -> [PASS][58]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-rkl-1/igt@perf_pmu@[email protected]
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-rkl-2/igt@perf_pmu@[email protected]

* igt@perf_pmu@most-busy-idle-check-all@rcs0:
- {shard-dg1}: [FAIL][59] ([i915#5234]) -> [PASS][60]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7284/shard-dg1-16/igt@perf_pmu@[email protected]
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/shard-dg1-18/igt@perf_pmu@[email protected]

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

[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
[fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#109300]: https://bugs.freedesktop.org/show_bug.cgi?id=109300
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[fdo#112283]: https://bugs.freedesktop.org/show_bug.cgi?id=112283
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1257]: https://gitlab.freedesktop.org/drm/intel/issues/1257
[i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
[i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
[i915#1937]: https://gitlab.freedesktop.org/drm/intel/issues/1937
[i915#2122]: https://gitlab.freedesktop.org/drm/intel/issues/2122
[i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
[i915#2437]: https://gitlab.freedesktop.org/drm/intel/issues/2437
[i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
[i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#2846]: https://gitlab.freedesktop.org/drm/intel/issues/2846
[i915#3023]: https://gitlab.freedesktop.org/drm/intel/issues/3023
[i915#3063]: https://gitlab.freedesktop.org/drm/intel/issues/3063
[i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
[i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
[i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
[i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
[i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
[i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
[i915#3778]: https://gitlab.freedesktop.org/drm/intel/issues/3778
[i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
[i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
[i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
[i915#433]: https://gitlab.freedesktop.org/drm/intel/issues/433
[i915#4349]: https://gitlab.freedesktop.org/drm/intel/issues/4349
[i915#4525]: https://gitlab.freedesktop.org/drm/intel/issues/4525
[i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
[i915#4573]: https://gitlab.freedesktop.org/drm/intel/issues/4573
[i915#4579]: https://gitlab.freedesktop.org/drm/intel/issues/4579
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4771]: https://gitlab.freedesktop.org/drm/intel/issues/4771
[i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
[i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
[i915#4936]: https://gitlab.freedesktop.org/drm/intel/issues/4936
[i915#5099]: https://gitlab.freedesktop.org/drm/intel/issues/5099
[i915#5122]: https://gitlab.freedesktop.org/drm/intel/issues/5122
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5234]: https://gitlab.freedesktop.org/drm/intel/issues/5234
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5461]: https://gitlab.freedesktop.org/drm/intel/issues/5461
[i915#5493]: https://gitlab.freedesktop.org/drm/intel/issues/5493
[i915#5566]: https://gitlab.freedesktop.org/drm/intel/issues/5566
[i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
[i915#6268]: https://gitlab.freedesktop.org/drm/intel/issues/6268
[i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
[i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
[i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
[i915#6786]: https://gitlab.freedesktop.org/drm/intel/issues/6786
[i915#6806]: https://gitlab.freedesktop.org/drm/intel/issues/6806
[i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
[i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
[i915#7461]: https://gitlab.freedesktop.org/drm/intel/issues/7461
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
[i915#7941]: https://gitlab.freedesktop.org/drm/intel/issues/7941
[i915#7953]: https://gitlab.freedesktop.org/drm/intel/issues/7953
[i915#7975]: https://gitlab.freedesktop.org/drm/intel/issues/7975
[i915#8011]: https://gitlab.freedesktop.org/drm/intel/issues/8011
[i915#8211]: https://gitlab.freedesktop.org/drm/intel/issues/8211
[i915#8213]: https://gitlab.freedesktop.org/drm/intel/issues/8213
[i915#8234]: https://gitlab.freedesktop.org/drm/intel/issues/8234
[i915#8292]: https://gitlab.freedesktop.org/drm/intel/issues/8292
[i915#8311]: https://gitlab.freedesktop.org/drm/intel/issues/8311
[i915#8411]: https://gitlab.freedesktop.org/drm/intel/issues/8411
[i915#8414]: https://gitlab.freedesktop.org/drm/intel/issues/8414

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

* CI: CI-20190529 -> None
* IGT: IGT_7284 -> IGTPW_8937

CI-20190529: 20190529
CI_DRM_13128: 31e3463b0edba64934bfd9e8fdbebeab1676d3eb @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8937: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8937/index.html
IGT_7284: 8c017d37b521276c113ad590521636eba8d7009c @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

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

#3 lore raw
In reply to [email protected]
Quoted 9 lines · On Wed, May 10, 2023 at 11:25:29AM +0530, [email protected] wrote:

From: Sai Gowtham Ch <[email protected]>

Extending the spin_create implementation and allocator handle support in xe, where it submits dummy work loads to engine. This Implementation is wrapped around vm_bind and unbind as we are supposed to do it manually for xe.

Cc Bhanuprakash Modem <[email protected]>
Cc Zbigniew Kempczyński <[email protected]>

Please provide some test I can run with this on xe and verify this library extension is working.

--
Zbigniew

Quoted 210 lines
---
 lib/igt_dummyload.c | 24 ++++++++++++----
 lib/igt_dummyload.h | 10 +++++++
 lib/xe/xe_spin.c    | 67 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 102 insertions(+), 6 deletions(-)
lib/igt_dummyload.c +18 -6
index 740a58f3..6e89b72d 100644
@@ -46,6 +46,7 @@
 #include "intel_reg.h"
 #include "ioctl_wrappers.h"
 #include "sw_sync.h"
+#include "xe/xe_spin.h"
 
 /**
  * SECTION:igt_dummyload
@@ -447,7 +448,10 @@ spin_create(int fd, const struct igt_spin_factory *opts)
 igt_spin_t *
 __igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 {
-	return spin_create(fd, opts);
+	if (is_xe_device(fd))
+		return xe_spin_create(fd, opts);
+	else
+		return spin_create(fd, opts);
 }
 
 /**
@@ -467,6 +471,11 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 {
 	igt_spin_t *spin;
 
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	}
+
 	if ((opts->flags & IGT_SPIN_POLL_RUN) && opts->engine != ALL_ENGINES) {
 		unsigned int class;
 
@@ -647,11 +656,14 @@ void igt_spin_free(int fd, igt_spin_t *spin)
 	if (!spin)
 		return;
 
-	pthread_mutex_lock(&list_lock);
-	igt_list_del(&spin->link);
-	pthread_mutex_unlock(&list_lock);
-
-	__igt_spin_free(fd, spin);
+	if (is_xe_device(fd)) {
+		xe_spin_free(fd, spin);
+	} else {
+		pthread_mutex_lock(&list_lock);
+		igt_list_del(&spin->link);
+		pthread_mutex_unlock(&list_lock);
+		__igt_spin_free(fd, spin);
+	}
 }
 
 void igt_terminate_spins(void)
lib/igt_dummyload.h +10 -0
index b247ab02..c2900a8f 100644
@@ -51,6 +51,7 @@ typedef struct igt_spin_factory {
 	uint32_t dependency;
 	uint64_t dependency_size;
 	unsigned int engine;
+	struct drm_xe_engine_class_instance *hwe;
 	unsigned int flags;
 	int fence;
 	uint64_t ahnd;
@@ -83,6 +84,15 @@ typedef struct igt_spin {
 #define SPIN_CLFLUSH (1 << 0)
 
 	struct igt_spin_factory opts;
+
+	uint32_t start;
+	uint32_t end;
+	size_t bo_size;
+	uint64_t address;
+	unsigned int engine;
+	uint32_t vm;
+	uint32_t syncobj;
+
 } igt_spin_t;
 
 
lib/xe/xe_spin.c +67 -0
index 856d0ba2..5f3a3b4f 100644
@@ -15,6 +15,7 @@
 #include "intel_reg.h"
 #include "xe_ioctl.h"
 #include "xe_spin.h"
+#include "lib/igt_dummyload.h"
 
 /**
  * xe_spin_init:
@@ -82,6 +83,72 @@ void xe_spin_end(struct xe_spin *spin)
 	spin->end = 0;
 }
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt)
+{
+	size_t bo_size = xe_get_default_alignment(fd);
+	uint32_t bo;
+	uint64_t ahnd = opt->ahnd, addr;
+	struct igt_spin *spin;
+	struct xe_spin *xe_spin;
+	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),
+	};
+
+	igt_assert(ahnd);
+	xe_spin = calloc(1, sizeof(struct xe_spin));
+	igt_assert(xe_spin);
+	spin = calloc(1, sizeof(struct igt_spin));
+	igt_assert(spin);
+
+	spin->vm = xe_vm_create(fd, 0, 0);
+	bo = xe_bo_create(fd, opt->hwe->gt_id, spin->vm, bo_size);
+	spin = xe_bo_map(fd, bo, 0x1000);
+	spin->handle = bo;
+	if (opt->engine)
+		spin->engine = opt->engine;
+	else
+		spin->engine = xe_engine_create(fd, spin->vm, opt->hwe, 0);
+
+	spin->syncobj = syncobj_create(fd, 0);
+	addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+	xe_vm_bind_sync(fd, spin->vm, bo, 0, addr, bo_size);
+
+	xe_spin_init(xe_spin, addr, true);
+	exec.engine_id = spin->engine;
+	exec.address = addr;
+	sync.handle = spin->syncobj;
+	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC, &exec), 0);
+
+	spin->batch = xe_spin->batch;
+	spin->start = xe_spin->start;
+	spin->end = xe_spin->end;
+	spin->bo_size = bo_size;
+	spin->address = addr;
+	return spin;
+
+}
+
+void xe_spin_sync_wait(int fd, struct igt_spin *spin)
+{
+	igt_assert(syncobj_wait(fd, &spin->syncobj, 1, INT64_MAX, 0,
+				NULL));
+}
+
+void xe_spin_free(int fd, struct igt_spin *spin)
+{
+	xe_vm_unbind_sync(fd, spin->vm, 0, spin->address, spin->bo_size);
+	spin->end = 0;
+	syncobj_destroy(fd, spin->syncobj);
+	xe_engine_destroy(fd, spin->engine);
+	gem_close(fd, spin->handle);
+}
+
 void xe_cork_init(int fd, struct drm_xe_engine_class_instance *hwe,
 		  struct xe_cork *cork)
 {
lib/xe/xe_spin.h +7 -0
index 73f9a026..48867eb8 100644
@@ -13,19 +13,26 @@
 #include <stdbool.h>
 
 #include "xe_query.h"
+#include "lib/igt_dummyload.h"
 
 /* Mapped GPU object */
+
 struct xe_spin {
 	uint32_t batch[16];
 	uint64_t pad;
 	uint32_t start;
 	uint32_t end;
+
 };
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt);
 void xe_spin_init(struct xe_spin *spin, uint64_t addr, bool preempt);
 bool xe_spin_started(struct xe_spin *spin);
+void xe_spin_sync_wait(int fd, struct igt_spin *spin);
 void xe_spin_wait_started(struct xe_spin *spin);
 void xe_spin_end(struct xe_spin *spin);
+void xe_spin_free(int fd, struct igt_spin *spin);
 
 struct xe_cork {
 	struct xe_spin *spin;
Signature · 1 line
2.39.1
#4 lore raw
Quoted 16 lines

-----Original Message-----
From: Kempczynski, Zbigniew <[email protected]>
Sent: Thursday, May 11, 2023 10:38 AM
To: Ch, Sai Gowtham <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH i-g-t] lib/xe/xe_spin: Integrate igt_spin_new with Xe.

Quoted 5 lines · On Wed, May 10, 2023 at 11:25:29AM +0530, [email protected] wrote:

From: Sai Gowtham Ch <[email protected]>

Extending the spin_create implementation and allocator handle support in xe, where it submits dummy work loads to engine. This Implementation is wrapped around vm_bind and unbind as we are supposed to

Quoted 9 lines

do it manually for xe.

Quoted 4 lines
Cc Bhanuprakash Modem <[email protected]>
Cc Zbigniew Kempczyński <[email protected]>

Please provide some test I can run with this on xe and verify this library extension is working.

Will be coming up with a simple test which exercises this lib.

Thanks,
Gowtham

Quoted 211 lines

--
Zbigniew

Quoted 31 lines
---
 lib/igt_dummyload.c | 24 ++++++++++++----  lib/igt_dummyload.h | 10
+++++++
 lib/xe/xe_spin.c    | 67 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 102 insertions(+), 6 deletions(-)
lib/igt_dummyload.c index renamed from lib/igt_dummyload.c +0 -0

740a58f3..6e89b72d 100644

lib/igt_dummyload.c +5 -1
@@ -46,6 +46,7 @@
 #include "intel_reg.h"
 #include "ioctl_wrappers.h"
 #include "sw_sync.h"
+#include "xe/xe_spin.h"
 
 /**
  * SECTION:igt_dummyload
@@ -447,7 +448,10 @@ spin_create(int fd, const struct igt_spin_factory
 *opts)  igt_spin_t *  __igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)  {
-	return spin_create(fd, opts);
+	if (is_xe_device(fd))
+		return xe_spin_create(fd, opts);
+	else
+		return spin_create(fd, opts);
 }
 
 /**

lib/igt_dummyload.c igt_spin_factory(int fd, const struct · line 479

Quoted 9 lines
lib/igt_dummyload.c +5 -0
@@ -467,6 +471,11 @@ igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)  {
 	igt_spin_t *spin;
 
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	}
+
 	if ((opts->flags & IGT_SPIN_POLL_RUN) && opts->engine !=

ALL_ENGINES) {

Quoted 89 lines
lib/igt_dummyload.c +8 -5
 		unsigned int class;
 
@@ -647,11 +656,14 @@ void igt_spin_free(int fd, igt_spin_t *spin)
 	if (!spin)
 		return;
 
-	pthread_mutex_lock(&list_lock);
-	igt_list_del(&spin->link);
-	pthread_mutex_unlock(&list_lock);
-
-	__igt_spin_free(fd, spin);
+	if (is_xe_device(fd)) {
+		xe_spin_free(fd, spin);
+	} else {
+		pthread_mutex_lock(&list_lock);
+		igt_list_del(&spin->link);
+		pthread_mutex_unlock(&list_lock);
+		__igt_spin_free(fd, spin);
+	}
 }
 
 void igt_terminate_spins(void)
lib/igt_dummyload.h index renamed from lib/igt_dummyload.h +0 -0

b247ab02..c2900a8f 100644

lib/igt_dummyload.h +10 -0
@@ -51,6 +51,7 @@ typedef struct igt_spin_factory {
 	uint32_t dependency;
 	uint64_t dependency_size;
 	unsigned int engine;
+	struct drm_xe_engine_class_instance *hwe;
 	unsigned int flags;
 	int fence;
 	uint64_t ahnd;
@@ -83,6 +84,15 @@ typedef struct igt_spin {  #define SPIN_CLFLUSH (1
 << 0)
 
 	struct igt_spin_factory opts;
+
+	uint32_t start;
+	uint32_t end;
+	size_t bo_size;
+	uint64_t address;
+	unsigned int engine;
+	uint32_t vm;
+	uint32_t syncobj;
+
 } igt_spin_t;
 
 
lib/xe/xe_spin.c index renamed from lib/xe/xe_spin.c +0 -0

856d0ba2..5f3a3b4f 100644

lib/xe/xe_spin.c +24 -0
@@ -15,6 +15,7 @@
 #include "intel_reg.h"
 #include "xe_ioctl.h"
 #include "xe_spin.h"
+#include "lib/igt_dummyload.h"
 
 /**
  * xe_spin_init:
@@ -82,6 +83,72 @@ void xe_spin_end(struct xe_spin *spin)
 	spin->end = 0;
 }
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt) {
+	size_t bo_size = xe_get_default_alignment(fd);
+	uint32_t bo;
+	uint64_t ahnd = opt->ahnd, addr;
+	struct igt_spin *spin;
+	struct xe_spin *xe_spin;
+	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),
+	};
+
+	igt_assert(ahnd);
+	xe_spin = calloc(1, sizeof(struct xe_spin));
+	igt_assert(xe_spin);
+	spin = calloc(1, sizeof(struct igt_spin));
+	igt_assert(spin);
+
+	spin->vm = xe_vm_create(fd, 0, 0);

lib/xe/xe_spin.c void xe_spin_end(struct xe_spin *spin) · line 118

Quoted 10 lines
lib/xe/xe_spin.c +10 -0
+	bo = xe_bo_create(fd, opt->hwe->gt_id, spin->vm, bo_size);
+	spin = xe_bo_map(fd, bo, 0x1000);
+	spin->handle = bo;
+	if (opt->engine)
+		spin->engine = opt->engine;
+	else
+		spin->engine = xe_engine_create(fd, spin->vm, opt->hwe, 0);
+
+	spin->syncobj = syncobj_create(fd, 0);
+	addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0,

ALLOC_STRATEGY_LOW_TO_HIGH);

Quoted 67 lines
lib/xe/xe_spin.c +30 -0
+	xe_vm_bind_sync(fd, spin->vm, bo, 0, addr, bo_size);
+
+	xe_spin_init(xe_spin, addr, true);
+	exec.engine_id = spin->engine;
+	exec.address = addr;
+	sync.handle = spin->syncobj;
+	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC, &exec), 0);
+
+	spin->batch = xe_spin->batch;
+	spin->start = xe_spin->start;
+	spin->end = xe_spin->end;
+	spin->bo_size = bo_size;
+	spin->address = addr;
+	return spin;
+
+}
+
+void xe_spin_sync_wait(int fd, struct igt_spin *spin) {
+	igt_assert(syncobj_wait(fd, &spin->syncobj, 1, INT64_MAX, 0,
+				NULL));
+}
+
+void xe_spin_free(int fd, struct igt_spin *spin) {
+	xe_vm_unbind_sync(fd, spin->vm, 0, spin->address, spin->bo_size);
+	spin->end = 0;
+	syncobj_destroy(fd, spin->syncobj);
+	xe_engine_destroy(fd, spin->engine);
+	gem_close(fd, spin->handle);
+}
+
 void xe_cork_init(int fd, struct drm_xe_engine_class_instance *hwe,
 		  struct xe_cork *cork)
 {
lib/xe/xe_spin.h index renamed from lib/xe/xe_spin.h +0 -0

73f9a026..48867eb8 100644

lib/xe/xe_spin.h +7 -1
@@ -13,19 +13,26 @@
 #include <stdbool.h>
 
 #include "xe_query.h"
+#include "lib/igt_dummyload.h"
 
 /* Mapped GPU object */
+
 struct xe_spin {
 	uint32_t batch[16];
 	uint64_t pad;
 	uint32_t start;
 	uint32_t end;
+
 };
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt);
 void xe_spin_init(struct xe_spin *spin, uint64_t addr, bool preempt);
 bool xe_spin_started(struct xe_spin *spin);
+void xe_spin_sync_wait(int fd, struct igt_spin *spin);
 void xe_spin_wait_started(struct xe_spin *spin);  void
 xe_spin_end(struct xe_spin *spin);
+void xe_spin_free(int fd, struct igt_spin *spin);
 
 struct xe_cork {
 	struct xe_spin *spin;
--

2.39.1

#5 lore raw
In reply to [email protected]

Hello Sai, see my comments inline below:

Quoted 139 lines · On Wed, 2023-05-10 at 11:25 +0530, [email protected] wrote:

From: Sai Gowtham Ch <[email protected]>

Extending the spin_create implementation and allocator handle support in xe,
where it submits dummy work loads to engine. This Implementation is wrapped
around vm_bind and unbind as we are supposed to do it manually for xe.

Cc Bhanuprakash Modem <[email protected]>
Cc Zbigniew Kempczyński <[email protected]>

---
 lib/igt_dummyload.c | 24 ++++++++++++----
 lib/igt_dummyload.h | 10 +++++++
 lib/xe/xe_spin.c    | 67
+++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++

 4 files changed, 102 insertions(+), 6 deletions(-)
lib/igt_dummyload.c +1 -0
index 740a58f3..6e89b72d 100644
@@ -46,6 +46,7 @@
  #include "intel_reg.h"
  #include "ioctl_wrappers.h"
  #include "sw_sync.h"
+#include "xe/xe_spin.h"


 /**
  * SECTION:igt_dummyload

lib/igt_dummyload.c +0 -0
@@ -447,7 +448,10 @@ spin_create(int fd, const struct
 igt_spin_factory *opts)

 igt_spin_t *
 __igt_spin_factory(int fd, const struct igt_spin_factory *opts) {
-       return spin_create(fd, opts);
+       if (is_xe_device(fd))
+               return xe_spin_create(fd, opts);
+       else
+               return spin_create(fd, opts);
 }

 /**

lib/igt_dummyload.c +0 -0
@@ -467,6 +471,11 @@ igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)
  {
         igt_spin_t *spin;


+       if (is_xe_device(fd)) {
+               spin = xe_spin_create(fd, opts);
+               return spin;
+       }
+
        if ((opts->flags & IGT_SPIN_POLL_RUN) && opts->engine != ALL_ENGINES) {
                unsigned int class;

lib/igt_dummyload.c +0 -0
@@ -647,11 +656,14 @@ void igt_spin_free(int fd, igt_spin_t *spin)
         if (!spin)
                 return;


-       pthread_mutex_lock(&list_lock);
-       igt_list_del(&spin->link);
-       pthread_mutex_unlock(&list_lock);
-
-       __igt_spin_free(fd, spin);
+       if (is_xe_device(fd)) {
+               xe_spin_free(fd, spin);
+       } else {
+               pthread_mutex_lock(&list_lock);
+               igt_list_del(&spin->link);
+               pthread_mutex_unlock(&list_lock);
+               __igt_spin_free(fd, spin);
+       }
 }

 void igt_terminate_spins(void)

lib/igt_dummyload.h +1 -0
index b247ab02..c2900a8f 100644
@@ -51,6 +51,7 @@ typedef struct igt_spin_factory {
         uint32_t dependency;
         uint64_t dependency_size;
         unsigned int engine;
+       struct drm_xe_engine_class_instance *hwe;
         unsigned int flags;
         int fence;
         uint64_t ahnd;
@@ -83,6 +84,15 @@ typedef struct igt_spin {
  #define SPIN_CLFLUSH (1 << 0)


        struct igt_spin_factory opts;

lib/igt_dummyload.h +9 -0
+
+       uint32_t start;
+       uint32_t end;
+       size_t bo_size;
+       uint64_t address;
+       unsigned int engine;
+       uint32_t vm;
+       uint32_t syncobj;
+

 } igt_spin_t;

lib/xe/xe_spin.c +1 -0
index 856d0ba2..5f3a3b4f 100644
@@ -15,6 +15,7 @@
  #include "intel_reg.h"
  #include "xe_ioctl.h"
  #include "xe_spin.h"
+#include "lib/igt_dummyload.h"


 /**
  * xe_spin_init:

lib/xe/xe_spin.c +0 -0
@@ -82,6 +83,72 @@ void xe_spin_end(struct xe_spin *spin)
         spin->end = 0;
  }

lib/xe/xe_spin.c +16 -0
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt)
+{
+       size_t bo_size = xe_get_default_alignment(fd);
+       uint32_t bo;
+       uint64_t ahnd = opt->ahnd, addr;
+       struct igt_spin *spin;
+       struct xe_spin *xe_spin;
+       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),
+       };

lib/xe/xe_spin.c void xe_spin_end(struct xe_spin *spin) · line 111

Quoted 10 lines
lib/xe/xe_spin.c +10 -0
+
+       igt_assert(ahnd);
+       xe_spin = calloc(1, sizeof(struct xe_spin));
+       igt_assert(xe_spin);
+       spin = calloc(1, sizeof(struct igt_spin));
+       igt_assert(spin);
+
+       spin->vm = xe_vm_create(fd, 0, 0);
+       bo = xe_bo_create(fd, opt->hwe->gt_id, spin->vm, bo_size);
+       spin = xe_bo_map(fd, bo, 0x1000);

This looks a bit strange. You are allocating spin above and then setting the pointer here.

I tried your code again with my testcase. Still I'm seeing crashes/failures. Do you have some example testcase how this is supposed to be used?

Quoted 78 lines

+       spin->handle = bo;
+       if (opt->engine)
+               spin->engine = opt->engine;
+       else
+               spin->engine = xe_engine_create(fd, spin->vm, opt-

Quoted 1 line

hwe, 0);

+
+       spin->syncobj = syncobj_create(fd, 0);
+       addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+       xe_vm_bind_sync(fd, spin->vm, bo, 0, addr, bo_size);

lib/xe/xe_spin.c +25 -0
+
+       xe_spin_init(xe_spin, addr, true);
+       exec.engine_id = spin->engine;
+       exec.address = addr;
+       sync.handle = spin->syncobj;
+       igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC, &exec), 0);
+
+       spin->batch = xe_spin->batch;
+       spin->start = xe_spin->start;
+       spin->end = xe_spin->end;
+       spin->bo_size = bo_size;
+       spin->address = addr;
+       return spin;
+
+}
+
+void xe_spin_sync_wait(int fd, struct igt_spin *spin)
+{
+       igt_assert(syncobj_wait(fd, &spin->syncobj, 1, INT64_MAX, 0,
+                               NULL));
+}
+
+void xe_spin_free(int fd, struct igt_spin *spin)
+{
+       xe_vm_unbind_sync(fd, spin->vm, 0, spin->address, spin-
Quoted 1 line

bo_size);

+       spin->end = 0;
+       syncobj_destroy(fd, spin->syncobj);
+       xe_engine_destroy(fd, spin->engine);
+       gem_close(fd, spin->handle);

lib/xe/xe_spin.c +2 -0
+}
+

 void xe_cork_init(int fd, struct drm_xe_engine_class_instance *hwe, struct xe_cork *cork)
 {

lib/xe/xe_spin.h +0 -0
index 73f9a026..48867eb8 100644
@@ -13,19 +13,26 @@
  #include <stdbool.h>


 #include "xe_query.h"
+#include "lib/igt_dummyload.h"

 /* Mapped GPU object */
+
 struct xe_spin {
        uint32_t batch[16];
        uint64_t pad;
        uint32_t start;
        uint32_t end;
+
 };

lib/xe/xe_spin.h +2 -0
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt);

 void xe_spin_init(struct xe_spin *spin, uint64_t addr, bool preempt);
 bool xe_spin_started(struct xe_spin *spin);
+void xe_spin_sync_wait(int fd, struct igt_spin *spin); void xe_spin_wait_started(struct xe_spin *spin); void xe_spin_end(struct xe_spin *spin);
+void xe_spin_free(int fd, struct igt_spin *spin);
 struct xe_cork {
        struct xe_spin *spin;

#6 lore raw
Quoted 163 lines

-----Original Message-----
From: Hogander, Jouni <[email protected]>
Sent: Thursday, May 11, 2023 12:14 PM
To: Kempczynski, Zbigniew <[email protected]>; Ch, Sai Gowtham <[email protected]>; [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] lib/xe/xe_spin: Integrate igt_spin_new with Xe.

Hello Sai, see my comments inline below:

Quoted 136 lines · On Wed, 2023-05-10 at 11:25 +0530, [email protected] wrote:

From: Sai Gowtham Ch <[email protected]>

Extending the spin_create implementation and allocator handle support in xe, where it submits dummy work loads to engine. This Implementation is wrapped around vm_bind and unbind as we are supposed to do it manually for xe.

Cc Bhanuprakash Modem <[email protected]>
Cc Zbigniew Kempczyński <[email protected]>

---
 lib/igt_dummyload.c | 24 ++++++++++++----
 lib/igt_dummyload.h | 10 +++++++
 lib/xe/xe_spin.c    | 67
+++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++

 4 files changed, 102 insertions(+), 6 deletions(-)
lib/igt_dummyload.c index renamed from lib/igt_dummyload.c +0 -0

740a58f3..6e89b72d 100644

lib/igt_dummyload.c +1 -0
@@ -46,6 +46,7 @@
  #include "intel_reg.h"
  #include "ioctl_wrappers.h"
  #include "sw_sync.h"
+#include "xe/xe_spin.h"
 
  /**
   * SECTION:igt_dummyload
@@ -447,7 +448,10 @@ spin_create(int fd, const struct igt_spin_factory
 *opts)

 igt_spin_t *
 __igt_spin_factory(int fd, const struct igt_spin_factory *opts) {
-       return spin_create(fd, opts);
+       if (is_xe_device(fd))
+               return xe_spin_create(fd, opts);
+       else
+               return spin_create(fd, opts);
 }

 /**

lib/igt_dummyload.c +5 -0
@@ -467,6 +471,11 @@ igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)
  {
         igt_spin_t *spin;
 
+       if (is_xe_device(fd)) {
+               spin = xe_spin_create(fd, opts);
+               return spin;
+       }
+

        if ((opts->flags & IGT_SPIN_POLL_RUN) && opts->engine != ALL_ENGINES) {
                unsigned int class;

lib/igt_dummyload.c +8 -5
@@ -647,11 +656,14 @@ void igt_spin_free(int fd, igt_spin_t *spin)
         if (!spin)
                 return;
 
-       pthread_mutex_lock(&list_lock);
-       igt_list_del(&spin->link);
-       pthread_mutex_unlock(&list_lock);
-
-       __igt_spin_free(fd, spin);
+       if (is_xe_device(fd)) {
+               xe_spin_free(fd, spin);
+       } else {
+               pthread_mutex_lock(&list_lock);
+               igt_list_del(&spin->link);
+               pthread_mutex_unlock(&list_lock);
+               __igt_spin_free(fd, spin);
+       }
  }
 
  void igt_terminate_spins(void)
lib/igt_dummyload.h index renamed from lib/igt_dummyload.h +0 -0

b247ab02..c2900a8f 100644

lib/igt_dummyload.h +10 -0
@@ -51,6 +51,7 @@ typedef struct igt_spin_factory {
         uint32_t dependency;
         uint64_t dependency_size;
         unsigned int engine;
+       struct drm_xe_engine_class_instance *hwe;
         unsigned int flags;
         int fence;
         uint64_t ahnd;
@@ -83,6 +84,15 @@ typedef struct igt_spin {
  #define SPIN_CLFLUSH (1 << 0)
 
         struct igt_spin_factory opts;
+
+       uint32_t start;
+       uint32_t end;
+       size_t bo_size;
+       uint64_t address;
+       unsigned int engine;
+       uint32_t vm;
+       uint32_t syncobj;
+
  } igt_spin_t;
 
 
lib/xe/xe_spin.c index renamed from lib/xe/xe_spin.c +0 -0

856d0ba2..5f3a3b4f 100644

lib/xe/xe_spin.c +16 -0
@@ -15,6 +15,7 @@
  #include "intel_reg.h"
  #include "xe_ioctl.h"
  #include "xe_spin.h"
+#include "lib/igt_dummyload.h"
 
  /**
   * xe_spin_init:
@@ -82,6 +83,72 @@ void xe_spin_end(struct xe_spin *spin)
         spin->end = 0;
  }
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt) {
+       size_t bo_size = xe_get_default_alignment(fd);
+       uint32_t bo;
+       uint64_t ahnd = opt->ahnd, addr;
+       struct igt_spin *spin;
+       struct xe_spin *xe_spin;
+       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),
+       };

lib/xe/xe_spin.c void xe_spin_end(struct xe_spin *spin) · line 110

Quoted 10 lines
lib/xe/xe_spin.c +10 -0
+
+       igt_assert(ahnd);
+       xe_spin = calloc(1, sizeof(struct xe_spin));
+       igt_assert(xe_spin);
+       spin = calloc(1, sizeof(struct igt_spin));
+       igt_assert(spin);
+
+       spin->vm = xe_vm_create(fd, 0, 0);
+       bo = xe_bo_create(fd, opt->hwe->gt_id, spin->vm, bo_size);
+       spin = xe_bo_map(fd, bo, 0x1000);

This looks a bit strange. You are allocating spin above and then setting the pointer here.

Quoted 2 lines

I tried your code again with my testcase. Still I'm seeing crashes/failures. Do you have some example testcase how this is supposed to be used?

Does your test using i915 or xe ?? if i915 then there is no change in the functionality it's the same existing code, because this change is specific to only xe.

Because from this patch https://patchwork.freedesktop.org/series/116130/ it looks like you are using spinner for i915.

Thanks,
Gowtham

Quoted 75 lines
Quoted 75 lines
lib/xe/xe_spin.c +37 -0
+       spin->handle = bo;
+       if (opt->engine)
+               spin->engine = opt->engine;
+       else
+               spin->engine = xe_engine_create(fd, spin->vm, opt-
 >hwe, 0);
+
+       spin->syncobj = syncobj_create(fd, 0);
+       addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size,
 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+       xe_vm_bind_sync(fd, spin->vm, bo, 0, addr, bo_size);
+
+       xe_spin_init(xe_spin, addr, true);
+       exec.engine_id = spin->engine;
+       exec.address = addr;
+       sync.handle = spin->syncobj;
+       igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC, &exec), 0);
+
+       spin->batch = xe_spin->batch;
+       spin->start = xe_spin->start;
+       spin->end = xe_spin->end;
+       spin->bo_size = bo_size;
+       spin->address = addr;
+       return spin;
+
+}
+
+void xe_spin_sync_wait(int fd, struct igt_spin *spin) {
+       igt_assert(syncobj_wait(fd, &spin->syncobj, 1, INT64_MAX, 0,
+                               NULL)); }
+
+void xe_spin_free(int fd, struct igt_spin *spin) {
+       xe_vm_unbind_sync(fd, spin->vm, 0, spin->address, spin-
 >bo_size);
+       spin->end = 0;
+       syncobj_destroy(fd, spin->syncobj);
+       xe_engine_destroy(fd, spin->engine);
+       gem_close(fd, spin->handle);
+}
+

 void xe_cork_init(int fd, struct drm_xe_engine_class_instance *hwe, struct xe_cork *cork)
 {

lib/xe/xe_spin.h index renamed from lib/xe/xe_spin.h +0 -0

73f9a026..48867eb8 100644

lib/xe/xe_spin.h +7 -0
@@ -13,19 +13,26 @@
  #include <stdbool.h>
 
  #include "xe_query.h"
+#include "lib/igt_dummyload.h"
 
  /* Mapped GPU object */
+
  struct xe_spin {
         uint32_t batch[16];
         uint64_t pad;
         uint32_t start;
         uint32_t end;
+
  };
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt);
  void xe_spin_init(struct xe_spin *spin, uint64_t addr, bool preempt);
  bool xe_spin_started(struct xe_spin *spin);
+void xe_spin_sync_wait(int fd, struct igt_spin *spin);
  void xe_spin_wait_started(struct xe_spin *spin);
  void xe_spin_end(struct xe_spin *spin);
+void xe_spin_free(int fd, struct igt_spin *spin);
 
  struct xe_cork {
         struct xe_spin *spin;
#7 lore raw
Quoted 174 lines · Sai Gowtham
Quoted 171 lines

-----Original Message-----
From: Hogander, Jouni <[email protected]>
Sent: Thursday, May 11, 2023 12:14 PM
To: Kempczynski, Zbigniew <[email protected]>; Ch, Sai Gowtham <[email protected]>; [email protected]
Subject: Re: [igt-dev] [PATCH i-g-t] lib/xe/xe_spin: Integrate igt_spin_new with
Xe.

Hello Sai, see my comments inline below:

Quoted 142 lines · On Wed, 2023-05-10 at 11:25 +0530, [email protected] wrote:

From: Sai Gowtham Ch <[email protected]>

Extending the spin_create implementation and allocator handle support
in xe, where it submits dummy work loads to engine. This Implementation is wrapped around vm_bind and unbind as we are supposed
to do it manually for xe.

Cc Bhanuprakash Modem <[email protected]>
Cc Zbigniew Kempczyński <[email protected]>

---
 lib/igt_dummyload.c | 24 ++++++++++++----
 lib/igt_dummyload.h | 10 +++++++
 lib/xe/xe_spin.c    | 67
+++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++

 4 files changed, 102 insertions(+), 6 deletions(-)
lib/igt_dummyload.c index renamed from lib/igt_dummyload.c +0 -0

740a58f3..6e89b72d 100644

lib/igt_dummyload.c +1 -0
@@ -46,6 +46,7 @@
  #include "intel_reg.h"
  #include "ioctl_wrappers.h"
  #include "sw_sync.h"
+#include "xe/xe_spin.h"
 
  /**
   * SECTION:igt_dummyload
@@ -447,7 +448,10 @@ spin_create(int fd, const struct

igt_spin_factory
*opts)
 igt_spin_t *
 __igt_spin_factory(int fd, const struct igt_spin_factory *opts) {
-       return spin_create(fd, opts);
+       if (is_xe_device(fd))
+               return xe_spin_create(fd, opts);
+       else
+               return spin_create(fd, opts);
 }

 /**

lib/igt_dummyload.c +5 -0
@@ -467,6 +471,11 @@ igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)
  {
         igt_spin_t *spin;
 
+       if (is_xe_device(fd)) {
+               spin = xe_spin_create(fd, opts);
+               return spin;
+       }
+

        if ((opts->flags & IGT_SPIN_POLL_RUN) && opts->engine != ALL_ENGINES) {
                unsigned int class;

lib/igt_dummyload.c +8 -5
@@ -647,11 +656,14 @@ void igt_spin_free(int fd, igt_spin_t
 *spin)
         if (!spin)
                 return;
 
-       pthread_mutex_lock(&list_lock);
-       igt_list_del(&spin->link);
-       pthread_mutex_unlock(&list_lock);
-
-       __igt_spin_free(fd, spin);
+       if (is_xe_device(fd)) {
+               xe_spin_free(fd, spin);
+       } else {
+               pthread_mutex_lock(&list_lock);
+               igt_list_del(&spin->link);
+               pthread_mutex_unlock(&list_lock);
+               __igt_spin_free(fd, spin);
+       }
  }
 

 void igt_terminate_spins(void)

lib/igt_dummyload.h index renamed from lib/igt_dummyload.h +0 -0

b247ab02..c2900a8f 100644

lib/igt_dummyload.h +10 -0
@@ -51,6 +51,7 @@ typedef struct igt_spin_factory {
         uint32_t dependency;
         uint64_t dependency_size;
         unsigned int engine;
+       struct drm_xe_engine_class_instance *hwe;
         unsigned int flags;
         int fence;
         uint64_t ahnd;
@@ -83,6 +84,15 @@ typedef struct igt_spin {
  #define SPIN_CLFLUSH (1 << 0)
 
         struct igt_spin_factory opts;
+
+       uint32_t start;
+       uint32_t end;
+       size_t bo_size;
+       uint64_t address;
+       unsigned int engine;
+       uint32_t vm;
+       uint32_t syncobj;
+
  } igt_spin_t;
 
 
lib/xe/xe_spin.c index renamed from lib/xe/xe_spin.c +0 -0

856d0ba2..5f3a3b4f 100644

lib/xe/xe_spin.c +17 -0
@@ -15,6 +15,7 @@
  #include "intel_reg.h"
  #include "xe_ioctl.h"
  #include "xe_spin.h"
+#include "lib/igt_dummyload.h"
 
  /**
   * xe_spin_init:
@@ -82,6 +83,72 @@ void xe_spin_end(struct xe_spin *spin)
         spin->end = 0;
  }
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt) {
+       size_t bo_size = xe_get_default_alignment(fd);
+       uint32_t bo;
+       uint64_t ahnd = opt->ahnd, addr;
+       struct igt_spin *spin;
+       struct xe_spin *xe_spin;
+       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),
+       };
+

lib/xe/xe_spin.c void xe_spin_end(struct xe_spin *spin) · line 112

Quoted 10 lines
lib/xe/xe_spin.c +9 -0
+       igt_assert(ahnd);
+       xe_spin = calloc(1, sizeof(struct xe_spin));
+       igt_assert(xe_spin);
+       spin = calloc(1, sizeof(struct igt_spin));
+       igt_assert(spin);
+
+       spin->vm = xe_vm_create(fd, 0, 0);
+       bo = xe_bo_create(fd, opt->hwe->gt_id, spin->vm,
 bo_size);
+       spin = xe_bo_map(fd, bo, 0x1000);

This looks a bit strange. You are allocating spin above and then setting the
pointer here.

Quoted 3 lines

I tried your code again with my testcase. Still I'm seeing crashes/failures. Do you
have some example testcase how this is supposed to be used?

Quoted 7 lines

Does your test using i915 or xe ?? if i915 then there is no change in the functionality it's the same existing code, because this change is specific to only xe.

Because from this patch
https://patchwork.freedesktop.org/series/116130/ it looks like you are using spinner for i915.

I'm trying to port that test for Xe on top of your changes. I.e. I'm using Xe.

Quoted 85 lines

Thanks,
Gowtham

Quoted 81 lines
Quoted 81 lines
lib/xe/xe_spin.c +5 -0
+       spin->handle = bo;
+       if (opt->engine)
+               spin->engine = opt->engine;
+       else
+               spin->engine = xe_engine_create(fd, spin->vm,

opt-

Quoted 1 line

hwe, 0);

+
+       spin->syncobj = syncobj_create(fd, 0);
+       addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size,
0, ALLOC_STRATEGY_LOW_TO_HIGH);
+       xe_vm_bind_sync(fd, spin->vm, bo, 0, addr, bo_size); +
+       xe_spin_init(xe_spin, addr, true);
+       exec.engine_id = spin->engine;
+       exec.address = addr;
+       sync.handle = spin->syncobj;
+       igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC, &exec), 0);

lib/xe/xe_spin.c +12 -0
+
+       spin->batch = xe_spin->batch;
+       spin->start = xe_spin->start;
+       spin->end = xe_spin->end;
+       spin->bo_size = bo_size;
+       spin->address = addr;
+       return spin;
+
+}
+
+void xe_spin_sync_wait(int fd, struct igt_spin *spin) {
+       igt_assert(syncobj_wait(fd, &spin->syncobj, 1, INT64_MAX,

0,
+                               NULL)); }

lib/xe/xe_spin.c +3 -0
+
+void xe_spin_free(int fd, struct igt_spin *spin) {
+       xe_vm_unbind_sync(fd, spin->vm, 0, spin->address, spin-
Quoted 1 line

bo_size);

+       spin->end = 0;
+       syncobj_destroy(fd, spin->syncobj);
+       xe_engine_destroy(fd, spin->engine);
+       gem_close(fd, spin->handle);

lib/xe/xe_spin.c +2 -0
+}
+

 void xe_cork_init(int fd, struct drm_xe_engine_class_instance *hwe,
                  struct xe_cork *cork)
 {

lib/xe/xe_spin.h index renamed from lib/xe/xe_spin.h +0 -0

73f9a026..48867eb8 100644

lib/xe/xe_spin.h +5 -0
@@ -13,19 +13,26 @@
  #include <stdbool.h>
 
  #include "xe_query.h"
+#include "lib/igt_dummyload.h"
 
  /* Mapped GPU object */
+
  struct xe_spin {
         uint32_t batch[16];
         uint64_t pad;
         uint32_t start;
         uint32_t end;
+
  };
 
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt);

 void xe_spin_init(struct xe_spin *spin, uint64_t addr, bool preempt);
 bool xe_spin_started(struct xe_spin *spin);
+void xe_spin_sync_wait(int fd, struct igt_spin *spin); void xe_spin_wait_started(struct xe_spin *spin); void xe_spin_end(struct xe_spin *spin);
+void xe_spin_free(int fd, struct igt_spin *spin);

 struct xe_cork {
        struct xe_spin *spin;