drm/amdgpu: Evict BOs from same process for contiguous allocation
authorPhilip Yang <Philip.Yang@amd.com>
Fri, 5 Apr 2024 19:56:41 +0000 (15:56 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 30 Apr 2024 13:58:15 +0000 (09:58 -0400)
When TTM failed to alloc VRAM, TTM try evict BOs from VRAM to system
memory then retry the allocation, this skips the KFD BOs from the same
process because KFD require all BOs are resident for user queues.

If TTM with TTM_PL_FLAG_CONTIGUOUS flag to alloc contiguous VRAM, allow
TTM evict KFD BOs from the same process, this will evict the user queues
first, and restore the queues later after contiguous VRAM allocation.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 923b20d3fdbd896d7d0dd4649636bb14fe5a46f5..2c1f4016272cd0721eab1624457f6b88c026dba6 100644 (file)
@@ -1400,7 +1400,8 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
         */
        dma_resv_for_each_fence(&resv_cursor, bo->base.resv,
                                DMA_RESV_USAGE_BOOKKEEP, f) {
-               if (amdkfd_fence_check_mm(f, current->mm))
+               if (amdkfd_fence_check_mm(f, current->mm) &&
+                   !(place->flags & TTM_PL_FLAG_CONTIGUOUS))
                        return false;
        }