Skip to contentSkip to conversation

lib/xe/xe_spin: Integrate igt_spin_new with Xe.

PATCH In review [email protected] 5 participants 9 messages May 5, 2023 – Jul 17, 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 Zbigniew Kempczyński <[email protected]>
---
 lib/igt_dummyload.c | 28 ++++++++++++++------
 lib/igt_dummyload.h |  8 ++++++
 lib/xe/xe_spin.c    | 63 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 98 insertions(+), 8 deletions(-)
lib/igt_dummyload.c +20 -8
index 740a58f3..92507819 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);
 }
 
 /**
@@ -480,8 +484,13 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 		igt_require(!gem_engine_has_cmdparser(fd, &opts->ctx->cfg,
 						      opts->engine));
 	}
-
-	spin = spin_create(fd, opts);
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	} else {
+		spin = spin_create(fd, opts);
+		return spin;
+	}
 
 	if (!(opts->flags & IGT_SPIN_INVALID_CS)) {
 		/*
@@ -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 +8 -0
index b247ab02..7efbb464 100644
@@ -83,6 +83,14 @@ typedef struct igt_spin {
 #define SPIN_CLFLUSH (1 << 0)
 
 	struct igt_spin_factory opts;
+	union {
+		uint64_t pad;
+		uint32_t start;
+		uint32_t end;
+		uint32_t vm;
+		uint32_t syncobj;
+	};
+
 } igt_spin_t;
 
 
lib/xe/xe_spin.c +63 -0

75 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. (rev3)

== Series Details ==

== Series Details ==

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

== Summary ==

CI Bug Log - changes from CI_DRM_13110 -> IGTPW_8916
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

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

Additional (1): fi-kbl-soraka
Missing (1): fi-snb-2520m

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_huc_copy@huc-copy:
- fi-kbl-soraka: NOTRUN -> [SKIP][1] ([fdo#109271] / [i915#2190])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][2] ([fdo#109271] / [i915#4613]) +3 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/fi-kbl-soraka/igt@[email protected]

* igt@i915_selftest@live@gt_pm:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][3] ([i915#1886] / [i915#7913])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

* igt@i915_selftest@live@mman:
- bat-rpls-2: [PASS][4] -> [TIMEOUT][5] ([i915#6794] / [i915#7392])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/bat-rpls-2/igt@i915_selftest@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/bat-rpls-2/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@requests:
- bat-rpls-1: [PASS][6] -> [ABORT][7] ([i915#7911] / [i915#7920] / [i915#7982])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/bat-rpls-1/igt@i915_selftest@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-kbl-soraka: NOTRUN -> [SKIP][8] ([fdo#109271]) +16 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/fi-kbl-soraka/igt@[email protected]

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#6794]: https://gitlab.freedesktop.org/drm/intel/issues/6794
[i915#7392]: https://gitlab.freedesktop.org/drm/intel/issues/7392
[i915#7911]: https://gitlab.freedesktop.org/drm/intel/issues/7911
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#7920]: https://gitlab.freedesktop.org/drm/intel/issues/7920
[i915#7982]: https://gitlab.freedesktop.org/drm/intel/issues/7982

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

* CI: CI-20190529 -> None
* IGT: IGT_7277 -> IGTPW_8916

CI-20190529: 20190529
CI_DRM_13110: 0fc2261e97d6fe498f17bcd9120fed98778ff0d8 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8916: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/index.html
IGT_7277: 1cb3507f3ff28d11bd5cfabcde576fe78ddab571 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

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

#2 lore raw

[igt-dev] ✗ Fi.CI.IGT: failure for lib/xe/xe_spin: Integrate igt_spin_new with Xe. (rev3)

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

== Series Details ==

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

== Summary ==

CI Bug Log - changes from CI_DRM_13110_full -> IGTPW_8916_full
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in IGTPW_8916_full, please notify your bug team 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_8916/index.html

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

No changes in participating hosts

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

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

### IGT changes ###

#### Possible regressions ####

* igt@gem_eio@in-flight-suspend:
- shard-apl: [PASS][1] -> [TIMEOUT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl7/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl4/igt@[email protected]

New tests
---------

New tests have been introduced between CI_DRM_13110_full and IGTPW_8916_full:

### New IGT tests (1) ###

* igt@kms_universal_plane:
- Statuses :
- Exec time: [None] s

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_fair@basic-pace-share@rcs0:
- shard-glk: [PASS][3] -> [FAIL][4] ([i915#2842]) +3 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-glk5/igt@gem_exec_fair@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-glk8/igt@gem_exec_fair@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- shard-glk: NOTRUN -> [SKIP][5] ([fdo#109271] / [i915#4613])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-glk5/igt@[email protected]

* igt@gem_lmem_swapping@verify-random-ccs:
- shard-apl: NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#4613]) +1 similar issue
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl6/igt@[email protected]

* igt@gem_mmap_gtt@fault-concurrent-x:
- shard-snb: [PASS][7] -> [ABORT][8] ([i915#5161]) +1 similar issue
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-snb5/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-snb5/igt@[email protected]

* igt@gem_render_copy@x-tiled-to-vebox-yf-tiled:
- shard-apl: NOTRUN -> [SKIP][9] ([fdo#109271]) +45 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl1/igt@[email protected]

* igt@i915_pm_dc@dc9-dpms:
- shard-apl: [PASS][10] -> [SKIP][11] ([fdo#109271])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl4/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl4/igt@[email protected]

* igt@kms_atomic@plane-primary-overlay-mutable-zpos:
- shard-glk: NOTRUN -> [SKIP][12] ([fdo#109271]) +34 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-glk5/igt@[email protected]

* igt@kms_ccs@pipe-a-random-ccs-data-y_tiled_gen12_rc_ccs_cc:
- shard-apl: NOTRUN -> [SKIP][13] ([fdo#109271] / [i915#3886])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl3/igt@kms_ccs@pipe-a-random-ccs-data-y_tiled_gen12_rc_ccs_cc.html

* igt@kms_ccs@pipe-c-bad-pixel-format-y_tiled_gen12_rc_ccs_cc:
- shard-glk: NOTRUN -> [SKIP][14] ([fdo#109271] / [i915#3886]) +1 similar issue
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-glk3/igt@kms_ccs@pipe-c-bad-pixel-format-y_tiled_gen12_rc_ccs_cc.html

* igt@kms_flip@flip-vs-expired-vblank@b-dp1:
- shard-apl: [PASS][15] -> [FAIL][16] ([i915#79])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl4/igt@kms_flip@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl7/igt@kms_flip@[email protected]

* igt@kms_plane_scaling@planes-downscale-factor-0-25-upscale-0-25@pipe-a-hdmi-a-1:
- shard-snb: NOTRUN -> [SKIP][17] ([fdo#109271]) +85 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-snb1/igt@kms_plane_scaling@[email protected]

* igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area:
- shard-glk: NOTRUN -> [SKIP][18] ([fdo#109271] / [i915#658])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-glk5/igt@[email protected]

#### Possible fixes ####

* igt@drm_fdinfo@idle@rcs0:
- {shard-rkl}: [FAIL][19] ([i915#7742]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-rkl-2/igt@drm_fdinfo@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-rkl-6/igt@drm_fdinfo@[email protected]

* igt@gem_ctx_exec@basic-nohangcheck:
- {shard-rkl}: [FAIL][21] ([i915#6268]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-rkl-4/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-rkl-1/igt@[email protected]

* igt@gem_ctx_freq@sysfs:
- {shard-dg1}: [FAIL][23] ([i915#6786]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-dg1-15/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-dg1-13/igt@[email protected]

* igt@gen9_exec_parse@allowed-all:
- shard-apl: [ABORT][25] ([i915#5566]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl1/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl2/igt@[email protected]

* igt@i915_module_load@reload-no-display:
- shard-snb: [ABORT][27] ([i915#4528] / [i915#8393]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-snb4/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-snb6/igt@[email protected]

* igt@i915_pm_dc@dc6-dpms:
- {shard-tglu}: [FAIL][29] ([i915#3989] / [i915#454]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-tglu-2/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-tglu-9/igt@[email protected]

* igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-hdmi-a:
- {shard-rkl}: [SKIP][31] ([i915#1937]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-rkl-2/igt@i915_pm_lpsp@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-rkl-7/igt@i915_pm_lpsp@[email protected]

* igt@i915_pm_rpm@modeset-non-lpsp-stress:
- {shard-rkl}: [SKIP][33] ([i915#1397]) -> [PASS][34] +2 similar issues
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-rkl-7/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-rkl-6/igt@[email protected]

* igt@i915_pm_rps@waitboost:
- {shard-dg1}: [FAIL][35] ([i915#8229]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-dg1-18/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-dg1-18/igt@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- shard-apl: [DMESG-FAIL][37] ([i915#5334]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl2/igt@i915_selftest@live@gt_heartbeat.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl3/igt@i915_selftest@live@gt_heartbeat.html

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

* igt@kms_cursor_legacy@forked-bo@pipe-b:
- {shard-rkl}: [INCOMPLETE][41] ([i915#8011]) -> [PASS][42]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-rkl-7/igt@kms_cursor_legacy@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-rkl-3/igt@kms_cursor_legacy@[email protected]

* igt@kms_fbcon_fbt@fbc-suspend:
- {shard-tglu}: [FAIL][43] ([i915#4767]) -> [PASS][44]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-tglu-10/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-tglu-9/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank@a-dp1:
- shard-apl: [FAIL][45] ([i915#79]) -> [PASS][46]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl4/igt@kms_flip@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl7/igt@kms_flip@[email protected]

* igt@kms_sysfs_edid_timing:
- shard-apl: [FAIL][47] ([IGT#2]) -> [PASS][48]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13110/shard-apl1/igt@kms_sysfs_edid_timing.html
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/shard-apl3/igt@kms_sysfs_edid_timing.html

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

[IGT#2]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/2
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[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#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
[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#2705]: https://gitlab.freedesktop.org/drm/intel/issues/2705
[i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#3023]: https://gitlab.freedesktop.org/drm/intel/issues/3023
[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#3299]: https://gitlab.freedesktop.org/drm/intel/issues/3299
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3361]: https://gitlab.freedesktop.org/drm/intel/issues/3361
[i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
[i915#3469]: https://gitlab.freedesktop.org/drm/intel/issues/3469
[i915#3591]: https://gitlab.freedesktop.org/drm/intel/issues/3591
[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#3742]: https://gitlab.freedesktop.org/drm/intel/issues/3742
[i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
[i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
[i915#3989]: https://gitlab.freedesktop.org/drm/intel/issues/3989
[i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
[i915#4525]: https://gitlab.freedesktop.org/drm/intel/issues/4525
[i915#4528]: https://gitlab.freedesktop.org/drm/intel/issues/4528
[i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
[i915#454]: https://gitlab.freedesktop.org/drm/intel/issues/454
[i915#4579]: https://gitlab.freedesktop.org/drm/intel/issues/4579
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4767]: https://gitlab.freedesktop.org/drm/intel/issues/4767
[i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
[i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
[i915#5161]: https://gitlab.freedesktop.org/drm/intel/issues/5161
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[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#6301]: https://gitlab.freedesktop.org/drm/intel/issues/6301
[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#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
[i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
[i915#7742]: https://gitlab.freedesktop.org/drm/intel/issues/7742
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
[i915#8011]: https://gitlab.freedesktop.org/drm/intel/issues/8011
[i915#8229]: https://gitlab.freedesktop.org/drm/intel/issues/8229
[i915#8253]: https://gitlab.freedesktop.org/drm/intel/issues/8253
[i915#8381]: https://gitlab.freedesktop.org/drm/intel/issues/8381
[i915#8393]: https://gitlab.freedesktop.org/drm/intel/issues/8393

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

* CI: CI-20190529 -> None
* IGT: IGT_7277 -> IGTPW_8916
* Piglit: piglit_4509 -> None

CI-20190529: 20190529
CI_DRM_13110: 0fc2261e97d6fe498f17bcd9120fed98778ff0d8 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8916: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8916/index.html
IGT_7277: 1cb3507f3ff28d11bd5cfabcde576fe78ddab571 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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

#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Fri, 2023-05-05 at 11:05 +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.

Hello Sai,

Do you have some example testcase demonstrating usage of this Xe spinner? I've been trying to adapt my testcase here to work with Xe and on top of your spinner patch:

https://patchwork.freedesktop.org/series/116130/

Without success. Seeing crash...

BR,

Jouni Högander

Quoted 207 lines
Cc Zbigniew Kempczyński <[email protected]>

---
 lib/igt_dummyload.c | 28 ++++++++++++++------
 lib/igt_dummyload.h |  8 ++++++
 lib/xe/xe_spin.c    | 63
+++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++

 4 files changed, 98 insertions(+), 8 deletions(-)
lib/igt_dummyload.c +1 -0
index 740a58f3..92507819 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
@@ -480,8 +484,13 @@ igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)

                igt_require(!gem_engine_has_cmdparser(fd, &opts->ctx-

Quoted 1 line

cfg,

                                                      opts->engine)); }
-
-       spin = spin_create(fd, opts);
+       if (is_xe_device(fd)) {
+               spin = xe_spin_create(fd, opts);
+               return spin;
+       } else {
+               spin = spin_create(fd, opts);
+               return spin;
+       }

        if (!(opts->flags & IGT_SPIN_INVALID_CS)) {
                /*

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 +0 -0
index b247ab02..7efbb464 100644
@@ -83,6 +83,14 @@ typedef struct igt_spin {
  #define SPIN_CLFLUSH (1 << 0)


        struct igt_spin_factory opts;
+       union {
+               uint64_t pad;
+               uint32_t start;
+               uint32_t end;
+               uint32_t vm;
+               uint32_t syncobj;
+       };
+
 } igt_spin_t;

lib/xe/xe_spin.c +1 -0
index 856d0ba2..b79b5a0c 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,68 @@ void xe_spin_end(struct xe_spin *spin)
         spin->end = 0;
  }

lib/xe/xe_spin.c +33 -0
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt)
+{
+       struct drm_xe_engine_class_instance *eci;
+       size_t bo_size = xe_get_default_alignment(fd);
+       uint32_t vm, bo, engine, syncobj;
+       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);
+
+       bo = xe_bo_create(fd, eci->gt_id, vm, bo_size);
+       spin = xe_bo_map(fd, bo, 0x1000);
+       spin->handle = bo;
+       spin->vm = xe_vm_create(fd, 0, 0);
+       engine = xe_engine_create(fd, vm, eci, 0);
+       spin->syncobj = syncobj_create(fd, 0);
+
+       if (ahnd)
+               addr = intel_allocator_alloc_with_strategy(ahnd, bo,

bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);

lib/xe/xe_spin.c +29 -0
+
+       xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+       xe_spin_init(xe_spin, addr, true);
+       exec.engine_id = engine;
+       exec.address = addr;
+       sync.handle = 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;
+       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)
+{
+       spin->end = 0;
+       xe_vm_destroy(fd, spin->vm);
+       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 +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;

#4 lore raw
Quoted 24 lines

-----Original Message-----
From: Hogander, Jouni <[email protected]>
Sent: Monday, May 8, 2023 5:50 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.

Quoted 6 lines · On Fri, 2023-05-05 at 11:05 +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.

Hello Sai,

Do you have some example testcase demonstrating usage of this Xe spinner? I've been trying to adapt my testcase here to work with Xe and on top of your spinner patch:

Quoted 7 lines

https://patchwork.freedesktop.org/series/116130/

Without success. Seeing crash...

BR,

Jouni Högander

Hi Jouni Högander,

It need few fixes Will be sending a new patch series in sometime, you can use that.

Thanks,
Sai Gowtham

Quoted 203 lines
Quoted 203 lines
Cc Zbigniew Kempczyński <[email protected]>

---
 lib/igt_dummyload.c | 28 ++++++++++++++------
 lib/igt_dummyload.h |  8 ++++++
 lib/xe/xe_spin.c    | 63
+++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++

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

740a58f3..92507819 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 +0 -0
@@ -480,8 +484,13 @@ igt_spin_factory(int fd, const struct
 igt_spin_factory *opts)

                igt_require(!gem_engine_has_cmdparser(fd, &opts->ctx-

Quoted 1 line

cfg,

                                                      opts->engine)); }
-
-       spin = spin_create(fd, opts);
+       if (is_xe_device(fd)) {
+               spin = xe_spin_create(fd, opts);
+               return spin;
+       } else {
+               spin = spin_create(fd, opts);
+               return spin;
+       }

        if (!(opts->flags & IGT_SPIN_INVALID_CS)) { /*

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..7efbb464 100644

lib/igt_dummyload.h +8 -0
@@ -83,6 +83,14 @@ typedef struct igt_spin {
  #define SPIN_CLFLUSH (1 << 0)
 
         struct igt_spin_factory opts;
+       union {
+               uint64_t pad;
+               uint32_t start;
+               uint32_t end;
+               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..b79b5a0c 100644

lib/xe/xe_spin.c +59 -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,68 @@ 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) {
+       struct drm_xe_engine_class_instance *eci;
+       size_t bo_size = xe_get_default_alignment(fd);
+       uint32_t vm, bo, engine, syncobj;
+       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);
+
+       bo = xe_bo_create(fd, eci->gt_id, vm, bo_size);
+       spin = xe_bo_map(fd, bo, 0x1000);
+       spin->handle = bo;
+       spin->vm = xe_vm_create(fd, 0, 0);
+       engine = xe_engine_create(fd, vm, eci, 0);
+       spin->syncobj = syncobj_create(fd, 0);
+
+       if (ahnd)
+               addr = intel_allocator_alloc_with_strategy(ahnd, bo,
 bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+
+       xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+       xe_spin_init(xe_spin, addr, true);
+       exec.engine_id = engine;
+       exec.address = addr;
+       sync.handle = 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;
+       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) {
+       spin->end = 0;
+       xe_vm_destroy(fd, spin->vm);
+       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;
#5 lore raw
In reply to [email protected]
Quoted 81 lines · On Fri, May 05, 2023 at 11:05:28AM +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 Zbigniew Kempczyński <[email protected]>
---
 lib/igt_dummyload.c | 28 ++++++++++++++------
 lib/igt_dummyload.h |  8 ++++++
 lib/xe/xe_spin.c    | 63 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 98 insertions(+), 8 deletions(-)
lib/igt_dummyload.c +20 -8
index 740a58f3..92507819 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);
 }
 
 /**
@@ -480,8 +484,13 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 		igt_require(!gem_engine_has_cmdparser(fd, &opts->ctx->cfg,
 						      opts->engine));
 	}
-
-	spin = spin_create(fd, opts);
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	} else {
+		spin = spin_create(fd, opts);
+		return spin;
+	}
 
 	if (!(opts->flags & IGT_SPIN_INVALID_CS)) {
 		/*
@@ -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 +0 -0
index b247ab02..7efbb464 100644
@@ -83,6 +83,14 @@ typedef struct igt_spin {
 #define SPIN_CLFLUSH (1 << 0)

lib/igt_dummyload.h typedef struct igt_spin { · line 93

Quoted 10 lines
lib/igt_dummyload.h +8 -0
 
 	struct igt_spin_factory opts;
+	union {
+		uint64_t pad;
+		uint32_t start;
+		uint32_t end;
+		uint32_t vm;
+		uint32_t syncobj;
+	};
+

Union? Marker guaranteed.

Quoted 68 lines
lib/igt_dummyload.h +0 -0
 } igt_spin_t;
 
 
lib/xe/xe_spin.c +50 -0
index 856d0ba2..b79b5a0c 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,68 @@ 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)
+{
+	struct drm_xe_engine_class_instance *eci;
+	size_t bo_size = xe_get_default_alignment(fd);
+	uint32_t vm, bo, engine, syncobj;
+	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);
+
+	bo = xe_bo_create(fd, eci->gt_id, vm, bo_size);
+	spin = xe_bo_map(fd, bo, 0x1000);
+	spin->handle = bo;
+	spin->vm = xe_vm_create(fd, 0, 0);
+	engine = xe_engine_create(fd, vm, eci, 0);
+	spin->syncobj = syncobj_create(fd, 0);
+
+	if (ahnd)
+		addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+
+	xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+	xe_spin_init(xe_spin, addr, true);
+	exec.engine_id = engine;
+	exec.address = addr;
+	sync.handle = 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;
+	return spin;
+
+}
+

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

Quoted 10 lines
lib/xe/xe_spin.c +10 -0
+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)
+{
+	spin->end = 0;
+	xe_vm_destroy(fd, spin->vm);

I see no usecase working right now but spin->end without synchronous unbinding before will likely produce gpu hang.

--
Zbigniew

Quoted 40 lines
lib/xe/xe_spin.c +3 -0
+	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
#6 lore raw
In reply to [email protected]

On Fri, May 05, 2023 at 11:05:28AM +0530, [email protected] wrote:
<cut>

Quoted 23 lines
lib/xe/xe_spin.c +23 -0
+igt_spin_t *
+xe_spin_create(int fd, const struct igt_spin_factory *opt)
+{
+	struct drm_xe_engine_class_instance *eci;
+	size_t bo_size = xe_get_default_alignment(fd);
+	uint32_t vm, bo, engine, syncobj;
+	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);

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, eci->gt_id, vm, bo_size);
+	spin = xe_bo_map(fd, bo, 0x1000);
+	spin->handle = bo;
+	spin->vm = xe_vm_create(fd, 0, 0);
+	engine = xe_engine_create(fd, vm, eci, 0);
+	spin->syncobj = syncobj_create(fd, 0);
+
+	if (ahnd)
+		addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);

if not necessary as you've assert on the beginning.

That's all I've noticed without testcode.

--
Zbigniew

Quoted 15 lines
lib/xe/xe_spin.c +15 -0
+
+	xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+	xe_spin_init(xe_spin, addr, true);
+	exec.engine_id = engine;
+	exec.address = addr;
+	sync.handle = 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;
+	return spin;
+
+}
#7 lore raw
In reply to [email protected]
Quoted 8 lines · On Fri, May 05, 2023 at 11:05:28AM +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 Zbigniew Kempczyński <[email protected]>

Who asked for this? I intentionally didn't use the existing IGT spin stuff in Xe as that code is a mess.

Matt

Quoted 201 lines
---
 lib/igt_dummyload.c | 28 ++++++++++++++------
 lib/igt_dummyload.h |  8 ++++++
 lib/xe/xe_spin.c    | 63 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 98 insertions(+), 8 deletions(-)
lib/igt_dummyload.c +20 -8
index 740a58f3..92507819 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);
 }
 
 /**
@@ -480,8 +484,13 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 		igt_require(!gem_engine_has_cmdparser(fd, &opts->ctx->cfg,
 						      opts->engine));
 	}
-
-	spin = spin_create(fd, opts);
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	} else {
+		spin = spin_create(fd, opts);
+		return spin;
+	}
 
 	if (!(opts->flags & IGT_SPIN_INVALID_CS)) {
 		/*
@@ -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 +8 -0
index b247ab02..7efbb464 100644
@@ -83,6 +83,14 @@ typedef struct igt_spin {
 #define SPIN_CLFLUSH (1 << 0)
 
 	struct igt_spin_factory opts;
+	union {
+		uint64_t pad;
+		uint32_t start;
+		uint32_t end;
+		uint32_t vm;
+		uint32_t syncobj;
+	};
+
 } igt_spin_t;
 
 
lib/xe/xe_spin.c +63 -0
index 856d0ba2..b79b5a0c 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,68 @@ 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)
+{
+	struct drm_xe_engine_class_instance *eci;
+	size_t bo_size = xe_get_default_alignment(fd);
+	uint32_t vm, bo, engine, syncobj;
+	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);
+
+	bo = xe_bo_create(fd, eci->gt_id, vm, bo_size);
+	spin = xe_bo_map(fd, bo, 0x1000);
+	spin->handle = bo;
+	spin->vm = xe_vm_create(fd, 0, 0);
+	engine = xe_engine_create(fd, vm, eci, 0);
+	spin->syncobj = syncobj_create(fd, 0);
+
+	if (ahnd)
+		addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+
+	xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+	xe_spin_init(xe_spin, addr, true);
+	exec.engine_id = engine;
+	exec.address = addr;
+	sync.handle = 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;
+	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)
+{
+	spin->end = 0;
+	xe_vm_destroy(fd, spin->vm);
+	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
#8 lore raw
Quoted 7 lines · Matthew Brost
Quoted 6 lines · On Fri, May 05, 2023 at 11:05:28AM +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.

Quoted 6 lines
Quoted 2 lines
Cc Zbigniew Kempczyński <[email protected]>

Who asked for this? I intentionally didn't use the existing IGT spin stuff in Xe as that code is a mess.

Some IGT KMS tests are written around igt_spin_factory. We try to avoid code duplication providing wrappers to mechanisms.

And I don't think wrapper to two separately implemented spinners is a mess. May you elaborate what's wrong with this?

--
Zbigniew

Quoted 204 lines

Matt

Quoted 201 lines
---
 lib/igt_dummyload.c | 28 ++++++++++++++------
 lib/igt_dummyload.h |  8 ++++++
 lib/xe/xe_spin.c    | 63 +++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_spin.h    |  7 +++++
 4 files changed, 98 insertions(+), 8 deletions(-)
lib/igt_dummyload.c +20 -8
index 740a58f3..92507819 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);
 }
 
 /**
@@ -480,8 +484,13 @@ igt_spin_factory(int fd, const struct igt_spin_factory *opts)
 		igt_require(!gem_engine_has_cmdparser(fd, &opts->ctx->cfg,
 						      opts->engine));
 	}
-
-	spin = spin_create(fd, opts);
+	if (is_xe_device(fd)) {
+		spin = xe_spin_create(fd, opts);
+		return spin;
+	} else {
+		spin = spin_create(fd, opts);
+		return spin;
+	}
 
 	if (!(opts->flags & IGT_SPIN_INVALID_CS)) {
 		/*
@@ -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 +8 -0
index b247ab02..7efbb464 100644
@@ -83,6 +83,14 @@ typedef struct igt_spin {
 #define SPIN_CLFLUSH (1 << 0)
 
 	struct igt_spin_factory opts;
+	union {
+		uint64_t pad;
+		uint32_t start;
+		uint32_t end;
+		uint32_t vm;
+		uint32_t syncobj;
+	};
+
 } igt_spin_t;
 
 
lib/xe/xe_spin.c +63 -0
index 856d0ba2..b79b5a0c 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,68 @@ 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)
+{
+	struct drm_xe_engine_class_instance *eci;
+	size_t bo_size = xe_get_default_alignment(fd);
+	uint32_t vm, bo, engine, syncobj;
+	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);
+
+	bo = xe_bo_create(fd, eci->gt_id, vm, bo_size);
+	spin = xe_bo_map(fd, bo, 0x1000);
+	spin->handle = bo;
+	spin->vm = xe_vm_create(fd, 0, 0);
+	engine = xe_engine_create(fd, vm, eci, 0);
+	spin->syncobj = syncobj_create(fd, 0);
+
+	if (ahnd)
+		addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0, ALLOC_STRATEGY_LOW_TO_HIGH);
+
+	xe_vm_bind_sync(fd, vm, bo, 0, addr, bo_size);
+
+	xe_spin_init(xe_spin, addr, true);
+	exec.engine_id = engine;
+	exec.address = addr;
+	sync.handle = 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;
+	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)
+{
+	spin->end = 0;
+	xe_vm_destroy(fd, spin->vm);
+	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