[PATCH 3/3] drm/amdgpu: validate the eviction fence attach/detach

Christian König christian.koenig at amd.com
Tue Apr 29 14:13:16 UTC 2025


On 4/29/25 11:12, Liang, Prike wrote:
>>> +   if (!IS_ERR_OR_NULL(fpriv->evf_mgr.ev_fence)) {
>>
>> Please don't use ERR_PTR functions on members.
>>
>>> +           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;
>>> +           }
>>
>> We should always have a stub fence in fpriv->evf_mgr.ev_fence, so those checks
>> are unnecessary.
> I checked that when enabling the kq and uq at the same time, and before schedule any user queue task then the eviction fence is NULL.

Yeah, but that case is handled by amdgpu_eviction_fence_attach() and *NOT* here.

You are completely messing up the logic with that stuff here.

Regards,
Christian.


> Based on the current design, the eviction fence only be created at the user queue BOs restored time.
> 
>> Regards,
>> Christian.
>>
>>>     }
>>>
>>>     amdgpu_bo_unreserve(abo);
>>> @@ -362,7 +365,8 @@ 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) &&
>>> +                   !IS_ERR_OR_NULL(fpriv->evf_mgr.ev_fence))
>>>             amdgpu_eviction_fence_detach(&fpriv->evf_mgr, bo);
>>>
>>>     bo_va = amdgpu_vm_bo_find(vm, bo);
> 



More information about the amd-gfx mailing list