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

Nirmoy Das nirmoy.das at intel.com
Tue Nov 19 12:15:58 UTC 2024


On 11/18/2024 1:16 PM, Krzysztof Niemiec wrote:
> 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>
Reviewed-by: Nirmoy Das <nirmoy.das 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);


More information about the igt-dev mailing list