From: Philip Yang <Philip.Yang@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <Felix.Kuehling@amd.com>, Philip Yang <Philip.Yang@amd.com>,
"Felix Kuehling" <felix.kuehling@amd.com>
Subject: [PATCH v3 2/2] drm/amdkfd: Dequeue user queues when process mm released
Date: Mon, 20 Oct 2025 10:30:16 -0400 [thread overview]
Message-ID: <20251020143016.23409-2-Philip.Yang@amd.com> (raw)
In-Reply-To: <20251020143016.23409-1-Philip.Yang@amd.com>
Move kfd_process_dequeue_from_all_devices from kfd_process_wq_release to
mmu notifier release callback, do it earlier to ensure no system memory
access from GPU because the process memory is going to free from CPU
after mmu release notifier callback returns.
Suggested-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_process.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 849456ac498b..9080d23d22ae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1162,7 +1162,6 @@ static void kfd_process_wq_release(struct work_struct *work)
release_work);
struct dma_fence *ef;
- kfd_process_dequeue_from_all_devices(p);
pqm_uninit(&p->pqm);
/*
@@ -1226,6 +1225,13 @@ static void kfd_process_notifier_release_internal(struct kfd_process *p)
cancel_delayed_work_sync(&p->eviction_work);
cancel_delayed_work_sync(&p->restore_work);
+ /*
+ * Evict and remove user queues because exit_mmap free process memory,
+ * it is not safe for GPU to access system memory after mmu release
+ * notifier callback returns.
+ */
+ kfd_process_dequeue_from_all_devices(p);
+
for (i = 0; i < p->n_pdds; i++) {
struct kfd_process_device *pdd = p->pdds[i];
--
2.49.0
next prev parent reply other threads:[~2025-10-20 14:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 14:30 [PATCH v3 1/2] drm/amdkfd: Fix false positive queue buffer free warning Philip Yang
2025-10-20 14:30 ` Philip Yang [this message]
2025-10-20 15:59 ` Chen, Xiaogang
2025-10-20 16:24 ` Kim, Jonathan
2025-10-20 17:33 ` Chen, Xiaogang
2025-10-20 17:45 ` Kim, Jonathan
2025-10-20 17:51 ` Chen, Xiaogang
2025-10-20 16:34 ` Philip Yang
2025-10-20 17:29 ` Chen, Xiaogang
2025-10-22 18:13 ` Philip Yang
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=20251020143016.23409-2-Philip.Yang@amd.com \
--to=philip.yang@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox