[Intel-gfx] [PATCH 2/7] drm/i915: Release shortlived maps of longlived objects

Chris Wilson chris at chris-wilson.co.uk
Wed Jul 8 13:50:34 UTC 2020


Quoting Chris Wilson (2020-07-08 14:47:37)
> Some objects we map once during their construction, and then never
> access their mappings again, even if they are kept around for the
> duration of the driver. Keeping those pages mapped, often vmapped, is
> therefore wasteful and we should release the maps as soon as we no
> longer need them.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_object.h    |  2 ++
>  drivers/gpu/drm/i915/gem/i915_gem_pages.c     | 20 +++++++++++++++++++
>  drivers/gpu/drm/i915/gt/gen7_renderclear.c    |  1 +
>  drivers/gpu/drm/i915/gt/intel_lrc.c           |  1 +
>  .../gpu/drm/i915/gt/intel_ring_submission.c   |  1 +
>  drivers/gpu/drm/i915/i915_perf.c              |  2 ++
>  6 files changed, 27 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> index 2faa481cc18f..a26a4faf014f 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
> @@ -394,6 +394,8 @@ static inline void i915_gem_object_unpin_map(struct drm_i915_gem_object *obj)
>         i915_gem_object_unpin_pages(obj);
>  }
>  
> +int i915_gem_object_release_map(struct drm_i915_gem_object *obj);
> +
>  void
>  i915_gem_object_flush_write_domain(struct drm_i915_gem_object *obj,
>                                    unsigned int flush_domains);
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> index af9e48ee4a33..114256014a97 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
> @@ -408,6 +408,26 @@ void __i915_gem_object_flush_map(struct drm_i915_gem_object *obj,
>         }
>  }
>  
> +int i915_gem_object_release_map(struct drm_i915_gem_object *obj)
> +{
> +       int err;
> +
> +       err = mutex_lock_interruptible(&obj->mm.lock);
> +       if (err)
> +               return err;
> +
> +       if (atomic_read(&obj->mm.pages_pin_count)) {
> +               err = -EBUSY;

Hmm. I realise this slightly defeats the efficacy of the patch, since we
often have a pinned vma at the time.

Since we only call this at known points, we can just say the caller
knows best and force the unmap. If we get it wrong, we'll have a very
weird GPF.
-Chris


More information about the Intel-gfx mailing list