drm/amdgpu: fix tear down order in amdgpu_vm_pt_free
Subsystems (2)
PATCH 1/2 drm/amdgpu: fix tear down order in amdgpu_vm_pt_free
When freeing PD/PT with shadows it can happen that the shadow destruction races with detaching the PD/PT from the VM causing a NULL pointer dereference in the invalidation code.
Fix this by detaching the the PD/PT from the VM first and then freeinguthe shadow instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +2 -1
@@ -642,13 +642,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry)if (!entry->bo)return ; + + entry->bo->vm_bo =NULL ; shadow =amdgpu_bo_shadowed (entry->bo);if (shadow) {ttm_bo_set_bulk_move (&shadow->tbo,NULL );amdgpu_bo_unref (&shadow); }ttm_bo_set_bulk_move (&entry->bo->tbo,NULL ); - entry->bo->vm_bo =NULL ;spin_lock (&entry->vm->status_lock);list_del (&entry->vm_status);
Signature · 1 line
2.34.1
PATCH 2/2 drm/amdgpu: warn when there are still mappings when a BO is destroyed v2
This can only happen when there is a reference counting bug.
v2: fix typo
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -0
@@ -1343,6 +1343,8 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo) abo =ttm_to_amdgpu_bo (bo); +WARN_ON (abo->vm_bo); +if (abo->kfd_bo)amdgpu_amdkfd_release_notify (abo);
Signature · 1 line
2.34.1
Quoted 7 lines · Christian König
When freeing PD/PT with shadows it can happen that the shadow destruction races with detaching the PD/PT from the VM causing a NULL pointer dereference in the invalidation code.
Fix this by detaching the the PD/PT from the VM first and then freeinguthe shadow instead.
typo. Should read:
freeing the shadow.
WIth that fixed, the series is:
Quoted 31 lines
Signed-off-by Christian König <[email protected]>Cc <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +2
-2@@ -642,13 +642,14 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry)if (!entry->bo)return ; + + entry->bo->vm_bo =NULL ; shadow =amdgpu_bo_shadowed (entry->bo);if (shadow) {ttm_bo_set_bulk_move (&shadow->tbo,NULL );amdgpu_bo_unref (&shadow); }ttm_bo_set_bulk_move (&entry->bo->tbo,NULL ); - entry->bo->vm_bo =NULL ;spin_lock (&entry->vm->status_lock);list_del (&entry->vm_status); --2.34.1