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
This commit is contained in:
Bjoern A. Zeeb 2024-09-12 21:17:51 +00:00
parent d2a55e6a93
commit a5c7b44d6a

View file

@ -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);
}