Skip to contentSkip to conversation

efi/capsule: Replace kmap_atomic() with kmap_local_page()

PATCH Applied Danish Khateeb 2 participants 2 messages Sep 2 – Sep 3 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/capsule: Replace kmap_atomic() with kmap_local_page()

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

The conversion is safe here: the mapping is created and torn down within a single iteration of the sg_count loop, preserving the strict stack-based ordering that kmap_local_page() requires, and the mapped region is only written to, so neither pagefault_disable() nor preempt_disable() is needed. The surrounding code already sleeps (it allocates the pages with alloc_page(GFP_KERNEL) and later takes capsule_mutex), so there is no atomic context to preserve.

Build-tested only.

Assisted-by LLM sparse
---
 drivers/firmware/efi/capsule.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/efi/capsule.c +2 -2
index dd6252638..417e8f13a 100644
@@ -245,7 +245,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages)
 	for (i = 0; i < sg_count; i++) {
 		efi_capsule_block_desc_t *sglist;
 
-		sglist = kmap_atomic(sg_pages[i]);
+		sglist = kmap_local_page(sg_pages[i]);
 
 		for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) {
 			u64 sz = min_t(u64, imagesize,
@@ -277,7 +277,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages)
 		 */
 		efi_capsule_flush_cache_range(sglist, PAGE_SIZE);
 #endif
-		kunmap_atomic(sglist);
+		kunmap_local(sglist);
 	}
 
 	mutex_lock(&capsule_mutex);
Signature · 1 line
2.55.0
maintainer Applied
#1 lore raw
Quoted 11 lines · Danish Khateeb

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

The conversion is safe here: the mapping is created and torn down within a single iteration of the sg_count loop, preserving the strict stack-based ordering that kmap_local_page() requires, and the mapped region is only written to, so neither pagefault_disable() nor preempt_disable() is needed. The surrounding code already sleeps (it allocates the pages with alloc_page(GFP_KERNEL) and later takes capsule_mutex), so there is no atomic context to preserve.

Quoted 8 lines

Build-tested only.

Assisted-by LLM sparse
---
 drivers/firmware/efi/capsule.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Queued up in efi/next - thanks