mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/amdgpu: remove all KFD fences from the BO on release
Remove all KFD BOs from the private dma_resv object. This prevents the KFD from being evict unecessarily when an exported BO is released. Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: James Zhu <James.Zhu@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Reviewed-and-tested-by: James Zhu <James.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
3521276ad1
commit
cb0de06d1b
@@ -1295,28 +1295,36 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo)
|
||||
if (abo->kfd_bo)
|
||||
amdgpu_amdkfd_release_notify(abo);
|
||||
|
||||
/* We only remove the fence if the resv has individualized. */
|
||||
WARN_ON_ONCE(bo->type == ttm_bo_type_kernel
|
||||
&& bo->base.resv != &bo->base._resv);
|
||||
if (bo->base.resv == &bo->base._resv)
|
||||
amdgpu_amdkfd_remove_fence_on_pt_pd_bos(abo);
|
||||
/*
|
||||
* We lock the private dma_resv object here and since the BO is about to
|
||||
* be released nobody else should have a pointer to it.
|
||||
* So when this locking here fails something is wrong with the reference
|
||||
* counting.
|
||||
*/
|
||||
if (WARN_ON_ONCE(!dma_resv_trylock(&bo->base._resv)))
|
||||
return;
|
||||
|
||||
amdgpu_amdkfd_remove_all_eviction_fences(abo);
|
||||
|
||||
if (!bo->resource || bo->resource->mem_type != TTM_PL_VRAM ||
|
||||
!(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE) ||
|
||||
adev->in_suspend || drm_dev_is_unplugged(adev_to_drm(adev)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
if (WARN_ON_ONCE(!dma_resv_trylock(bo->base.resv)))
|
||||
return;
|
||||
r = dma_resv_reserve_fences(&bo->base._resv, 1);
|
||||
if (r)
|
||||
goto out;
|
||||
|
||||
r = amdgpu_fill_buffer(abo, 0, bo->base.resv, &fence, true);
|
||||
if (!WARN_ON(r)) {
|
||||
amdgpu_vram_mgr_set_cleared(bo->resource);
|
||||
amdgpu_bo_fence(abo, fence, false);
|
||||
dma_fence_put(fence);
|
||||
}
|
||||
r = amdgpu_fill_buffer(abo, 0, &bo->base._resv, &fence, true);
|
||||
if (WARN_ON(r))
|
||||
goto out;
|
||||
|
||||
dma_resv_unlock(bo->base.resv);
|
||||
amdgpu_vram_mgr_set_cleared(bo->resource);
|
||||
dma_resv_add_fence(&bo->base._resv, fence, DMA_RESV_USAGE_KERNEL);
|
||||
dma_fence_put(fence);
|
||||
|
||||
out:
|
||||
dma_resv_unlock(&bo->base._resv);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user