Module Name:    src
Committed By:   matt
Date:           Sun Sep  6 22:58:59 UTC 2009

Modified Files:
        src/sys/arch/mips/mips [matt-nb5-mips64]: bus_dma.c

Log Message:
Don't refer to KSEG2 anymore.  If LP64 kernel, use XKPHYS for addresses
that don't fit in into KSEG0/KSEG1.


To generate a diff of this commit:
cvs rdiff -u -r1.22.16.2 -r1.22.16.3 src/sys/arch/mips/mips/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/mips/mips/bus_dma.c
diff -u src/sys/arch/mips/mips/bus_dma.c:1.22.16.2 src/sys/arch/mips/mips/bus_dma.c:1.22.16.3
--- src/sys/arch/mips/mips/bus_dma.c:1.22.16.2	Fri Aug 21 17:35:43 2009
+++ src/sys/arch/mips/mips/bus_dma.c	Sun Sep  6 22:58:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.22.16.2 2009/08/21 17:35:43 matt Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.22.16.3 2009/09/06 22:58:59 matt Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.22.16.2 2009/08/21 17:35:43 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.22.16.3 2009/09/06 22:58:59 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -263,9 +263,13 @@
 		 *
 		 * XXX Check TLB entries for cache-inhibit bits?
 		 */
-		if (buf >= (void *)MIPS_KSEG1_START &&
-		    buf < (void *)MIPS_KSEG2_START)
+		if (MIPS_KSEG1_P(buf))
 			map->_dm_flags |= MIPS_DMAMAP_COHERENT;
+#ifdef _LP64
+		else if (MIPS_XKPHYS_P((vaddr_t)buf)
+		    && MIPS_XKPHYS_TO_CCA((vaddr_t)buf) == CCA_UNCACHED)
+			map->_dm_flags |= MIPS_DMAMAP_COHERENT;
+#endif
 	}
 	return (error);
 }
@@ -652,6 +656,17 @@
 	 * TLB thrashing.
 	 */
 	if (nsegs == 1) {
+#ifdef _LP64
+		if (segs[0].ds_addr + segs[0].ds_len > MIPS_PHYS_MASK) {
+			unsigned long cca;
+			if (flags & BUS_DMA_COHERENT)
+				cca = CCA_UNCACHED;
+			else
+				cca = CCA_CACHEABLE;
+			*kvap = (void *)MIPS_PHYS_TO_XKPHYS(segs[0].ds_addr,
+			    cca);
+		} else
+#endif
 		if (flags & BUS_DMA_COHERENT)
 			*kvap = (void *)MIPS_PHYS_TO_KSEG1(segs[0].ds_addr);
 		else
@@ -699,11 +714,14 @@
 
 	/*
 	 * Nothing to do if we mapped it with KSEG0 or KSEG1 (i.e.
-	 * not in KSEG2).
+	 * not in KSEG2 or XKSEG).
 	 */
-	if (kva >= (void *)MIPS_KSEG0_START &&
-	    kva < (void *)MIPS_KSEG2_START)
+	if (MIPS_KSEG0_P(kva) || MIPS_KSEG1_P(kva))
 		return;
+#ifdef _LP64
+	if (MIPS_XKPHYS_P((vaddr_t)kva))
+		return;
+#endif
 
 	size = round_page(size);
 	pmap_remove(pmap_kernel(), (vaddr_t)kva, (vaddr_t)kva + size);

Reply via email to