contigmalloc() breaking Xorg

John Baldwin jhb at freebsd.org
Mon Aug 6 14:40:02 UTC 2012


On Thursday, July 12, 2012 8:26:05 am John Baldwin wrote:
> However, rather add a wiredmalloc(), I think you should just have 
> bus_dmamem_alloc() call kmem_alloc_attr() directly in this case.  One of the 
> things I've been meaning to add to bus_dma is a way to allocate other memory 
> types (e.g. WC memory), and in that case it would be best to just call 
> kmem_alloc_attr() directly instead.

After my recent changes, I think this would do the above.  What do you think of
this, and if it looks ok, can you test it?

Index: busdma_machdep.c
===================================================================
--- busdma_machdep.c	(revision 239020)
+++ busdma_machdep.c	(working copy)
@@ -533,13 +533,14 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr,
 	    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);

-- 
John Baldwin


More information about the freebsd-hackers mailing list