Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/amdgpu/userq: race allowing resume_work after amdgpu_userq_suspend() [1] --
commit a80bb08812a1d7a481e2390eeabf02bdbae59d10 Author: Prike Liang <[email protected]> drm/amdgpu: only save VKMS modeset state if VKMS is initialized This commit introduces amdgpu_device_has_vkms() to verify that both enable_virtual_display and mode_config_initialized are set before saving and restoring VKMS modeset state during device suspend and resume. > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > index 7cf3a4cbac27c..9b0ef3ab5f53a 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c [ ... ] > @@ -4605,7 +4615,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool > notify_clients) > amdgpu_ras_suspend(adev); > > /* VKMS modeset state is saved here, never from the reset path */ > - if (adev->enable_virtual_display) { > + if (amdgpu_device_has_vkms(adev)) { > r = drm_mode_config_helper_suspend(dev); > if (r) > goto unwind_smartshift; [Severity: High] This problem wasn't introduced by this patch, but can amdgpu_device_suspend() leave uqm->resume_work scheduled after amdgpu_userq_suspend() returns [1]? During system suspend, amdgpu_userq_suspend() can race with amdgpu_eviction_fence_suspend_worker(): kworker CPU0 amdgpu_eviction_fence_suspend_worker() mutex_lock(&uq_mgr->userq_mutex) ... dma_fence_signal(ev_fence) amdgpu_device_prepare() amdgpu_device_suspend() amdgpu_userq_suspend() cancel_delayed_work_sync( &uqm->resume_work) schedule_delayed_work( &uq_mgr->resume_work, 0) mutex_unlock(&uq_mgr->userq_mutex) guard(mutex)(&uqm->userq_mutex) amdgpu_userq_unmap_helper() ... amdgpu_userq_restore_worker() <-- runs on suspended GPU amdgpu_eviction_fence_suspend_worker() signals ev_fence before queuing resume_work and releasing userq_mutex, while amdgpu_userq_suspend() calls cancel_delayed_work_sync(&uqm->resume_work) before taking userq_mutex and without flushing evf_mgr->suspend_work. In addition, amdgpu_device_suspend() calls amdgpu_userq_suspend() before amdgpu_device_evict_resources(): drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:amdgpu_device_suspend() { ... r = amdgpu_userq_suspend(adev); if (r) goto unwind_ip_phase1; r = amdgpu_device_evict_resources(adev); if (r) goto unwind_userq; ... } If ev_fence is still unsignaled at that point, evicting resources triggers evf_mgr->suspend_work, which schedules uqm->resume_work after amdgpu_userq_suspend() has already finished. In either case, amdgpu_userq_restore_worker() can run after TTM buffer functions, fence drivers and GPU IP blocks are suspended, causing failed page table updates, MES command timeouts or hardware access to a suspended device. [1] https://sashiko.dev/#/bug/linux-f4cce3e7-09c5-44f6-b753-c17f5780e3fb -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
