mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] efi/capsule: Replace kmap_atomic() with kmap_local_page()
@ 2026-09-02 20:13 Danish Khateeb
  2026-09-03  9:27 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Danish Khateeb @ 2026-09-02 20:13 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Ilias Apalodimas, linux-efi, linux-kernel, 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.

Build-tested only.

Assisted-by: LLM sparse
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
---
 drivers/firmware/efi/capsule.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c
index dd6252638..417e8f13a 100644
--- a/drivers/firmware/efi/capsule.c
+++ b/drivers/firmware/efi/capsule.c
@@ -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);
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] efi/capsule: Replace kmap_atomic() with kmap_local_page()
  2026-09-02 20:13 [PATCH] efi/capsule: Replace kmap_atomic() with kmap_local_page() Danish Khateeb
@ 2026-09-03  9:27 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2026-09-03  9:27 UTC (permalink / raw)
  To: Danish Khateeb; +Cc: Ilias Apalodimas, linux-efi, linux-kernel



On Wed, 2 Sep 2026, at 22:13, Danish Khateeb wrote:
> 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
> Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
> ---
>  drivers/firmware/efi/capsule.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Queued up in efi/next - thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-03  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 20:13 [PATCH] efi/capsule: Replace kmap_atomic() with kmap_local_page() Danish Khateeb
2026-09-03  9:27 ` Ard Biesheuvel

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®