It doesn't need to attach the invalid eviction fence
to non-userq's BOs.

Signed-off-by: Prike Liang <prike.li...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 2c68118fe9fd..50356aa23a99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -294,12 +294,14 @@ static int amdgpu_gem_object_open(struct drm_gem_object 
*obj,
        else
                ++bo_va->ref_count;
 
-       /* attach gfx eviction fence */
-       r = amdgpu_eviction_fence_attach(&fpriv->evf_mgr, abo);
-       if (r) {
-               DRM_DEBUG_DRIVER("Failed to attach eviction fence to BO\n");
-               amdgpu_bo_unreserve(abo);
-               return r;
+       /* attach gfx eviction fence when userq created*/
+       if (vm->is_userq_context) {
+               r = amdgpu_eviction_fence_attach(&fpriv->evf_mgr, abo);
+               if (r) {
+                       DRM_DEBUG_DRIVER("Failed to attach eviction fence to 
BO\n");
+                       amdgpu_bo_unreserve(abo);
+                       return r;
+               }
        }
 
        amdgpu_bo_unreserve(abo);
@@ -365,7 +367,7 @@ static void amdgpu_gem_object_close(struct drm_gem_object 
*obj,
                        goto out_unlock;
        }
 
-       if (!amdgpu_vm_is_bo_always_valid(vm, bo))
+       if (!amdgpu_vm_is_bo_always_valid(vm, bo) && vm->is_compute_context)
                amdgpu_eviction_fence_detach(&fpriv->evf_mgr, bo);
 
        bo_va = amdgpu_vm_bo_find(vm, bo);
-- 
2.34.1

Reply via email to