Commit 2698f620 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: cleanup VM shadow BO unreferencing

Unreference the shadow BOs in the error path as well and drop the NULL checks.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarEdward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0fc8683e
...@@ -1430,6 +1430,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, ...@@ -1430,6 +1430,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
r = amdgpu_vm_clear_bo(adev, vm, pt); r = amdgpu_vm_clear_bo(adev, vm, pt);
if (r) { if (r) {
amdgpu_bo_unref(&pt->shadow);
amdgpu_bo_unref(&pt); amdgpu_bo_unref(&pt);
goto error_free; goto error_free;
} }
...@@ -1636,6 +1637,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) ...@@ -1636,6 +1637,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
return 0; return 0;
error_free_page_directory: error_free_page_directory:
amdgpu_bo_unref(&vm->page_directory->shadow);
amdgpu_bo_unref(&vm->page_directory); amdgpu_bo_unref(&vm->page_directory);
vm->page_directory = NULL; vm->page_directory = NULL;
...@@ -1675,15 +1677,17 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) ...@@ -1675,15 +1677,17 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
} }
for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) { for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) {
if (vm->page_tables[i].entry.robj && struct amdgpu_bo *pt = vm->page_tables[i].entry.robj;
vm->page_tables[i].entry.robj->shadow)
amdgpu_bo_unref(&vm->page_tables[i].entry.robj->shadow); if (!pt)
amdgpu_bo_unref(&vm->page_tables[i].entry.robj); continue;
amdgpu_bo_unref(&pt->shadow);
amdgpu_bo_unref(&pt);
} }
drm_free_large(vm->page_tables); drm_free_large(vm->page_tables);
if (vm->page_directory->shadow) amdgpu_bo_unref(&vm->page_directory->shadow);
amdgpu_bo_unref(&vm->page_directory->shadow);
amdgpu_bo_unref(&vm->page_directory); amdgpu_bo_unref(&vm->page_directory);
fence_put(vm->page_directory_fence); fence_put(vm->page_directory_fence);
} }
......
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