gpu: nvgpu: Keep lock while unreffing mappings

In the vm_area free code, when unreffing the mappings owned by
the vm_area, we need to continue holding the VM lock.

Also add a comment specifying this requirement in the VM code.

Bug 2156667

Change-Id: If0b430f045e4c585fcba2d3176163e5b19be8326
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1763235
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Alex Waterman
2018-06-27 10:14:12 -07:00
committed by mobile promotions
parent e8d51f0c32
commit e323f562b2
2 changed files with 7 additions and 1 deletions

View File

@@ -1094,6 +1094,11 @@ static void __nvgpu_vm_unmap(struct nvgpu_mapped_buf *mapped_buffer,
nvgpu_kfree(g, mapped_buffer);
}
/*
* Note: the update_gmmu_lock of the VM that owns this buffer must be locked
* before calling nvgpu_ref_put() with this function as the unref function
* argument since this can modify the tree of maps.
*/
void __nvgpu_vm_unmap_ref(struct nvgpu_ref *ref)
{
struct nvgpu_mapped_buf *mapped_buffer =

View File

@@ -199,7 +199,6 @@ int nvgpu_vm_area_free(struct vm_gk20a *vm, u64 addr)
return 0;
}
nvgpu_list_del(&vm_area->vm_area_list);
nvgpu_mutex_release(&vm->update_gmmu_lock);
nvgpu_log(g, gpu_dbg_map,
"DEL vm_area: pgsz=%#-8x pages=%-9llu "
@@ -219,6 +218,8 @@ int nvgpu_vm_area_free(struct vm_gk20a *vm, u64 addr)
nvgpu_ref_put(&buffer->ref, __nvgpu_vm_unmap_ref);
}
nvgpu_mutex_release(&vm->update_gmmu_lock);
/* if this was a sparse mapping, free the va */
if (vm_area->sparse)
g->ops.mm.gmmu_unmap(vm,