Make sure that we never allocate a page table for an invalidation operation.

Signed-off-by: Christian König <christian.koe...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 4de9b3300870..9af5bde885a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1416,15 +1416,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);
@@ -1453,6 +1453,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);
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to