[Intel-gfx] [PATCH 10/20] drm/i915/gt: Pull marking vm as closed underneath the vm->mutex
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Fri Feb 28 12:12:09 UTC 2020
On 27/02/2020 08:57, Chris Wilson wrote:
> Pull the final atomic_dec of vm->open (marking the vm as closed)
> underneath the same vm->mutex as used to close it. This is required to
> correctly serialise with attempting to reuse the vma as the vm is closed
> by a second thread.
>
> References: 00de702c6c6f ("drm/i915: Check that the vma hasn't been closed before we insert it")
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/gt/intel_gtt.c | 5 ++++-
> drivers/gpu/drm/i915/gt/intel_gtt.h | 3 +--
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.c b/drivers/gpu/drm/i915/gt/intel_gtt.c
> index bb9a6e638175..dfb1be050cca 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gtt.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gtt.c
> @@ -171,7 +171,9 @@ void __i915_vm_close(struct i915_address_space *vm)
> {
> struct i915_vma *vma, *vn;
>
> - mutex_lock(&vm->mutex);
> + if (!atomic_dec_and_mutex_lock(&vm->open, &vm->mutex))
> + return;
> +
> list_for_each_entry_safe(vma, vn, &vm->bound_list, vm_link) {
> struct drm_i915_gem_object *obj = vma->obj;
>
> @@ -186,6 +188,7 @@ void __i915_vm_close(struct i915_address_space *vm)
> i915_gem_object_put(obj);
> }
> GEM_BUG_ON(!list_empty(&vm->bound_list));
> +
> mutex_unlock(&vm->mutex);
> }
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h
> index 23004445806a..eac38c682ef4 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gtt.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
> @@ -429,8 +429,7 @@ static inline void
> i915_vm_close(struct i915_address_space *vm)
> {
> GEM_BUG_ON(!atomic_read(&vm->open));
> - if (atomic_dec_and_test(&vm->open))
> - __i915_vm_close(vm);
> + __i915_vm_close(vm);
>
> i915_vm_put(vm);
> }
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Regards,
Tvrtko
More information about the Intel-gfx
mailing list