diff options
author | jhb <jhb@FreeBSD.org> | 2012-08-17 14:14:25 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2012-08-17 14:14:25 +0000 |
commit | d521b77bda858157b90767c330e22f4946888bff (patch) | |
tree | f3b06e3dfc8e5bda650835609c975dc8a2250703 /sys/x86 | |
parent | 1bcd97d2397cc3de594cfeed003322c713a220d0 (diff) | |
download | FreeBSD-src-d521b77bda858157b90767c330e22f4946888bff.zip FreeBSD-src-d521b77bda858157b90767c330e22f4946888bff.tar.gz |
Allow static DMA allocations that allow for enough segments to do page-sized
segments for the entire allocation to use kmem_alloc_attr() to allocate
KVM rather than using kmem_alloc_contig(). This avoids requiring
a single physically contiguous chunk in this case.
Submitted by: Peter Jeremy (original version)
MFC after: 1 month
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/x86/busdma_machdep.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/x86/x86/busdma_machdep.c b/sys/x86/x86/busdma_machdep.c index 00f2e0b..ffa8807 100644 --- a/sys/x86/x86/busdma_machdep.c +++ b/sys/x86/x86/busdma_machdep.c @@ -533,13 +533,14 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem) && attr == VM_MEMATTR_DEFAULT) { *vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags); + } else if (dmat->nsegments >= btoc(dmat->maxsize) && + dmat->alignment <= PAGE_SIZE && + (dmat->boundary == 0 || dmat->boundary >= dmat->lowaddr)) { + /* Page-based multi-segment allocations allowed */ + *vaddr = (void *)kmem_alloc_attr(kernel_map, dmat->maxsize, + mflags, 0ul, dmat->lowaddr, attr); + *mapp = &contig_dmamap; } else { - /* - * XXX Use Contigmalloc until it is merged into this facility - * and handles multi-seg allocations. Nobody is doing - * multi-seg allocations yet though. - * XXX Certain AGP hardware does. - */ *vaddr = (void *)kmem_alloc_contig(kernel_map, dmat->maxsize, mflags, 0ul, dmat->lowaddr, dmat->alignment ? dmat->alignment : 1ul, dmat->boundary, attr); |