]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu: move VM eviction decision into amdgpu_vm.c
authorChristian König <christian.koenig@amd.com>
Thu, 28 Nov 2019 13:51:46 +0000 (14:51 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Dec 2019 22:01:51 +0000 (17:01 -0500)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

index 61d9b7774d42ef87ab26ee2a8d6916d19cea355e..80fc3d8ee1cfa79b4c06ef7eb580158a34ee3873 100644 (file)
@@ -1489,11 +1489,8 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
        struct dma_fence *f;
        int i;
 
-       /* Don't evict VM page tables while they are busy, otherwise we can't
-        * cleanly handle page faults.
-        */
        if (bo->type == ttm_bo_type_kernel &&
-           !dma_resv_test_signaled_rcu(bo->base.resv, true))
+           !amdgpu_vm_evictable(ttm_to_amdgpu_bo(bo)))
                return false;
 
        /* If bo is a KFD BO, check if the bo belongs to the current process.
index f20b572d2438e83482b1c34710fc2b2639cb7039..145ea95d977a09a654a87f8e95e57aab152dfe96 100644 (file)
@@ -2499,6 +2499,28 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,
        kfree(bo_va);
 }
 
+/**
+ * amdgpu_vm_evictable - check if we can evict a VM
+ *
+ * @bo: A page table of the VM.
+ *
+ * Check if it is possible to evict a VM.
+ */
+bool amdgpu_vm_evictable(struct amdgpu_bo *bo)
+{
+       struct amdgpu_vm_bo_base *bo_base = bo->vm_bo;
+
+       /* Page tables of a destroyed VM can go away immediately */
+       if (!bo_base || !bo_base->vm)
+               return true;
+
+       /* Don't evict VM page tables while they are busy */
+       if (!dma_resv_test_signaled_rcu(bo->tbo.base.resv, true))
+               return false;
+
+       return true;
+}
+
 /**
  * amdgpu_vm_bo_invalidate - mark the bo as invalid
  *
index 67f946b0c515a0cd4559a686cdd8394d7d77a504..d3b7a5cff56cc27f6075d138504f938acfdf2596 100644 (file)
@@ -378,6 +378,7 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
 int amdgpu_vm_bo_update(struct amdgpu_device *adev,
                        struct amdgpu_bo_va *bo_va,
                        bool clear);
+bool amdgpu_vm_evictable(struct amdgpu_bo *bo);
 void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
                             struct amdgpu_bo *bo, bool evicted);
 uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr);