From: oushinnyo <oushinnyo@163.com>
To: amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, christian.koenig@amd.com,
Harish.Kasiviswanathan@amd.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, oushinnyo <oushinnyo@163.com>,
stable@vger.kernel.org
Subject: [PATCH v1] drm/amdgpu: keep freed VM mappings on clear failure
Date: Sat, 5 Sep 2026 10:31:51 +0800 [thread overview]
Message-ID: <20260905023151.90699-1-oushinnyo@163.com> (raw)
amdgpu_vm_clear_freed() removes a mapping from vm->freed before
clearing its page table entries. If amdgpu_vm_update_range() fails,
the mapping is currently freed even though the PTE update might not
have completed.
This is particularly problematic with CPU VM updates. Waiting for an
earlier submission is interruptible, so a signal can abort the wait
before any PTE is cleared. The old mapping then exists neither in the
VA tree nor on the freed list, allowing a later VM update to reuse the
virtual address while an earlier submission still references it.
Put the mapping back on vm->freed on every update error. This keeps the
pending clear operation alive and makes later VM updates retry it before
installing new PTEs. It also covers partial CPU or SDMA updates
conservatively.
Fixes: b4d42511b7f2 ("drm/amdgpu: Support page table update via CPU")
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5
Signed-off-by: oushinnyo <oushinnyo@163.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 47cde5459469..e20905d2d90c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1606,11 +1606,12 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
r = amdgpu_vm_update_range(adev, vm, false, false, true, false,
&sync, mapping->start, mapping->last,
0, 0, 0, NULL, NULL, &f);
- amdgpu_vm_free_mapping(adev, vm, mapping, f);
if (r) {
+ list_add(&mapping->list, &vm->freed);
dma_fence_put(f);
goto error_free;
}
+ amdgpu_vm_free_mapping(adev, vm, mapping, f);
}
if (fence && f) {
--
2.25.1
next reply other threads:[~2026-09-05 2:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 2:31 oushinnyo [this message]
2026-09-07 12:04 ` Christian König
[not found] ` <3efdfbf9.7999.1a09efb9469.Coremail.oushinnyo@163.com>
2026-09-14 18:04 ` Christian König
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=20260905023151.90699-1-oushinnyo@163.com \
--to=oushinnyo@163.com \
--cc=Harish.Kasiviswanathan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.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
all inboxes | Powered by JetHome®