[PATCH] drm/i915/gt: Handle errors for i915_gem_object_trylock

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Wed Mar 2 10:37:18 UTC 2022


+ Thomas, Matt

On 02/03/2022 06:19, Jiasheng Jiang wrote:
> As the potential failure of the i915_gem_object_trylock(),
> it should be better to check it and return error if fails.
> 
> Fixes: 94ce0d65076c ("drm/i915/gt: Setup a default migration context on the GT")
> Signed-off-by: Jiasheng Jiang <jiasheng at iscas.ac.cn>
> ---
>   drivers/gpu/drm/i915/gt/selftest_migrate.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/selftest_migrate.c b/drivers/gpu/drm/i915/gt/selftest_migrate.c
> index fa4293d2944f..79c6c68f7316 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_migrate.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_migrate.c
> @@ -465,7 +465,11 @@ create_init_lmem_internal(struct intel_gt *gt, size_t sz, bool try_lmem)
>   			return obj;
>   	}
>   
> -	i915_gem_object_trylock(obj, NULL);

Guys why is this a trylock to start with? (Since being added in 
94ce0d65076c ("drm/i915/gt: Setup a default migration context on the GT").

Surely it can't ever fail since the object has just been created.

Regards,

Tvrtko

> +	if (!i915_gem_object_trylock(obj, NULL)) {
> +		i915_gem_object_put(obj);
> +		return ERR_PTR(-EBUSY);
> +	}
> +
>   	err = i915_gem_object_pin_pages(obj);
>   	if (err) {
>   		i915_gem_object_unlock(obj);


More information about the dri-devel mailing list