All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: use set_page_dirty_lock() when unpinning userptr pages
@ 2026-09-02  2:50 Perry Yuan
  0 siblings, 0 replies; only message in thread
From: Perry Yuan @ 2026-09-02  2:50 UTC (permalink / raw)
  To: Alexander.Deucher, amd-gfx; +Cc: Christian.Koenig, Yifan1.Zhang, perry.yuan

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-02  2:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02  2:50 [PATCH] drm/amdgpu: use set_page_dirty_lock() when unpinning userptr pages Perry Yuan

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.