Commit 82b9c55b authored by Christian König's avatar Christian König Committed by Alex Deucher

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: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 585116c5
...@@ -539,6 +539,7 @@ struct amdgpu_bo { ...@@ -539,6 +539,7 @@ struct amdgpu_bo {
/* Constant after initialization */ /* Constant after initialization */
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct drm_gem_object gem_base; struct drm_gem_object gem_base;
struct amdgpu_bo *parent;
struct ttm_bo_kmap_obj dma_buf_vmap; struct ttm_bo_kmap_obj dma_buf_vmap;
pid_t pid; pid_t pid;
......
...@@ -100,6 +100,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) ...@@ -100,6 +100,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
list_del_init(&bo->list); list_del_init(&bo->list);
mutex_unlock(&bo->adev->gem.mutex); mutex_unlock(&bo->adev->gem.mutex);
drm_gem_object_release(&bo->gem_base); drm_gem_object_release(&bo->gem_base);
amdgpu_bo_unref(&bo->parent);
kfree(bo->metadata); kfree(bo->metadata);
kfree(bo); kfree(bo);
} }
......
...@@ -1079,6 +1079,11 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, ...@@ -1079,6 +1079,11 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
if (r) if (r)
goto error_free; goto error_free;
/* Keep a reference to the page table to avoid freeing
* them up in the wrong order.
*/
pt->parent = amdgpu_bo_ref(vm->page_directory);
r = amdgpu_vm_clear_bo(adev, pt); r = amdgpu_vm_clear_bo(adev, pt);
if (r) { if (r) {
amdgpu_bo_unref(&pt); amdgpu_bo_unref(&pt);
......
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