drm/amdgpu: make sure to never allocate PDs/PTs for invalidations
authorChristian König <christian.koenig@amd.com>
Wed, 18 Dec 2019 14:45:17 +0000 (15:45 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 5 Feb 2020 04:30:39 +0000 (23:30 -0500)
Make sure that we never allocate a page table for an invalidation operation.

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_vm.c

index 010561e..b40c017 100644 (file)
@@ -1442,15 +1442,15 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
                uint64_t incr, entry_end, pe_start;
                struct amdgpu_bo *pt;
 
-               /* make sure that the page tables covering the address range are
-                * actually allocated
-                */
-               r = amdgpu_vm_alloc_pts(params->adev, params->vm, &cursor,
-                                       params->direct);
-               if (r)
-                       return r;
-
-               pt = cursor.entry->base.bo;
+               if (flags & AMDGPU_PTE_VALID) {
+                       /* make sure that the page tables covering the
+                        * address range are actually allocated
+                        */
+                       r = amdgpu_vm_alloc_pts(params->adev, params->vm,
+                                               &cursor, params->direct);
+                       if (r)
+                               return r;
+               }
 
                shift = amdgpu_vm_level_shift(adev, cursor.level);
                parent_shift = amdgpu_vm_level_shift(adev, cursor.level - 1);
@@ -1479,6 +1479,10 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
                        continue;
                }
 
+               pt = cursor.entry->base.bo;
+               if (!pt)
+                       return -ENOENT;
+
                /* Looks good so far, calculate parameters for the update */
                incr = (uint64_t)AMDGPU_GPU_PAGE_SIZE << shift;
                mask = amdgpu_vm_entries_mask(adev, cursor.level);