From: Perry Yuan <perry.yuan@amd.com>
To: <Alexander.Deucher@amd.com>, <amd-gfx@lists.freedesktop.org>
Cc: <Christian.Koenig@amd.com>, <Yifan1.Zhang@amd.com>, <perry.yuan@amd.com>
Subject: [PATCH] drm/amdgpu: use set_page_dirty_lock() when unpinning userptr pages
Date: Wed, 2 Sep 2026 10:50:47 +0800 [thread overview]
Message-ID: <20260902025047.698595-1-perry.yuan@amd.com> (raw)
amdgpu_ttm_tt_mark_user_pages() dirties pages obtained from
get_user_pages() while holding only a page reference - no page lock, no
page table lock. set_page_dirty() requires the caller to keep the folio
from being truncated, otherwise the address_space can be freed between
the folio_mapping() load and the ->dirty_folio() call.
Use set_page_dirty_lock(), which takes the folio lock around the update.
The upstream gup helper unpin_user_pages_dirty_lock() does the same for
this reason.
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 07f8854bc80c..4bc6ba074c23 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -971,8 +971,9 @@ void amdgpu_ttm_tt_mark_user_pages(struct ttm_tt *ttm)
if (!page)
continue;
+ /* The caller does not hold the page lock. */
if (!(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY))
- set_page_dirty(page);
+ set_page_dirty_lock(page);
mark_page_accessed(page);
}
--
2.34.1
reply other threads:[~2026-09-02 2:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260902025047.698595-1-perry.yuan@amd.com \
--to=perry.yuan@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Yifan1.Zhang@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;
as well as URLs for NNTP newsgroup(s).