Bunch of patches to fix fence timeout cleanup
Subsystems (2)
v3 cover Bunch of patches to fix fence timeout cleanup
v2: add more fixes as suggested by christian and update some logging.
v3: patch no 4 in amdgpu_userq_wait_for_last_fence to remove signalled check.
Sunil Khatri (4):
drm/amdgpu/userq: dont check return value in amdgpu_userq_evict drm/amdgpu/userq: add the return code too in error condition drm/amdgpu/userq: call dma_resv_wait_timeout without test for
signalled
drm/amdgpu/userq: use dma_fence_wait_timeout without test for
signalled
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 60 +++++++++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +- 2 files changed, 24 insertions(+), 40 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/4 drm/amdgpu/userq: dont check return value in amdgpu_userq_evict
In function amdgpu_userq_evict we do not need to check for return values and print errors as we are already print error in all the functions of amdgpu_userq_evict.
a. amdgpu_userq_wait_for_signal: Could timeout and we print
error message in the function already
b. amdgpu_userq_evict_all: We unmap all the queues here and
in case of unmap failure we already print unmap error.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +8 -15
@@ -1258,7 +1258,7 @@ amdgpu_userq_evict_all(struct amdgpu_userq_mgr *uq_mgr) }if (ret) -drm_file_err (uq_mgr->file,"Couldn't unmap all the queues\n" ); +drm_file_err (uq_mgr->file,"Couldn't unmap all the queues, eviction failed\n" );return ret; }
@@ -1289,12 +1289,13 @@ amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr)xa_for_each (&uq_mgr->userq_xa, queue_id, queue) {struct dma_fence *f = queue->last_fence; -if (!f ||dma_fence_is_signaled (f)) +if (!f)continue ; - ret =dma_fence_wait_timeout (f, true,msecs_to_jiffies (100 )); + ret =dma_fence_wait_timeout (f, false,MAX_SCHEDULE_TIMEOUT );if (ret <=0 ) { -drm_file_err (uq_mgr->file,"Timed out waiting for fence=%llu:%llu\n" , +drm_file_err (uq_mgr->file, +"Timed out in wait_for_signal fence=%llu:%llu\n" , f->context, f->seqno);return -ETIMEDOUT ;
@@ -1307,18 +1308,10 @@ amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr)void amdgpu_userq_evict (struct amdgpu_userq_mgr *uq_mgr) { -struct amdgpu_device *adev = uq_mgr->adev; -int ret; -/* Wait for any pending userqueue fence work to finish */ - ret =amdgpu_userq_wait_for_signal (uq_mgr); -if (ret) -dev_err (adev->dev,"Not evicting userqueue, timeout waiting for work\n" ); - - ret =amdgpu_userq_evict_all (uq_mgr); -if (ret) -dev_err (adev->dev,"Failed to evict userqueue\n" ); - +amdgpu_userq_wait_for_signal (uq_mgr); +/* unmaps all the queues */ +amdgpu_userq_evict_all (uq_mgr); } int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,
Signature · 1 line
2.34.1
PATCH v3 2/4 drm/amdgpu/userq: add the return code too in error condition
In reply to Sunil KhatriIn function amdgpu_userq_restore
a. amdgpu_userq_vm_validate: add return code in error condition b. amdgpu_userq_restore_all: It already prints the error log, just
update the erorr log in the function and remove it from caller.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +3 -5
@@ -1023,7 +1023,7 @@ amdgpu_userq_restore_all(struct amdgpu_userq_mgr *uq_mgr)mutex_unlock (&uq_mgr->userq_mutex);if (ret) -drm_file_err (uq_mgr->file,"Failed to map all the queues\n" ); +drm_file_err (uq_mgr->file,"Failed to map all the queues, restore failed ret=%d\n" , ret);return ret; }
@@ -1230,13 +1230,11 @@ static void amdgpu_userq_restore_worker(struct work_struct *work) ret =amdgpu_userq_vm_validate (uq_mgr);if (ret) { -drm_file_err (uq_mgr->file,"Failed to validate BOs to restore\n" ); +drm_file_err (uq_mgr->file,"Failed to validate BOs to restore ret=%d\n" , ret); goto put_fence; } - ret =amdgpu_userq_restore_all (uq_mgr); -if (ret) -drm_file_err (uq_mgr->file,"Failed to restore all queues\n" ); +amdgpu_userq_restore_all (uq_mgr); put_fence:dma_fence_put (ev_fence);
Signature · 1 line
2.34.1
PATCH v3 3/4 drm/amdgpu/userq: call dma_resv_wait_timeout without test for signalled
In reply to Sunil KhatriIn function amdgpu_userq_gem_va_unmap_validate call dma_resv_wait_timeout directly.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 11 ++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +--- 2 files changed, 3 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -9
@@ -1478,7 +1478,6 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,u32 ip_mask =amdgpu_userq_get_supported_ip_mask (adev);struct amdgpu_bo_va *bo_va = mapping->bo_va;struct dma_resv *resv = bo_va->base.bo->tbo.base.resv; -int ret =0 ;if (!ip_mask)return 0 ;
@@ -1492,14 +1491,8 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,* unmap is only for one kind of userq VAs, so at this point suppose * the eviction fence is always unsignaled. */ -if (!dma_resv_test_signaled (resv,DMA_RESV_USAGE_BOOKKEEP )) { - ret =dma_resv_wait_timeout (resv,DMA_RESV_USAGE_BOOKKEEP , true, -MAX_SCHEDULE_TIMEOUT ); -if (ret <=0 ) -return -EBUSY ; - } - -return 0 ; +return dma_resv_wait_timeout (resv,DMA_RESV_USAGE_BOOKKEEP , + true,MAX_SCHEDULE_TIMEOUT ); }void amdgpu_userq_pre_reset (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -3
@@ -1978,7 +1978,6 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,struct amdgpu_bo_va_mapping *mapping;struct amdgpu_vm *vm = bo_va->base.vm;bool valid = true; -int r; saddr /=AMDGPU_GPU_PAGE_SIZE ;
@@ -2004,8 +2003,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,* from user space. */ if (unlikely (atomic_read (&bo_va->userq_va_mapped) >0 )) { - r =amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr); -if (unlikely (r == -EBUSY )) +if (amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr))dev_warn_once (adev->dev,"Attempt to unmap an active userq buffer\n" ); }
Signature · 1 line
2.34.1
PATCH v3 4/4 drm/amdgpu/userq: use dma_fence_wait_timeout without test for signalled
In reply to Sunil KhatriIn function amdgpu_userq_wait_for_last_fence use dma_fence_wait_timeout directly instead of checking for signalled fence first.
Return dma_fence_wait_timeout return value. Also update the fence timeout log to differentiate where fence timedout.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +10 -8
@@ -433,14 +433,16 @@ static int amdgpu_userq_wait_for_last_fence(struct amdgpu_usermode_queue *queue)struct dma_fence *f = queue->last_fence;int ret =0 ; -if (f && !dma_fence_is_signaled (f)) { - ret =dma_fence_wait_timeout (f, true,MAX_SCHEDULE_TIMEOUT ); -if (ret <=0 ) { -drm_file_err (uq_mgr->file,"Timed out waiting for fence=%llu:%llu\n" , - f->context, f->seqno); - queue->state =AMDGPU_USERQ_STATE_HUNG ; -return -ETIME ; - } +if (!f) +return 0 ; + + ret =dma_fence_wait_timeout (f, true,MAX_SCHEDULE_TIMEOUT ); +if (ret <=0 ) { +drm_file_err (uq_mgr->file, +"Timed out in wait_for_last_fence fence=%llu:%llu\n" , + f->context, f->seqno); + queue->state =AMDGPU_USERQ_STATE_HUNG ; +return -ETIMEDOUT ; }return ret;
Signature · 1 line
2.34.1