[PATCH] drm/vmwgfx: Replace kmap_atomic() with kmap_local_page()

From: Danish Khateeb

Date: Thu Sep 03 2026 - 12:56:40 EST


kmap_atomic() is deprecated in favour of kmap_local_page(), as described
in Documentation/mm/highmem.rst.

The conversion is safe in vmw_mob_build_pt(): the mapping is created and
torn down within a single iteration of the pt_page loop, preserving the
strict stack-based ordering that kmap_local_page() requires. Between the
map and the unmap the code only writes page table entries through the
mapped address and calls the vmw_piter accessors, which are non-sleeping
array and scatterlist lookups, so neither pagefault_disable() nor
preempt_disable() is needed.

Reword the function comment to match. Avoiding TLB thrashing, the reason
given there for using temporary mappings, still applies.

Build-tested only.

Assisted-by: LLM sparse
Signed-off-by: Danish Khateeb <danishkhateeb03@xxxxxxxxx>
---
drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
index de7a504de..edc1ba5df 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
@@ -451,7 +451,7 @@ static void vmw_mob_assign_ppn(u32 **addr, dma_addr_t val)
* @pt_pages: Array of page pointers to the page table pages.
*
* Returns the number of page table pages actually used.
- * Uses atomic kmaps of highmem pages to avoid TLB thrashing.
+ * Uses local kmaps of highmem pages to avoid TLB thrashing.
*/
static unsigned long vmw_mob_build_pt(struct vmw_piter *data_iter,
unsigned long num_data_pages,
@@ -467,7 +467,7 @@ static unsigned long vmw_mob_build_pt(struct vmw_piter *data_iter,
for (pt_page = 0; pt_page < num_pt_pages; ++pt_page) {
page = vmw_piter_page(pt_iter);

- save_addr = addr = kmap_atomic(page);
+ save_addr = addr = kmap_local_page(page);

for (i = 0; i < PAGE_SIZE / VMW_PPN_SIZE; ++i) {
vmw_mob_assign_ppn(&addr,
@@ -476,7 +476,7 @@ static unsigned long vmw_mob_build_pt(struct vmw_piter *data_iter,
break;
WARN_ON(!vmw_piter_next(data_iter));
}
- kunmap_atomic(save_addr);
+ kunmap_local(save_addr);
vmw_piter_next(pt_iter);
}

--
2.55.0