[Intel-gfx] [PATCH 15/16] drm/i915: Add a simple fence selftest to i915_gem_request

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Fri Dec 9 16:02:49 UTC 2016


On 07/12/2016 13:58, Chris Wilson wrote:
> Do a quick selftest on in the interoperability of dma_fence_wait on a
> i915_gem_request.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem_request.c | 51 +++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
> index 9ba17d3e35cb..2bde3fc8e8bf 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.c
> +++ b/drivers/gpu/drm/i915/i915_gem_request.c
> @@ -1648,11 +1648,62 @@ static int igt_wait_request(void *ignore)
>  	return err;
>  }
>
> +static int igt_fence_wait(void *ignore)
> +{
> +	struct drm_i915_private *i915;
> +	struct drm_i915_gem_request *request;
> +	int err = -ENOMEM;
> +
> +	i915 = mock_device();
> +	if (!i915)
> +		goto out;
> +
> +	err = -EINVAL;
> +	mutex_lock(&i915->drm.struct_mutex);
> +	request = mock_request(i915->engine[RCS],
> +			       i915->kernel_context,
> +			       HZ);

Even slower than the previous one. :)

> +	if (!request) {
> +		mutex_unlock(&i915->drm.struct_mutex);
> +		goto out_device;
> +	}
> +
> +	i915_add_request(request);
> +	mutex_unlock(&i915->drm.struct_mutex);
> +
> +	if (dma_fence_is_signaled(&request->fence)) {
> +		pr_err("fence signaled immediately!\n");
> +		goto out_device;
> +	}
> +
> +	if (dma_fence_wait_timeout(&request->fence, false, 1) != -ETIME) {
> +		pr_err("fence wait success after submit (expected timeout)!\n");
> +		goto out_device;
> +	}
> +
> +	if (dma_fence_wait_timeout(&request->fence, false, 2 * HZ) <= 0) {
> +		pr_err("fence wait timed out (expected success)!\n");
> +		goto out_device;
> +	}
> +
> +	if (!dma_fence_is_signaled(&request->fence)) {
> +		pr_err("fence unsignaled after waiting!\n");
> +		goto out_device;
> +	}

And the error codes.

> +
> +	err = 0;
> +out_device:
> +	mock_device_free(i915);
> +out:
> +	return err;
> +}
> +
>  int i915_gem_request_selftest(void)
>  {
>  	static const struct i915_subtest tests[] = {
>  		SUBTEST(igt_add_request),
>  		SUBTEST(igt_wait_request),
> +		SUBTEST(igt_fence_wait),
>  	};
>
>  	return i915_subtests(tests, NULL);
>

See if you can speed it up, but that is optional.

Just some better failure codes from the test and then:

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Regards,

Tvrtko




More information about the Intel-gfx mailing list