Commit fe158997 authored by Bernard Zhao's avatar Bernard Zhao Committed by Alex Deucher

drm/amdgpu: shrink critical section in amdgpu_amdkfd_gpuvm_free_memory_of_gpu

Reduce the mem->lock`s protected code area, no need to protect pr_debug.
This also simplifies error handling.
Signed-off-by: default avatarBernard Zhao <bernard@vivo.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6f81b2d0
...@@ -1284,22 +1284,22 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( ...@@ -1284,22 +1284,22 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct kfd_bo_va_list *entry, *tmp; struct kfd_bo_va_list *entry, *tmp;
struct bo_vm_reservation_context ctx; struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry; struct ttm_validate_buffer *bo_list_entry;
unsigned int mapped_to_gpu_memory;
int ret; int ret;
mutex_lock(&mem->lock); mutex_lock(&mem->lock);
mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
mutex_unlock(&mem->lock);
/* lock is not needed after this, since mem is unused and will
* be freed anyway
*/
if (mem->mapped_to_gpu_memory > 0) { if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n", pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size); mem->va, bo_size);
mutex_unlock(&mem->lock);
return -EBUSY; return -EBUSY;
} }
mutex_unlock(&mem->lock);
/* lock is not needed after this, since mem is unused and will
* be freed anyway
*/
/* No more MMU notifiers */ /* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo); amdgpu_mn_unregister(mem->bo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment