From: Michel Dänzer <michel.daen...@amd.com>

If there is no free space in CPU visible VRAM for the faulting BO, move
it to GTT instead of evicting other BOs from CPU visible VRAM.

Signed-off-by: Michel Dänzer <michel.daen...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index b3252bc8fe51..41ee353b22c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -940,7 +940,6 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object 
*bo)
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
        struct amdgpu_bo *abo;
        unsigned long offset, size;
-       int r;
 
        if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
                return 0;
@@ -960,22 +959,17 @@ int amdgpu_bo_fault_reserve_notify(struct 
ttm_buffer_object *bo)
                return -EINVAL;
 
        /* hurrah the memory is not visible ! */
-       amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
+       amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM |
+                                        AMDGPU_GEM_DOMAIN_GTT);
        abo->placements[0].lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
-       r = ttm_bo_validate(bo, &abo->placement, false, false);
-       if (unlikely(r == -ENOMEM)) {
-               amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
-               return ttm_bo_validate(bo, &abo->placement, false, false);
-       } else if (unlikely(r != 0)) {
-               return r;
-       }
 
-       offset = bo->mem.start << PAGE_SHIFT;
-       /* this should never happen */
-       if ((offset + size) > adev->mc.visible_vram_size)
-               return -EINVAL;
+       /* Only set GTT as busy placement; if there is no space in CPU visible
+        * VRAM, move this BO to GTT instead of evicting other BOs
+        */
+       abo->placement.busy_placement = &abo->placements[1];
+       abo->placement.num_busy_placement = 1;
 
-       return 0;
+       return ttm_bo_validate(bo, &abo->placement, false, false);
 }
 
 /**
-- 
2.11.0

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

Reply via email to