[Intel-gfx] [PATCH] drm/i915: Reduce nested prepare_remote_context() to a trylock

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Nov 26 12:15:58 UTC 2019


On 26/11/2019 06:55, Chris Wilson wrote:
> On context retiring, we may invoke the kernel_context to unpin this
> context. Elsewhere, we may use the kernel_context to modify this
> context. This currently leads to an AB-BA lock inversion, so we need to
> back-off from the contended lock, and repeat.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111732
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/gt/intel_context.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
> index ee9d2bcd2c13..4fcb98f96da6 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.c
> +++ b/drivers/gpu/drm/i915/gt/intel_context.c
> @@ -310,10 +310,8 @@ int intel_context_prepare_remote_request(struct intel_context *ce,
>   	GEM_BUG_ON(rq->hw_context == ce);
>   
>   	if (rcu_access_pointer(rq->timeline) != tl) { /* timeline sharing! */
> -		err = mutex_lock_interruptible_nested(&tl->mutex,
> -						      SINGLE_DEPTH_NESTING);
> -		if (err)
> -			return err;
> +		if (!mutex_trylock(&tl->mutex))
> +			return -EAGAIN;
>   
>   		/* Queue this switch after current activity by this context. */
>   		err = i915_active_fence_set(&tl->last_request, rq);
> 

Please just drop a short comment above the trylock since with git blame 
it is often very hard to find the commit.

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

Regards,

Tvrtko


More information about the Intel-gfx mailing list