Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2012 14:14:26 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239354 - head/sys/x86/x86
Message-ID:  <201208171414.q7HEEQl5079980@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Aug 17 14:14:25 2012
New Revision: 239354
URL: http://svn.freebsd.org/changeset/base/239354

Log:
  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

Modified:
  head/sys/x86/x86/busdma_machdep.c

Modified: head/sys/x86/x86/busdma_machdep.c
==============================================================================
--- head/sys/x86/x86/busdma_machdep.c	Fri Aug 17 05:51:46 2012	(r239353)
+++ head/sys/x86/x86/busdma_machdep.c	Fri Aug 17 14:14:25 2012	(r239354)
@@ -533,13 +533,14 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, voi
 	    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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208171414.q7HEEQl5079980>