Commit 24a3897c authored by Konstantin Belousov's avatar Konstantin Belousov
Browse files

x86 bounce_bus_dmamem_alloc(): use malloc_aligned() only when possible

malloc_domainset_aligned() requires that alignment is less than
page size. Fall back to other allocation methods, most likely
kmem_alloc_contig(), when malloc_aligned() cannot fullfill the driver

Reported by:	Loic F <>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:
parent 71d31f1c
......@@ -453,6 +453,7 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
* Allocate the buffer from the malloc(9) allocator if...
* - It's small enough to fit into a single page.
* - Its alignment requirement is also smaller than the page size.
* - The low address requirement is fulfilled.
* - Default cache attributes are requested (WB).
* else allocate non-contiguous pages if...
......@@ -467,6 +468,7 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
* Warn the user if malloc gets it wrong.
if (dmat->common.maxsize <= PAGE_SIZE &&
dmat->common.alignment <= PAGE_SIZE &&
dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) &&
*vaddr = malloc_domainset_aligned(dmat->common.maxsize,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment