Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/amdgpu/userq: missing resume_work flush in amdgpu_userq_query_status() --
commit dcee7ab7a079dac06e55c3b0a31589e130baf8e9 Author: Prike Liang <[email protected]> drm/amdgpu/userq: report invalid VA through the broken status flag This commit sets AMDGPU_USERQ_QUERY_STATUS_FLAGS_BROKEN in amdgpu_userq_query_status() when a usermode queue is in AMDGPU_USERQ_STATE_INVALID_VA, and updates the UAPI comment in amdgpu_drm.h. > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > index 496137fca1f0c..b48cf2a2118c0 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c > @@ -837,6 +837,7 @@ amdgpu_userq_query_status(struct drm_file *filp, union > drm_amdgpu_userq *args) > > args->out_qs.flags = 0; > if (queue->state == AMDGPU_USERQ_STATE_HUNG || > + queue->state == AMDGPU_USERQ_STATE_INVALID_VA || > queue->generation != amdgpu_vm_generation(adev, &fpriv->vm)) > args->out_qs.flags |= AMDGPU_USERQ_QUERY_STATUS_FLAGS_BROKEN; > amdgpu_userq_put(queue); [Severity: Medium] Can amdgpu_userq_query_status() miss AMDGPU_USERQ_STATE_INVALID_VA when called before uq_mgr->resume_work finishes? The only place that sets queue->state to AMDGPU_USERQ_STATE_INVALID_VA is amdgpu_userq_restore_all(), which runs asynchronously from uq_mgr->resume_work: CPU0 kworker amdgpu_gem_va_ioctl(UNMAP) amdgpu_userq_gem_va_unmap_validate() dma_resv_wait_timeout() amdgpu_eviction_fence_suspend_worker() amdgpu_userq_evict() queue->state = AMDGPU_USERQ_STATE_UNMAPPED dma_fence_signal(ev_fence) schedule_delayed_work( &uq_mgr->resume_work, 0) drm_exec_fini() amdgpu_userq_query_status() mutex_lock(&uq_mgr->userq_mutex) queue->state == AMDGPU_USERQ_STATE_UNMAPPED <-- BROKEN not set mutex_unlock(&uq_mgr->userq_mutex) amdgpu_userq_restore_worker() ... amdgpu_userq_restore_all() queue->state = AMDGPU_USERQ_STATE_INVALID_VA Because amdgpu_gem_va_ioctl() holds the VM reservation lock until drm_exec_fini() just before returning to userspace, uq_mgr->resume_work cannot finish validating the VM and calling amdgpu_userq_restore_all() before the unmap ioctl returns. Unlike amdgpu_userq_ensure_ev_fence(), amdgpu_userq_query_status() does not call flush_delayed_work(&uq_mgr->resume_work) before acquiring uq_mgr->userq_mutex, so querying queue status after unmapping a queue VA reports flags as 0 instead of AMDGPU_USERQ_QUERY_STATUS_FLAGS_BROKEN. Also, if a queue VA mapping is removed via AMDGPU_VA_OP_CLEAR or AMDGPU_VA_OP_REPLACE (amdgpu_vm_bo_clear_mappings()), amdgpu_userq_gem_va_unmap_validate() is never called to trigger eviction and transition the queue to AMDGPU_USERQ_STATE_INVALID_VA. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=3
