]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/amdgpu: fix and cleanup VM ready check
authorChristian König <christian.koenig@amd.com>
Thu, 24 Aug 2017 10:32:55 +0000 (12:32 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 29 Aug 2017 19:27:56 +0000 (15:27 -0400)
Stop checking the mapped BO itself, cause that one is
certainly not a page table.

Additional to that move the code into amdgpu_vm.c

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

index 7171968f261e1a13094f3c94b2d649a382b2f6a0..9b1b6bdd48410bbfab9fa0dc8fc66a25c68d3559 100644 (file)
@@ -127,35 +127,6 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
        return 0;
 }
 
-static int amdgpu_gem_vm_check(void *param, struct amdgpu_bo *bo)
-{
-       /* if anything is swapped out don't swap it in here,
-          just abort and wait for the next CS */
-       if (!amdgpu_bo_gpu_accessible(bo))
-               return -ERESTARTSYS;
-
-       if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow))
-               return -ERESTARTSYS;
-
-       return 0;
-}
-
-static bool amdgpu_gem_vm_ready(struct amdgpu_device *adev,
-                               struct amdgpu_vm *vm,
-                               struct list_head *list)
-{
-       struct ttm_validate_buffer *entry;
-
-       list_for_each_entry(entry, list, head) {
-               struct amdgpu_bo *bo =
-                       container_of(entry->bo, struct amdgpu_bo, tbo);
-               if (amdgpu_gem_vm_check(NULL, bo))
-                       return false;
-       }
-
-       return !amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_gem_vm_check, NULL);
-}
-
 void amdgpu_gem_object_close(struct drm_gem_object *obj,
                             struct drm_file *file_priv)
 {
@@ -189,7 +160,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
        if (bo_va && --bo_va->ref_count == 0) {
                amdgpu_vm_bo_rmv(adev, bo_va);
 
-               if (amdgpu_gem_vm_ready(adev, vm, &list)) {
+               if (amdgpu_vm_ready(adev, vm)) {
                        struct dma_fence *fence = NULL;
 
                        r = amdgpu_vm_clear_freed(adev, vm, &fence);
@@ -513,7 +484,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
 {
        int r = -ERESTARTSYS;
 
-       if (!amdgpu_gem_vm_ready(adev, vm, list))
+       if (!amdgpu_vm_ready(adev, vm))
                goto error;
 
        r = amdgpu_vm_update_directories(adev, vm);
index db63ff5c80f20981e5bc8507c62378dff2e3fe44..67c37b22f8ef36d66d5bfea85a9a783c820a71be 100644 (file)
@@ -231,6 +231,38 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                                        adev->mman.bdev.glob);
 }
 
+/**
+ * amdgpu_vm_check - helper for amdgpu_vm_ready
+ */
+static int amdgpu_vm_check(void *param, struct amdgpu_bo *bo)
+{
+       /* if anything is swapped out don't swap it in here,
+          just abort and wait for the next CS */
+       if (!amdgpu_bo_gpu_accessible(bo))
+               return -ERESTARTSYS;
+
+       if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow))
+               return -ERESTARTSYS;
+
+       return 0;
+}
+
+/**
+ * amdgpu_vm_ready - check VM is ready for updates
+ *
+ * @adev: amdgpu device
+ * @vm: VM to check
+ *
+ * Check if all VM PDs/PTs are ready for updates
+ */
+bool amdgpu_vm_ready(struct amdgpu_device *adev, struct amdgpu_vm *vm)
+{
+       if (amdgpu_vm_check(NULL, vm->root.bo))
+               return false;
+
+       return !amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_vm_check, NULL);
+}
+
 /**
  * amdgpu_vm_alloc_levels - allocate the PD/PT levels
  *
index ba6691b58ee72f4e785bcf83a643065a3e8b89e0..9347d28c3c1e5ccda9ef41c958b0e404d9e605d6 100644 (file)
@@ -225,6 +225,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm);
 void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
                         struct list_head *validated,
                         struct amdgpu_bo_list_entry *entry);
+bool amdgpu_vm_ready(struct amdgpu_device *adev, struct amdgpu_vm *vm);
 int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                              int (*callback)(void *p, struct amdgpu_bo *bo),
                              void *param);