aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-11-27 10:49:00 -0500
committerAlex Deucher <alexander.deucher@amd.com>2015-11-30 14:41:33 -0500
commit82b9c55b1edfcb87f5568add56bc7313f5893b60 (patch)
tree58aaf2f240374a533d74d71b080508885655e5dd /drivers/gpu
parent585116c5fafe578e89c146c9839c95ac75acfb9d (diff)
drm/amdgpu: fix VM page table reference counting
We use the reservation object of the page directory for the page tables as well, because of this the page directory should be freed last. Ensure that by keeping a reference from the page tables to the directory. Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c5
3 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 251b14736de9..670fefb56945 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -539,6 +539,7 @@ struct amdgpu_bo {
539 /* Constant after initialization */ 539 /* Constant after initialization */
540 struct amdgpu_device *adev; 540 struct amdgpu_device *adev;
541 struct drm_gem_object gem_base; 541 struct drm_gem_object gem_base;
542 struct amdgpu_bo *parent;
542 543
543 struct ttm_bo_kmap_obj dma_buf_vmap; 544 struct ttm_bo_kmap_obj dma_buf_vmap;
544 pid_t pid; 545 pid_t pid;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 0d524384ff79..c3ce103b6a33 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -100,6 +100,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
100 list_del_init(&bo->list); 100 list_del_init(&bo->list);
101 mutex_unlock(&bo->adev->gem.mutex); 101 mutex_unlock(&bo->adev->gem.mutex);
102 drm_gem_object_release(&bo->gem_base); 102 drm_gem_object_release(&bo->gem_base);
103 amdgpu_bo_unref(&bo->parent);
103 kfree(bo->metadata); 104 kfree(bo->metadata);
104 kfree(bo); 105 kfree(bo);
105} 106}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ae037e5b6ad0..a582ef553499 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1079,6 +1079,11 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
1079 if (r) 1079 if (r)
1080 goto error_free; 1080 goto error_free;
1081 1081
1082 /* Keep a reference to the page table to avoid freeing
1083 * them up in the wrong order.
1084 */
1085 pt->parent = amdgpu_bo_ref(vm->page_directory);
1086
1082 r = amdgpu_vm_clear_bo(adev, pt); 1087 r = amdgpu_vm_clear_bo(adev, pt);
1083 if (r) { 1088 if (r) {
1084 amdgpu_bo_unref(&pt); 1089 amdgpu_bo_unref(&pt);