drm/amdgpu/evf: skip BOs no longer in the VM
Subsystems (2)
PATCH 1/1 drm/amdgpu/evf: skip BOs no longer in the VM
If the eviction fence restore gets triggered while a BO unmap is happening, the attempt to lock the BO for restore will fail. On retry, drm_exec locks the contended BO first, but it is not actually required to be locked, and the eviction fence should not be attached to such a BO.
If the BO was freed, this extra lock will cause BUG_ON to fire in dma_resv_add_fence, since the gem object and its resv lists are freed already.
drm_exec::prelocked remains set only if the object was locked on retry but not actually requested to be locked, so use that to detect this case and skip it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c +4 -0
@@ -145,6 +145,10 @@ int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr,/* And add it to all existing BOs */ drm_exec_for_each_locked_object (exec, index, obj) {struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); +/* A BO may be locked after it has been dropped from the VM due +* to how drm_exec treats contention. */ +if (obj == exec->prelocked) +continue ;amdgpu_evf_mgr_attach_fence (evf_mgr, bo); }
Signature · 1 line
2.55.0
Quoted 1 line · Benjamin Cheng
If the eviction fence restore gets triggered while a BO unmap is
Sorry, this should be s/eviction fence restore/userq vm restore/
Quoted 34 lines
happening, the attempt to lock the BO for restore will fail. On retry,
drm_execlocks the contended BO first, but it is not actually required to be locked, and the eviction fence should not be attached to such a BO.If the BO was freed, this extra lock will cause
BUG_ONto fire indma_resv_add_fence, since the gem object and its resv lists are freed already.
drm_exec::prelockedremains set only if the object was locked on retry but not actually requested to be locked, so use that to detect this case and skip it.Fixes 2cd7284ba54b ("drm/amdgpu: completely rework eviction fence handling v2")Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c +4
-0@@ -145,6 +145,10 @@ int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr,/* And add it to all existing BOs */ drm_exec_for_each_locked_object (exec, index, obj) {struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); +/* A BO may be locked after it has been dropped from the VM due +* to how drm_exec treats contention. */ +if (obj == exec->prelocked) +continue ;amdgpu_evf_mgr_attach_fence (evf_mgr, bo); }
Christian König
maintainerQuoted 6 lines · Benjamin Cheng
If the eviction fence restore gets triggered while a BO unmap is happening, the attempt to lock the BO for restore will fail. On retry,
drm_execlocks the contended BO first, but it is not actually required to be locked, and the eviction fence should not be attached to such a BO.
Quoted 7 lines
If the BO was freed, this extra lock will cause
BUG_ONto fire indma_resv_add_fence, since the gem object and its resv lists are freed already.
drm_exec::prelockedremains set only if the object was locked on retry but not actually requested to be locked, so use that to detect this case and skip it.
Vitaly and I already found the real root cause for this and I'm about to push the fix to amd-staging-drm-next.
Regards,
Christian.
Quoted 22 lines
Fixes 2cd7284ba54b ("drm/amdgpu: completely rework eviction fence handling v2")Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c +4
-0@@ -145,6 +145,10 @@ int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr,/* And add it to all existing BOs */ drm_exec_for_each_locked_object (exec, index, obj) {struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); +/* A BO may be locked after it has been dropped from the VM due +* to how drm_exec treats contention. */ +if (obj == exec->prelocked) +continue ;amdgpu_evf_mgr_attach_fence (evf_mgr, bo); }
Quoted 7 lines · Christian König
Quoted 6 lines · Benjamin Cheng
If the eviction fence restore gets triggered while a BO unmap is happening, the attempt to lock the BO for restore will fail. On retry,
drm_execlocks the contended BO first, but it is not actually required to be locked, and the eviction fence should not be attached to such a BO.
Quoted 8 lines
Quoted 7 lines
If the BO was freed, this extra lock will cause
BUG_ONto fire indma_resv_add_fence, since the gem object and its resv lists are freed already.
drm_exec::prelockedremains set only if the object was locked on retry but not actually requested to be locked, so use that to detect this case and skip it.Vitaly and I already found the real root cause for this and I'm about to push the fix to amd-staging-drm-next.
Ah, thanks I did not see that one. Indeed the same issue.
Quoted 25 lines
Regards,
Christian.Quoted 21 lines
Fixes 2cd7284ba54b ("drm/amdgpu: completely rework eviction fence handling v2")Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c +4
-0@@ -145,6 +145,10 @@ int amdgpu_evf_mgr_rearm(struct amdgpu_eviction_fence_mgr *evf_mgr,/* And add it to all existing BOs */ drm_exec_for_each_locked_object (exec, index, obj) {struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); +/* A BO may be locked after it has been dropped from the VM due +* to how drm_exec treats contention. */ +if (obj == exec->prelocked) +continue ;amdgpu_evf_mgr_attach_fence (evf_mgr, bo); }