mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 07:03:28 -04:00
drm/amdgpu: skip BOs being torn down during GTT recovery
A GPU reset can race with BO teardown after the BO's GTT resource has been marked for deletion but before its drm_mm node is removed. In this window, amdgpu_gtt_mgr_recover() can treat the node as a live BO and try to restore its GART mapping while its TT backing is being destroyed. Recolor the GTT node from amdgpu_bo_delete_mem_notify() so that recovery skips it, reusing the existing color for ranges without a BO. The range stays allocated until the resource is freed. This prevents reset recovery from accessing a BO whose backing storage is no longer valid. v2: refine commit message. (David Francis) v3: Remove new BO color. (Christian) Signed-off-by: Yifan Zhang <yifan1.zhang@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Perry Yuan <perry.yuan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
a4b0720e4f
commit
24775b2e8b
@@ -102,6 +102,29 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *res)
|
||||
return drm_mm_node_allocated(&node->mm_nodes[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_gtt_mgr_mark_bo_teardown - exclude a BO from GART recovery
|
||||
*
|
||||
* @tbo: TTM BO whose TT backing is about to be destroyed
|
||||
*
|
||||
* Keep the GART range allocated until the resource is freed, but make recovery
|
||||
* treat it like a range without a BO so it isn't touched after TT teardown has
|
||||
* started.
|
||||
*/
|
||||
void amdgpu_gtt_mgr_mark_bo_teardown(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
|
||||
struct ttm_range_mgr_node *node = to_ttm_range_mgr_node(tbo->resource);
|
||||
struct amdgpu_gtt_mgr *mgr = &adev->mman.gtt_mgr;
|
||||
|
||||
dma_resv_assert_held(tbo->base.resv);
|
||||
|
||||
spin_lock(&mgr->lock);
|
||||
if (drm_mm_node_allocated(&node->mm_nodes[0]))
|
||||
node->mm_nodes[0].color = GART_ENTRY_WITHOUT_BO_COLOR;
|
||||
spin_unlock(&mgr->lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_gtt_mgr_new - allocate a new node
|
||||
*
|
||||
|
||||
@@ -1694,6 +1694,9 @@ static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo,
|
||||
static void
|
||||
amdgpu_bo_delete_mem_notify(struct ttm_buffer_object *bo)
|
||||
{
|
||||
if (bo->resource && bo->resource->mem_type == TTM_PL_TT)
|
||||
amdgpu_gtt_mgr_mark_bo_teardown(bo);
|
||||
|
||||
amdgpu_bo_move_notify(bo, false, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev);
|
||||
void amdgpu_vram_mgr_fini(struct amdgpu_device *adev);
|
||||
|
||||
bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem);
|
||||
void amdgpu_gtt_mgr_mark_bo_teardown(struct ttm_buffer_object *tbo);
|
||||
void amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr);
|
||||
|
||||
int amdgpu_gtt_mgr_alloc_entries(struct amdgpu_gtt_mgr *mgr,
|
||||
|
||||
Reference in New Issue
Block a user