[Intel-gfx] [PATCH] drm/i915/gt: Close race between cacheline_retire and free

Mika Kuoppala mika.kuoppala at linux.intel.com
Fri Mar 6 16:19:55 UTC 2020


Chris Wilson <chris at chris-wilson.co.uk> writes:

> If the cacheline may still be busy, atomically mark it for future
> release, and only if we can determine that it will never be used again,
> immediately free it.
>
> Closes: https://gitlab.freedesktop.org/drm/intel/issues/1392
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> Cc: Matthew Auld <matthew.auld at intel.com>

Reviewed-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>

> ---
>  drivers/gpu/drm/i915/gt/intel_timeline.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_timeline.c b/drivers/gpu/drm/i915/gt/intel_timeline.c
> index 54e1e55f3c81..91debbc97c9a 100644
> --- a/drivers/gpu/drm/i915/gt/intel_timeline.c
> +++ b/drivers/gpu/drm/i915/gt/intel_timeline.c
> @@ -192,11 +192,15 @@ static void cacheline_release(struct intel_timeline_cacheline *cl)
>  
>  static void cacheline_free(struct intel_timeline_cacheline *cl)
>  {
> +	if (!i915_active_acquire_if_busy(&cl->active)) {
> +		__idle_cacheline_free(cl);
> +		return;
> +	}
> +
>  	GEM_BUG_ON(ptr_test_bit(cl->vaddr, CACHELINE_FREE));
>  	cl->vaddr = ptr_set_bit(cl->vaddr, CACHELINE_FREE);
>  
> -	if (i915_active_is_idle(&cl->active))
> -		__idle_cacheline_free(cl);
> +	i915_active_release(&cl->active);
>  }
>  
>  int intel_timeline_init(struct intel_timeline *timeline,
> -- 
> 2.25.1


More information about the Intel-gfx mailing list