Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu/userq: system_freezable_wq is not frozen during
  hibernation dpm_prepare()
--

commit f10cd6c65f3801c912d63876fd1a81a692e96c5a
Author: Arisa Snowbell <[email protected]>

drm/amdgpu/userq: keep the restore worker out of system sleep

This commit moves the user queue restore worker (resume_work) to
system_freezable_wq and skips mapping evicted queues in
amdgpu_userq_resume(), queuing the restore worker for them instead.

> 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]
Can uq_mgr->resume_work still run during amdgpu_device_prepare() on the
hibernation (S4) path?

In hibernate(), freeze_processes() passes user_only = true to
try_to_freeze_tasks(), which skips freeze_workqueues_begin().
hibernation_snapshot() then calls dpm_prepare(PMSG_FREEZE) before
freeze_kernel_threads() freezes freezable workqueues:

kernel/power/hibernate.c:hibernation_snapshot() {
        ...
        error = dpm_prepare(PMSG_FREEZE);
        if (error)
                goto Complete;

        /* Preallocate image memory before freezing kernel threads and shutting 
down devices. */
        error = hibernate_preallocate_memory();
        if (error)
                goto Complete;

        error = freeze_kernel_threads();
        ...
}

When amdgpu_pmops_prepare() -> amdgpu_device_prepare() ->
amdgpu_device_evict_resources() evicts a user queue BO during hibernation
prepare, system_freezable_wq is not frozen yet, so uq_mgr->resume_work
runs immediately and can still deadlock with ttm_bo_evict_first() on the
BO reservations or move evicted BOs back into VRAM before
freeze_kernel_threads() runs.

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to