Module Name:    src
Committed By:   matt
Date:           Wed Jun  8 15:19:57 UTC 2011

Modified Files:
        src/sys/arch/powerpc/powerpc: bus_dma.c

Log Message:
A small speedup, when mapping memory in bus_dmamem_map, if the memory is
cacheable and is in a single segment (physically contiguous) don't bother
allocating KVA for it, just use the physical address as the VA.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/powerpc/powerpc/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/powerpc/bus_dma.c
diff -u src/sys/arch/powerpc/powerpc/bus_dma.c:1.38 src/sys/arch/powerpc/powerpc/bus_dma.c:1.39
--- src/sys/arch/powerpc/powerpc/bus_dma.c:1.38	Tue Jan 18 01:02:55 2011
+++ src/sys/arch/powerpc/powerpc/bus_dma.c	Wed Jun  8 15:19:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.38 2011/01/18 01:02:55 matt Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.39 2011/06/08 15:19:57 matt Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #define _POWERPC_BUS_DMA_PRIVATE
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.38 2011/01/18 01:02:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.39 2011/06/08 15:19:57 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -601,6 +601,19 @@
 
 	size = round_page(size);
 
+#ifdef PMAP_MAP_POOLPAGE
+	/*
+	 * If we are mapping a cacheable physically contiguous segment, treat
+	 * it as if we are mapping a poolpage and avoid consuming any KVAs.
+	 */
+	if (nsegs == 1 && (flags & BUS_DMA_NOCACHE) == 0) {
+		KASSERT(size == segs->ds_len);
+		addr = BUS_MEM_TO_PHYS(t, segs->ds_addr);
+		*kvap = (void *)PMAP_MAP_POOLPAGE(addr);
+		return 0;
+	}
+#endif
+
 	va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags);
 
 	if (va == 0)
@@ -639,16 +652,18 @@
 void
 _bus_dmamem_unmap(bus_dma_tag_t t, void *kva, size_t size)
 {
+	vaddr_t va = (vaddr_t) kva;
 
 #ifdef DIAGNOSTIC
-	if ((u_long)kva & PGOFSET)
+	if (va & PGOFSET)
 		panic("_bus_dmamem_unmap");
 #endif
 
-	size = round_page(size);
-
-	pmap_kremove((vaddr_t)kva, size);
-	uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY);
+	if (va >= VM_MIN_KERNEL_ADDRESS && va < VM_MAX_KERNEL_ADDRESS) {
+		size = round_page(size);
+		pmap_kremove(va, size);
+		uvm_km_free(kernel_map, va, size, UVM_KMF_VAONLY);
+	}
 }
 
 /*

Reply via email to