All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arisa Snowbell" <arisa.snowbell@gmail.com>,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue
Date: Tue, 24 Nov 2026 16:14:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-231538@kernel.org> (raw)
In-Reply-To: <20261124130258.1270242-1-arisa.snowbell@gmail.com>

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 <arisa.snowbell@gmail.com>

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/20261124130258.1270242-1-arisa.snowbell@gmail.com?part=1

      parent reply	other threads:[~2026-11-24 16:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  2:32 [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Arisa Snowbell
2026-11-24  2:32 ` [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep Arisa Snowbell
2026-11-24  8:56   ` sashiko-bot
2026-11-24 10:43     ` Arisa Snowbell
2026-11-24 12:15 ` [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Christian König
2026-11-24 13:01   ` Arisa Snowbell
2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
2026-11-24 13:51   ` Arisa Snowbell
2026-11-24 14:14   ` [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep Arisa Snowbell
2026-11-24 14:16     ` Arisa Snowbell
2026-11-24 16:23     ` sashiko-bot
2026-11-24 16:14   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-231538@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arisa.snowbell@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.