aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2014-07-30 21:04:57 +0200
committerAlex Deucher <alexander.deucher@amd.com>2014-08-05 08:53:54 -0400
commitee26d83ff030fd2a9952a2c91b94c75819f86973 (patch)
treec43944990fc628d55f60be7f302424082ff2b162
parent512d8afc5d971be1e32596c6ad0a68abe1373cd9 (diff)
downloadlinux-stericsson-ee26d83ff030fd2a9952a2c91b94c75819f86973.tar.gz
drm/radeon: take a BO reference on VM cleanup
This closes a small window where the GPU might have accessed freed up memory. Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/radeon/radeon_vm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index 759038800d10..d520ab71b748 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -450,6 +450,7 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
tmp->it.last = bo_va->it.last;
tmp->vm = vm;
tmp->addr = bo_va->addr;
+ tmp->bo = radeon_bo_ref(bo_va->bo);
list_add(&tmp->vm_status, &vm->freed);
}
@@ -932,6 +933,7 @@ int radeon_vm_clear_freed(struct radeon_device *rdev,
list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status) {
r = radeon_vm_bo_update(rdev, bo_va, NULL);
+ radeon_bo_unref(&bo_va->bo);
kfree(bo_va);
if (r)
return r;
@@ -987,7 +989,7 @@ void radeon_vm_bo_rmv(struct radeon_device *rdev,
list_del(&bo_va->vm_status);
if (bo_va->addr) {
- bo_va->bo = NULL;
+ bo_va->bo = radeon_bo_ref(bo_va->bo);
list_add(&bo_va->vm_status, &vm->freed);
} else {
kfree(bo_va);
@@ -1098,8 +1100,10 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
kfree(bo_va);
}
}
- list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status)
+ list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status) {
+ radeon_bo_unref(&bo_va->bo);
kfree(bo_va);
+ }
for (i = 0; i < radeon_vm_num_pdes(rdev); i++)
radeon_bo_unref(&vm->page_tables[i].bo);