Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/amdgpu/userq: canceled resume_work leaves VM unvalidated in amdgpu_userq_resume() --
commit 5bc8d4302fb0871c6ac59bea95139558edabb658 Author: Arisa Snowbell <[email protected]> drm/amdgpu/userq: queue the restore worker on a freezable workqueue This commit moves the userqueue restore worker from system_wq to system_freezable_wq so it does not run concurrently with VRAM BO eviction during amdgpu_device_prepare(). > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c > index 2924f34da316a..358a6c8ce45f5 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c > @@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct > *work) > dma_fence_put(ev_fence); > > if (!evf_mgr->shutdown) > - schedule_delayed_work(&uq_mgr->resume_work, 0); > + queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, > 0); > > mutex_unlock(&uq_mgr->userq_mutex); > } [Severity: High] Does canceling uq_mgr->resume_work in amdgpu_userq_suspend() leave the process's VM unvalidated and its eviction fence signaled on resume? When amdgpu_device_prepare() evicts VRAM BOs, amdgpu_eviction_fence_suspend_worker() unmaps the user queues, signals ev_fence, and queues uq_mgr->resume_work on system_freezable_wq. Because system_freezable_wq is already frozen, uq_mgr->resume_work stays pending while the remaining BOs (including vm->root.bo and page tables) are evicted, and amdgpu_userq_suspend() then cancels it: drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:amdgpu_userq_suspend() { ... xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) { uqm = queue->userq_mgr; cancel_delayed_work_sync(&uqm->resume_work); ... } On resume, amdgpu_userq_resume() never re-queues uqm->resume_work or calls amdgpu_userq_vm_validate_and_restore_queue(): drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:amdgpu_userq_resume() { ... xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) { uqm = queue->userq_mgr; guard(mutex)(&uqm->userq_mutex); if (adev->in_s0ix) r = amdgpu_userq_restore_helper(queue); else r = amdgpu_userq_map_helper(queue); ... } For S3 and S4, amdgpu_userq_map_helper() maps the queue in MES while the VM BOs and page tables are still evicted and ev_fence remains signaled, causing GPU page faults or MES mapping failures. In addition, because amdgpu_userq_map_helper() sets queue->state to AMDGPU_USERQ_STATE_MAPPED, a later resume_work run that moves vm->root.bo back to VRAM will see queue->state != AMDGPU_USERQ_STATE_UNMAPPED and skip updating MES with the new page table base address. For dGPU S0ix, queue->state was already set to AMDGPU_USERQ_STATE_UNMAPPED during amdgpu_device_prepare(), so amdgpu_userq_restore_helper() (which only restores AMDGPU_USERQ_STATE_PREEMPTED queues) is a no-op and the queue stays unmapped. -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
