[PATCH i-g-t v2] tests/intel/gem_ctx_persistence: Wait for context termination

Krzysztof Niemiec krzysztof.niemiec at intel.com
Mon Nov 18 12:16:58 UTC 2024


In some of the subtests, there is a race condition - if a non-persistent
context is not terminated by the driver before the associated spinner is
ended and probed for status, the status will be incorrectly reported as
completed.

Add a sleep instruction before the assert to give the kernel time to
clean up.

v2:
 - Update the patch description,
 - Change the previous expression to a simpler usleep(),
 - Add a usleep() call in test_saturated_hostile_all(), as this behavior
   is also shown in this subtest.

Signed-off-by: Krzysztof Niemiec <krzysztof.niemiec at intel.com>
---
 tests/intel/gem_ctx_persistence.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/intel/gem_ctx_persistence.c b/tests/intel/gem_ctx_persistence.c
index 974444cf1..d90b78267 100644
--- a/tests/intel/gem_ctx_persistence.c
+++ b/tests/intel/gem_ctx_persistence.c
@@ -1029,6 +1029,9 @@ test_saturated_hostile_all(int i915, const intel_ctx_t *base_ctx,
 	igt_spin_busywait_until_started(spin);
 	intel_ctx_destroy(i915, ctx);
 
+	/* Give the kernel some time to terminate the context */
+	usleep(reset_timeout_ms * 1000);
+
 	/* Hostile request requires a GPU reset to terminate */
 	igt_assert_eq(wait_for_status(spin->out_fence, reset_timeout_ms), -EIO);
 
@@ -1173,6 +1176,9 @@ static void __smoker(int i915, const intel_ctx_cfg_t *cfg,
 	drm_close_driver(fd);
 	flush_delayed_fput(i915);
 
+	/* Give the kernel some time to terminate the context */
+	usleep(reset_timeout_ms * 1000);
+
 	igt_spin_end(spin);
 
 	igt_assert_eq(wait_for_status(spin->out_fence, timeout), expected);
-- 
2.45.2



More information about the igt-dev mailing list