diff options
| author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2024-09-12 21:17:51 +0000 |
|---|---|---|
| committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2025-03-14 16:24:52 +0000 |
| commit | a5c7b44d6a46fc5a67a79cb9b31050a9cc7c50ce (patch) | |
| tree | 24901743f1c4130e19ad8478d2df40a84596bf4b | |
| parent | d2a55e6a9348bb55038dbc6b727ab041085f22db (diff) | |
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
MFC after: 3 days
Reviewed by: jhb, dumbbell
Differential Revision: https://reviews.freebsd.org/D46661
| -rw-r--r-- | sys/compat/linuxkpi/common/src/linux_page.c | 10 |
1 files 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 6ca926e89174..bece8c954bfd 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); } |
