Skip to content

Commit 82b9c55

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
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>
1 parent 585116c commit 82b9c55

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ struct amdgpu_bo {
539539
/* Constant after initialization */
540540
struct amdgpu_device *adev;
541541
struct drm_gem_object gem_base;
542+
struct amdgpu_bo *parent;
542543

543544
struct ttm_bo_kmap_obj dma_buf_vmap;
544545
pid_t pid;

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
100100
list_del_init(&bo->list);
101101
mutex_unlock(&bo->adev->gem.mutex);
102102
drm_gem_object_release(&bo->gem_base);
103+
amdgpu_bo_unref(&bo->parent);
103104
kfree(bo->metadata);
104105
kfree(bo);
105106
}

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,11 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
10791079
if (r)
10801080
goto error_free;
10811081

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+
10821087
r = amdgpu_vm_clear_bo(adev, pt);
10831088
if (r) {
10841089
amdgpu_bo_unref(&pt);

0 commit comments

Comments
 (0)