Skip to contentSkip to conversation

tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE

PATCH Superseded Erik Kurzinger 3 participants 4 messages Jan 12, 2024 – Jan 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE

The syncobj_timeline test suite includes cases where drmSyncobjTimelineWait is called with the WAIT_FOR_SUBMIT flag before the timeline point has been submitted. Then, after a short delay, the timeline point does get submitted and signaled and the test verifies that the drmSyncobjTimelineWait call is unblocked as expected.

Alas, while this was working correctly with the WAIT_FOR_SUBMIT flag, if the WAIT_AVAILABLE flag is used instead the wait will *always* block for the full timeout duration even if the timeline point is submitted earlier due to a bug in the kernel. The return value would still indicate that the wait completed successfully, though. That is, it wouldn't return -ETIME.

To ensure test coverage for such a scenario, this change adds delayed submission test cases which use the WAIT_AVAILABLE flag. These will be similar to the WAIT_FOR_SUBMIT cases mentioned above except that, after the delay, the timeline point will only submitted, not signaled.

Furthermore, it adds an assertion that the drmSyncobjTimelineWait call returned *before* the timeout expired, which it always should since the timeout is a full 100ms longer than the delay.

v1 -> v2: added documentation for new test cases

---
 tests/syncobj_timeline.c | 46 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)
tests/syncobj_timeline.c +42 -4
index ea8341a30..25ccd6889 100644
@@ -394,6 +394,9 @@
  * SUBTEST: wait-all-for-submit-delayed-submit
  * Description: Verifies wait behavior on a timeline syncobj with a delayed signal from a different thread
  *
+ * SUBTEST: wait-all-available-delayed-submit
+ * Description: Verifies wait behavior on a timeline syncobj with a delayed submit from a different thread
+ *
  * SUBTEST: wait-all-for-submit-snapshot
  * Description: Verifies waiting on a list of timeline syncobjs with different thread for wait/signal
  *
@@ -425,6 +428,9 @@
  * SUBTEST: wait-for-submit-delayed-submit
  * Description: Verifies wait behavior on a timeline syncobj with a delayed signal from a different thread
  *
+ * SUBTEST: wait-available-delayed-submit
+ * Description: Verifies wait behavior on a timeline syncobj with a delayed submit from a different thread
+ *
  * SUBTEST: wait-for-submit-snapshot
  * Description: Verifies waiting on a list of timeline syncobjs with different thread for wait/signal
  */
@@ -490,6 +496,13 @@ syncobj_trigger(int fd, uint32_t handle, uint64_t point)
 	close(timeline);
 }
 
+static void
+syncobj_submit(int fd, uint32_t handle, uint64_t point)
+{
+	int timeline = syncobj_attach_sw_sync(fd, handle, point);
+	close(timeline);
+}
+
 static timer_t
 set_timer(void (*cb)(union sigval), void *ptr, int i, uint64_t nsec)
 {
@@ -534,8 +547,17 @@ syncobj_trigger_free_pair_func(union sigval sigval)
 	free(pair);
 }
 
+static void
+syncobj_submit_free_pair_func(union sigval sigval)
+{
+	struct fd_handle_pair *pair = sigval.sival_ptr;
+	syncobj_submit(pair->fd, pair->handle, pair->point);
+	free(pair);
+}
+
 static timer_t
-syncobj_trigger_delayed(int fd, uint32_t syncobj, uint64_t point, uint64_t nsec)
+syncobj_delayed_operation(int fd, uint32_t syncobj, uint64_t point, uint64_t nsec,
+			  void (*operation)(union sigval))
 {
 	struct fd_handle_pair *pair = malloc(sizeof(*pair));
 
@@ -543,7 +565,7 @@ syncobj_trigger_delayed(int fd, uint32_t syncobj, uint64_t point, uint64_t nsec)
 	pair->handle = syncobj;
 	pair->point = point;
 
-	return set_timer(syncobj_trigger_free_pair_func, pair, 0, nsec);
+	return set_timer(operation, pair, 0, nsec);
 }
 
 static const char *test_wait_bad_flags_desc =
@@ -942,18 +964,26 @@ test_wait_delayed_signal(int fd, uint32_t test_flags)
 	uint64_t point = 1;
 	int timeline = -1;
 	timer_t timer;
+	uint64_t start_time;
 
 	if (test_flags & WAIT_FOR_SUBMIT) {
-		timer = syncobj_trigger_delayed(fd, syncobj, point, SHORT_TIME_NSEC);
+		timer = syncobj_delayed_operation(fd, syncobj, point, SHORT_TIME_NSEC,
+						  syncobj_trigger_free_pair_func);
+	} else if (test_flags & WAIT_AVAILABLE) {
+		timer = syncobj_delayed_operation(fd, syncobj, point, SHORT_TIME_NSEC,
+						  syncobj_submit_free_pair_func);
 	} else {
 		timeline = syncobj_attach_sw_sync(fd, syncobj, point);
 		timer = set_timer(timeline_inc_func, NULL,
 				  timeline, SHORT_TIME_NSEC);
 	}
 
+	start_time = gettime_ns();
 	igt_assert(syncobj_timeline_wait(fd, &syncobj, &point, 1,
-				gettime_ns() + SHORT_TIME_NSEC * 2,
+				start_time + SHORT_TIME_NSEC * 2,
 				flags, NULL));
+	/* ensure we were unblocked before the timeout expired */
+	igt_assert(gettime_ns() - start_time < SHORT_TIME_NSEC * 2);
 
 	timer_delete(timer);
 
@@ -1809,6 +1839,10 @@ igt_main
 	igt_subtest("wait-for-submit-delayed-submit")
 		test_wait_delayed_signal(fd, WAIT_FOR_SUBMIT);
 
+	igt_describe(test_wait_delayed_signal_desc);
+	igt_subtest("wait-available-delayed-submit")
+		test_wait_delayed_signal(fd, WAIT_AVAILABLE);
+
 	igt_describe(test_wait_delayed_signal_desc);
 	igt_subtest("wait-all-delayed-signal")
 		test_wait_delayed_signal(fd, WAIT_ALL);
@@ -1817,6 +1851,10 @@ igt_main
 	igt_subtest("wait-all-for-submit-delayed-submit")
 		test_wait_delayed_signal(fd, WAIT_ALL | WAIT_FOR_SUBMIT);
 
+	igt_describe(test_wait_delayed_signal_desc);
+	igt_subtest("wait-all-available-delayed-submit")
+		test_wait_delayed_signal(fd, WAIT_ALL | WAIT_AVAILABLE);
+
 	igt_describe(test_reset_unsignaled_desc);
 	igt_subtest("reset-unsignaled")
 		test_reset_unsignaled(fd);
Signature · 1 line
2.43.0
#1 lore raw

✓ CI.xeBAT: success for tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE (rev2)

== Series Details ==

== Series Details ==

Series: tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE (rev2)
URL : https://patchwork.freedesktop.org/series/128742/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7673_BAT -> XEIGTPW_10529_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

No changes in participating hosts

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

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

### IGT changes ###

#### Possible fixes ####

* igt@kms_frontbuffer_tracking@basic:
- bat-adlp-7: [DMESG-FAIL][1] ([Intel XE#1033]) -> [PASS][2]
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7673/bat-adlp-7/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10529/bat-adlp-7/igt@[email protected]

* igt@xe_exec_threads@threads-mixed-fd-basic:
- bat-dg2-oem2: [TIMEOUT][3] -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7673/bat-dg2-oem2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10529/bat-dg2-oem2/igt@[email protected]

[Intel XE#1033]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/1033

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

* IGT: IGT_7673 -> IGTPW_10529

IGTPW_10529: 10529
IGT_7673: 7673
xe-627-d1296191ba3a2fb8300d9887bd56b8613c1bc18d: d1296191ba3a2fb8300d9887bd56b8613c1bc18d

== Logs ==

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

#2 lore raw

✗ Fi.CI.BAT: failure for tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE (rev2)

In reply to Erik Kurzinger
== Series Details ==

== Series Details ==

Series: tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE (rev2)
URL : https://patchwork.freedesktop.org/series/128742/
State : failure

== Summary ==

CI Bug Log - changes from IGT_7673 -> IGTPW_10529
====================================================

Summary
-------

**FAILURE**

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

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

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

Participating hosts (38 -> 36)
------------------------------

Missing (2): fi-snb-2520m fi-pnv-d510

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

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

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_suspend@basic-s0@smem:
- fi-skl-6600u: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_7673/fi-skl-6600u/igt@gem_exec_suspend@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10529/fi-skl-6600u/igt@gem_exec_suspend@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

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

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

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271

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

* CI: CI-20190529 -> None
* IGT: IGT_7673 -> IGTPW_10529

CI-20190529: 20190529
CI_DRM_14119: 41678c40fc3eab0b328130d434818299c166b1de @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_10529: 10529
IGT_7673: 7673

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

+igt@syncobj_timeline@wait-all-available-delayed-submit +igt@syncobj_timeline@wait-available-delayed-submit

== Logs ==

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

#3 lore raw
In reply to Erik Kurzinger

Hi Erik,
On 2024-01-12 at 14:31:58 -0800, Erik Kurzinger wrote:

please drop from commit message const names you added, add also i-g-t after PATCH, so instead of:

[PATCH v2] tests/syncobj_timeline: test delayed submission with, WAIT_AVAILABLE

this would be:

[PATCH i-g-t v2] tests/syncobj_timeline: test delayed submission

Quoted 18 lines

The syncobj_timeline test suite includes cases where drmSyncobjTimelineWait is called with the WAIT_FOR_SUBMIT flag before the timeline point has been submitted. Then, after a short delay, the timeline point does get submitted and signaled and the test verifies that the drmSyncobjTimelineWait call is unblocked as expected.

Alas, while this was working correctly with the WAIT_FOR_SUBMIT flag, if the WAIT_AVAILABLE flag is used instead the wait will *always* block for the full timeout duration even if the timeline point is submitted earlier due to a bug in the kernel. The return value would still indicate that the wait completed successfully, though. That is, it wouldn't return -ETIME.

To ensure test coverage for such a scenario, this change adds delayed submission test cases which use the WAIT_AVAILABLE flag. These will be similar to the WAIT_FOR_SUBMIT cases mentioned above except that, after the delay, the timeline point will only submitted, not signaled.

Quoted 7 lines

Furthermore, it adds an assertion that the drmSyncobjTimelineWait call returned *before* the timeout expired, which it always should since the timeout is a full 100ms longer than the delay.

v1 -> v2: added documentation for new test cases

Overall it looks good but I didn't test it.
Allow me few more days for reading and review,

Regards,
Kamil

Quoted 125 lines
---
 tests/syncobj_timeline.c | 46 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)
tests/syncobj_timeline.c +42 -4
index ea8341a30..25ccd6889 100644
@@ -394,6 +394,9 @@
  * SUBTEST: wait-all-for-submit-delayed-submit
  * Description: Verifies wait behavior on a timeline syncobj with a delayed signal from a different thread
  *
+ * SUBTEST: wait-all-available-delayed-submit
+ * Description: Verifies wait behavior on a timeline syncobj with a delayed submit from a different thread
+ *
  * SUBTEST: wait-all-for-submit-snapshot
  * Description: Verifies waiting on a list of timeline syncobjs with different thread for wait/signal
  *
@@ -425,6 +428,9 @@
  * SUBTEST: wait-for-submit-delayed-submit
  * Description: Verifies wait behavior on a timeline syncobj with a delayed signal from a different thread
  *
+ * SUBTEST: wait-available-delayed-submit
+ * Description: Verifies wait behavior on a timeline syncobj with a delayed submit from a different thread
+ *
  * SUBTEST: wait-for-submit-snapshot
  * Description: Verifies waiting on a list of timeline syncobjs with different thread for wait/signal
  */
@@ -490,6 +496,13 @@ syncobj_trigger(int fd, uint32_t handle, uint64_t point)
 	close(timeline);
 }
 
+static void
+syncobj_submit(int fd, uint32_t handle, uint64_t point)
+{
+	int timeline = syncobj_attach_sw_sync(fd, handle, point);
+	close(timeline);
+}
+
 static timer_t
 set_timer(void (*cb)(union sigval), void *ptr, int i, uint64_t nsec)
 {
@@ -534,8 +547,17 @@ syncobj_trigger_free_pair_func(union sigval sigval)
 	free(pair);
 }
 
+static void
+syncobj_submit_free_pair_func(union sigval sigval)
+{
+	struct fd_handle_pair *pair = sigval.sival_ptr;
+	syncobj_submit(pair->fd, pair->handle, pair->point);
+	free(pair);
+}
+
 static timer_t
-syncobj_trigger_delayed(int fd, uint32_t syncobj, uint64_t point, uint64_t nsec)
+syncobj_delayed_operation(int fd, uint32_t syncobj, uint64_t point, uint64_t nsec,
+			  void (*operation)(union sigval))
 {
 	struct fd_handle_pair *pair = malloc(sizeof(*pair));
 
@@ -543,7 +565,7 @@ syncobj_trigger_delayed(int fd, uint32_t syncobj, uint64_t point, uint64_t nsec)
 	pair->handle = syncobj;
 	pair->point = point;
 
-	return set_timer(syncobj_trigger_free_pair_func, pair, 0, nsec);
+	return set_timer(operation, pair, 0, nsec);
 }
 
 static const char *test_wait_bad_flags_desc =
@@ -942,18 +964,26 @@ test_wait_delayed_signal(int fd, uint32_t test_flags)
 	uint64_t point = 1;
 	int timeline = -1;
 	timer_t timer;
+	uint64_t start_time;
 
 	if (test_flags & WAIT_FOR_SUBMIT) {
-		timer = syncobj_trigger_delayed(fd, syncobj, point, SHORT_TIME_NSEC);
+		timer = syncobj_delayed_operation(fd, syncobj, point, SHORT_TIME_NSEC,
+						  syncobj_trigger_free_pair_func);
+	} else if (test_flags & WAIT_AVAILABLE) {
+		timer = syncobj_delayed_operation(fd, syncobj, point, SHORT_TIME_NSEC,
+						  syncobj_submit_free_pair_func);
 	} else {
 		timeline = syncobj_attach_sw_sync(fd, syncobj, point);
 		timer = set_timer(timeline_inc_func, NULL,
 				  timeline, SHORT_TIME_NSEC);
 	}
 
+	start_time = gettime_ns();
 	igt_assert(syncobj_timeline_wait(fd, &syncobj, &point, 1,
-				gettime_ns() + SHORT_TIME_NSEC * 2,
+				start_time + SHORT_TIME_NSEC * 2,
 				flags, NULL));
+	/* ensure we were unblocked before the timeout expired */
+	igt_assert(gettime_ns() - start_time < SHORT_TIME_NSEC * 2);
 
 	timer_delete(timer);
 
@@ -1809,6 +1839,10 @@ igt_main
 	igt_subtest("wait-for-submit-delayed-submit")
 		test_wait_delayed_signal(fd, WAIT_FOR_SUBMIT);
 
+	igt_describe(test_wait_delayed_signal_desc);
+	igt_subtest("wait-available-delayed-submit")
+		test_wait_delayed_signal(fd, WAIT_AVAILABLE);
+
 	igt_describe(test_wait_delayed_signal_desc);
 	igt_subtest("wait-all-delayed-signal")
 		test_wait_delayed_signal(fd, WAIT_ALL);
@@ -1817,6 +1851,10 @@ igt_main
 	igt_subtest("wait-all-for-submit-delayed-submit")
 		test_wait_delayed_signal(fd, WAIT_ALL | WAIT_FOR_SUBMIT);
 
+	igt_describe(test_wait_delayed_signal_desc);
+	igt_subtest("wait-all-available-delayed-submit")
+		test_wait_delayed_signal(fd, WAIT_ALL | WAIT_AVAILABLE);
+
 	igt_describe(test_reset_unsignaled_desc);
 	igt_subtest("reset-unsignaled")
 		test_reset_unsignaled(fd);
Signature · 1 line
2.43.0