[Intel-gfx] [PATCH 15/22] drm/i915: Provide an i915_active.acquire callback

Matthew Auld matthew.auld at intel.com
Mon Jun 17 18:58:49 UTC 2019


On 17/06/2019 08:19, Chris Wilson wrote:
> If we introduce a callback for i915_active that is only called the first
> time we use the i915_active and is symmetrically paired with the
> i915_active.retire callback, we can replace the open-coded and
> non-atomic implementations -- which will be very fragile (i.e. broken)
> upon removing the struct_mutex serialisation.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_context.c  |   8 +-
>   drivers/gpu/drm/i915/gt/intel_context.c      |  82 ++++---
>   drivers/gpu/drm/i915/gt/intel_context.h      |  14 +-
>   drivers/gpu/drm/i915/gt/intel_lrc.c          |   6 +-
>   drivers/gpu/drm/i915/gt/intel_ringbuffer.c   |   2 +-
>   drivers/gpu/drm/i915/gt/mock_engine.c        |   2 +-
>   drivers/gpu/drm/i915/i915_active.c           | 217 ++++++++++---------
>   drivers/gpu/drm/i915/i915_active.h           |  25 ++-
>   drivers/gpu/drm/i915/i915_active_types.h     |  10 +-
>   drivers/gpu/drm/i915/i915_gem_gtt.c          |   2 +-
>   drivers/gpu/drm/i915/i915_timeline.c         |  16 +-
>   drivers/gpu/drm/i915/i915_vma.c              |  22 +-
>   drivers/gpu/drm/i915/selftests/i915_active.c |  12 +-
>   13 files changed, 225 insertions(+), 193 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 1ce122f4ed25..9262a1d4f763 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -923,8 +923,12 @@ static int context_barrier_task(struct i915_gem_context *ctx,
>   	if (!cb)
>   		return -ENOMEM;
>   
> -	i915_active_init(i915, &cb->base, cb_retire);
> -	i915_active_acquire(&cb->base);
> +	i915_active_init(i915, &cb->base, NULL, cb_retire);
> +	err = i915_active_acquire(&cb->base);
> +	if (err) {
> +		kfree(cb);
> +		return err;
> +	}
>   
>   	for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) {
>   		struct i915_request *rq;
> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
> index 2c454f227c2e..b19aa823a51a 100644
> --- a/drivers/gpu/drm/i915/gt/intel_context.c
> +++ b/drivers/gpu/drm/i915/gt/intel_context.c
> @@ -95,11 +95,14 @@ void intel_context_unpin(struct intel_context *ce)
>   	intel_context_put(ce);
>   }
>   
> -static int __context_pin_state(struct i915_vma *vma, unsigned long flags)
> +static int __context_pin_state(struct i915_vma *vma)
>   {
> +	u64 flags;
>   	int err;
>   
> -	err = i915_vma_pin(vma, 0, 0, flags | PIN_GLOBAL);
> +	flags = PIN_HIGH | PIN_GLOBAL;
> +	flags |= i915_vm_to_ggtt(vma->vm)->pin_bias | PIN_OFFSET_BIAS;

i915_ggtt_pin_bias(vma) | PIN_OFFSET_BIAS;

Fwiw,
Reviewed-by: Matthew Auld <matthew.auld at intel.com>



More information about the Intel-gfx mailing list