git: 3494f4f5369d - stable/14 - LinuxKPI: always use contig allocations in linux_alloc_kmem()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Apr 2025 14:36:51 UTC
The branch stable/14 has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=3494f4f5369de2661c88f3217acbf8d5f0795780
commit 3494f4f5369de2661c88f3217acbf8d5f0795780
Author: Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-09-12 21:17:51 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-04-18 14:35:57 +0000
LinuxKPI: always use contig allocations in linux_alloc_kmem()
In linux_alloc_kmem() [used by *get_page*()] we always at least allocate
PAGE_SIZE and we want the allocation to be contiguous so it can be passed
to DMA. Always use kmem_alloc_contig() and only change the low argument
depending on the GFP_DMA32 flag being given or not.
Sponsored by: The FreeBSD Foundation
Reviewed by: jhb, dumbbell
Differential Revision: https://reviews.freebsd.org/D46661
(cherry picked from commit a5c7b44d6a46fc5a67a79cb9b31050a9cc7c50ce)
---
sys/compat/linuxkpi/common/src/linux_page.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index cc7683e3b572..99b63e8d5680 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -182,12 +182,10 @@ linux_alloc_kmem(gfp_t flags, unsigned int order)
size_t size = ((size_t)PAGE_SIZE) << order;
void *addr;
- if ((flags & GFP_DMA32) == 0) {
- addr = kmem_malloc(size, flags & GFP_NATIVE_MASK);
- } else {
- addr = kmem_alloc_contig(size, flags & GFP_NATIVE_MASK, 0,
- BUS_SPACE_MAXADDR_32BIT, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
- }
+ addr = kmem_alloc_contig(size, flags & GFP_NATIVE_MASK, 0,
+ ((flags & GFP_DMA32) == 0) ? -1UL : BUS_SPACE_MAXADDR_32BIT,
+ PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
+
return ((vm_offset_t)addr);
}