Skip to content

Commit 2a1eb1a

Browse files
hongkzha-amdalexdeucher
authored andcommitted
drm/amdgpu: fix Null pointer dereference error in amdgpu_device_recover_vram
Use the function of amdgpu_bo_vm_destroy to handle the resource release of shadow bo. During the amdgpu_mes_self_test, shadow bo released, but vmbo->shadow_list was not, which caused a null pointer reference error in amdgpu_device_recover_vram when GPU reset. Fixes: 6c032c3 ("drm/amdgpu: Fix vram recover doesn't work after whole GPU reset (v2)") Signed-off-by: xinhui pan <xinhui.pan@amd.com> Signed-off-by: Horatio Zhang <Hongkun.Zhang@amd.com> Acked-by: Feifei Xu <Feifei.Xu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 30c3d3b commit 2a1eb1a

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ static void amdgpu_bo_user_destroy(struct ttm_buffer_object *tbo)
7979
static void amdgpu_bo_vm_destroy(struct ttm_buffer_object *tbo)
8080
{
8181
struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
82-
struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
82+
struct amdgpu_bo *shadow_bo = ttm_to_amdgpu_bo(tbo), *bo;
8383
struct amdgpu_bo_vm *vmbo;
8484

85+
bo = shadow_bo->parent;
8586
vmbo = to_amdgpu_bo_vm(bo);
8687
/* in case amdgpu_device_recover_vram got NULL of bo->parent */
8788
if (!list_empty(&vmbo->shadow_list)) {
@@ -694,11 +695,6 @@ int amdgpu_bo_create_vm(struct amdgpu_device *adev,
694695
return r;
695696

696697
*vmbo_ptr = to_amdgpu_bo_vm(bo_ptr);
697-
INIT_LIST_HEAD(&(*vmbo_ptr)->shadow_list);
698-
/* Set destroy callback to amdgpu_bo_vm_destroy after vmbo->shadow_list
699-
* is initialized.
700-
*/
701-
bo_ptr->tbo.destroy = &amdgpu_bo_vm_destroy;
702698
return r;
703699
}
704700

@@ -715,6 +711,8 @@ void amdgpu_bo_add_to_shadow_list(struct amdgpu_bo_vm *vmbo)
715711

716712
mutex_lock(&adev->shadow_list_lock);
717713
list_add_tail(&vmbo->shadow_list, &adev->shadow_list);
714+
vmbo->shadow->parent = amdgpu_bo_ref(&vmbo->bo);
715+
vmbo->shadow->tbo.destroy = &amdgpu_bo_vm_destroy;
718716
mutex_unlock(&adev->shadow_list_lock);
719717
}
720718

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ int amdgpu_vm_pt_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,
564564
return r;
565565
}
566566

567-
(*vmbo)->shadow->parent = amdgpu_bo_ref(bo);
568567
amdgpu_bo_add_to_shadow_list(*vmbo);
569568

570569
return 0;

0 commit comments

Comments
 (0)