Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: move VM eviction decision into amdgpu_vm.c

When a page tables needs to be evicted the VM code should
decide if that is possible or not.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
6ceeb144 4b4c5638

+24 -4
+1 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 1489 1489 struct dma_fence *f; 1490 1490 int i; 1491 1491 1492 - /* Don't evict VM page tables while they are busy, otherwise we can't 1493 - * cleanly handle page faults. 1494 - */ 1495 1492 if (bo->type == ttm_bo_type_kernel && 1496 - !dma_resv_test_signaled_rcu(bo->base.resv, true)) 1493 + !amdgpu_vm_evictable(ttm_to_amdgpu_bo(bo))) 1497 1494 return false; 1498 1495 1499 1496 /* If bo is a KFD BO, check if the bo belongs to the current process.
+22
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 2500 2500 } 2501 2501 2502 2502 /** 2503 + * amdgpu_vm_evictable - check if we can evict a VM 2504 + * 2505 + * @bo: A page table of the VM. 2506 + * 2507 + * Check if it is possible to evict a VM. 2508 + */ 2509 + bool amdgpu_vm_evictable(struct amdgpu_bo *bo) 2510 + { 2511 + struct amdgpu_vm_bo_base *bo_base = bo->vm_bo; 2512 + 2513 + /* Page tables of a destroyed VM can go away immediately */ 2514 + if (!bo_base || !bo_base->vm) 2515 + return true; 2516 + 2517 + /* Don't evict VM page tables while they are busy */ 2518 + if (!dma_resv_test_signaled_rcu(bo->tbo.base.resv, true)) 2519 + return false; 2520 + 2521 + return true; 2522 + } 2523 + 2524 + /** 2503 2525 * amdgpu_vm_bo_invalidate - mark the bo as invalid 2504 2526 * 2505 2527 * @adev: amdgpu_device pointer
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
··· 378 378 int amdgpu_vm_bo_update(struct amdgpu_device *adev, 379 379 struct amdgpu_bo_va *bo_va, 380 380 bool clear); 381 + bool amdgpu_vm_evictable(struct amdgpu_bo *bo); 381 382 void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, 382 383 struct amdgpu_bo *bo, bool evicted); 383 384 uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr);