Module Name:    src
Committed By:   mrg
Date:           Wed Mar 16 05:49:44 UTC 2011

Modified Files:
        src/sys/arch/sparc64/dev: iommu.c iommureg.h iommuvar.h psycho.c
            psychoreg.h sbus.c sbusreg.h

Log Message:
revert the iommu changes for now.  my U60 doesn't like them.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/dev/iommureg.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc64/dev/iommuvar.h
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/sparc64/dev/psycho.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc64/dev/psychoreg.h
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/sparc64/dev/sbus.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/dev/sbusreg.h

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/sparc64/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.101 src/sys/arch/sparc64/dev/iommu.c:1.102
--- src/sys/arch/sparc64/dev/iommu.c:1.101	Wed Mar 16 02:41:19 2011
+++ src/sys/arch/sparc64/dev/iommu.c	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.101 2011/03/16 02:41:19 mrg Exp $	*/
+/*	$NetBSD: iommu.c,v 1.102 2011/03/16 05:49:43 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.101 2011/03/16 02:41:19 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.102 2011/03/16 05:49:43 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -134,7 +134,7 @@
 	 * be hard-wired, so we read the start and size from the PROM and
 	 * just use those values.
 	 */
-	is->is_cr = IOMMUCR_EN;
+	is->is_cr = (tsbsize << 16) | IOMMUCR_EN;
 	is->is_tsbsize = tsbsize;
 	if (iovabase == -1) {
 		is->is_dvmabase = IOTSB_VSTART(is->is_tsbsize);
@@ -172,7 +172,7 @@
 	memset(is->is_tsb, 0, size);
 
 #ifdef DEBUG
-	if ((iommudebug & IDB_INFO) && 0)
+	if (iommudebug & IDB_INFO)
 	{
 		/* Probe the iommu */
 
@@ -197,6 +197,11 @@
 #endif
 
 	/*
+	 * now actually start up the IOMMU
+	 */
+	iommu_reset(is);
+
+	/*
 	 * Now all the hardware's working we need to allocate a dvma map.
 	 */
 	aprint_debug("DVMA map: %x to %x\n",
@@ -209,20 +214,6 @@
 	    is->is_dvmabase, is->is_dvmaend,
 	    M_DEVBUF, 0, 0, EX_NOWAIT);
 	/* XXXMRG Check is_dvmamap is valid. */
-
-	/*
-	 * Set the TSB size.  The relevant bits were moved to the TSB
-	 * base register in the PCIe host bridges.
-	 */
-	if (strncmp(name, "pyro", 4) == 0)
-		is->is_ptsb |= is->is_tsbsize;
-	else
-		is->is_cr |= (is->is_tsbsize << 16);
-
-	/*
-	 * now actually start up the IOMMU
-	 */
-	iommu_reset(is);
 }
 
 /*
@@ -236,10 +227,13 @@
 	int i;
 	struct strbuf_ctl *sb;
 
-	IOMMUREG_WRITE(is, iommu_tsb, is->is_ptsb);
+	/* Need to do 64-bit stores */
+	bus_space_write_8(is->is_bustag, is->is_iommu, IOMMUREG(iommu_tsb),
+		is->is_ptsb);
 
 	/* Enable IOMMU in diagnostic mode */
-	IOMMUREG_WRITE(is, iommu_cr, is->is_cr|IOMMUCR_DE);
+	bus_space_write_8(is->is_bustag, is->is_iommu, IOMMUREG(iommu_cr),
+		is->is_cr|IOMMUCR_DE);
 
 	for (i = 0; i < 2; i++) {
 		if ((sb = is->is_sb[i])) {
@@ -248,8 +242,6 @@
 			bus_space_write_8(is->is_bustag, is->is_sb[i]->sb_sb,
 				STRBUFREG(strbuf_ctl), STRBUF_EN);
 
-			membar_lookaside();
-
 			/* No streaming buffers? Disable them */
 			if (bus_space_read_8(is->is_bustag,
 				is->is_sb[i]->sb_sb,
@@ -260,16 +252,12 @@
 				/*
 				 * locate the pa of the flush buffer.
 				 */
-				if (pmap_extract(pmap_kernel(),
-				     (vaddr_t)is->is_sb[i]->sb_flush,
-				     &is->is_sb[i]->sb_flushpa) == FALSE)
-					is->is_sb[i]->sb_flush = NULL;
+				(void)pmap_extract(pmap_kernel(),
+					(vaddr_t)is->is_sb[i]->sb_flush,
+					&is->is_sb[i]->sb_flushpa);
 			}
 		}
 	}
-
-	if (is->is_flags & IOMMU_FLUSH_CACHE)
-		IOMMUREG_WRITE(is, iommu_cache_invalidate, -1ULL);
 }
 
 /*
@@ -337,7 +325,6 @@
 void
 iommu_remove(struct iommu_state *is, vaddr_t va, size_t len)
 {
-	int slot;
 
 #ifdef DIAGNOSTIC
 	if (va < is->is_dvmabase || va > is->is_dvmaend)
@@ -376,15 +363,8 @@
 		is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)] &= ~IOTTE_V;
 		membar_storestore();
 #endif
-		IOMMUREG_WRITE(is, iommu_flush, va);
-
-		/* Flush cache if necessary. */
-		slot = IOTSBSLOT(trunc_page(va), is->is_tsbsize);
-		if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-		    (len == 0 || (slot % 8) == 7))
-			IOMMUREG_WRITE(is, iommu_cache_flush,
-			    is->is_ptsb + slot * 8);
-
+		bus_space_write_8(is->is_bustag, is->is_iommu,
+			IOMMUREG(iommu_flush), va);
 		va += PAGE_SIZE;
 	}
 }
@@ -473,7 +453,6 @@
 	vaddr_t vaddr = (vaddr_t)buf;
 	int seg;
 	struct pmap *pmap;
-	int slot;
 
 	if (map->dm_nsegs) {
 		/* Already in use?? */
@@ -510,7 +489,6 @@
 	 * If our segment size is larger than the boundary we need to
 	 * split the transfer up int little pieces ourselves.
 	 */
-	KASSERT(is->is_dvmamap);
 	s = splhigh();
 	err = extent_alloc(is->is_dvmamap, sgsize, align,
 	    (sgsize > boundary) ? 0 : boundary,
@@ -619,17 +597,9 @@
 		    flags | IOTTE_DEBUG(0x4000));
 		needsflush = 1;
 
+		dvmaddr += PAGE_SIZE;
 		vaddr += sgsize;
 		buflen -= sgsize;
-
-		/* Flush cache if necessary. */
-		slot = IOTSBSLOT(trunc_page(dvmaddr), is->is_tsbsize);
-		if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-		    (buflen <= 0 || (slot % 8) == 7))
-			IOMMUREG_WRITE(is, iommu_cache_flush,
-			    is->is_ptsb + slot * 8);
-
-		dvmaddr += PAGE_SIZE;
 	}
 	if (needsflush)
 		iommu_strbuf_flush_done(sb);
@@ -702,7 +672,6 @@
 	u_long dvmaddr, sgstart, sgend, bmask;
 	struct pglist *pglist;
 	const int pagesz = PAGE_SIZE;
-	int slot;
 #ifdef DEBUG
 	int npg = 0;
 #endif
@@ -872,15 +841,7 @@
 					    prev_pa = pa,
 					    flags | IOTTE_DEBUG(++npg << 12));
 					needsflush = 1;
-
-					/* Flush cache if necessary. */
-					slot = IOTSBSLOT(trunc_page(dvmaddr), is->is_tsbsize);
-					if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-					    ((dvmaddr + pagesz) > sgend || (slot % 8) == 7))
-						IOMMUREG_WRITE(is, iommu_cache_flush,
-						    is->is_ptsb + slot * 8);
 				}
-
 				dvmaddr += pagesz;
 				pa += pagesz;
 				last_va = dvmaddr;
@@ -951,16 +912,8 @@
 		iommu_enter(sb, dvmaddr, pa, flags | IOTTE_DEBUG(0x8000));
 		needsflush = 1;
 
-		sgsize -= pagesz;
-
-		/* Flush cache if necessary. */
-		slot = IOTSBSLOT(trunc_page(dvmaddr), is->is_tsbsize);
-		if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-		    (sgsize == 0 || (slot % 8) == 7))
-			IOMMUREG_WRITE(is, iommu_cache_flush,
-			    is->is_ptsb + slot * 8);
-
 		dvmaddr += pagesz;
+		sgsize -= pagesz;
 	}
 	if (needsflush)
 		iommu_strbuf_flush_done(sb);

Index: src/sys/arch/sparc64/dev/iommureg.h
diff -u src/sys/arch/sparc64/dev/iommureg.h:1.17 src/sys/arch/sparc64/dev/iommureg.h:1.18
--- src/sys/arch/sparc64/dev/iommureg.h:1.17	Wed Mar 16 03:49:53 2011
+++ src/sys/arch/sparc64/dev/iommureg.h	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommureg.h,v 1.17 2011/03/16 03:49:53 mrg Exp $	*/
+/*	$NetBSD: iommureg.h,v 1.18 2011/03/16 05:49:43 mrg Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -49,21 +49,10 @@
  */
 
 /* iommmu registers */
-struct iommureg_old {
-	volatile uint64_t	iommu_cr;	/* IOMMU control register */
-	volatile uint64_t	iommu_tsb;	/* IOMMU TSB base register */
-	volatile uint64_t	iommu_flush;	/* IOMMU flush register */
-};
-
 struct iommureg {
-	volatile uint64_t	iommu_cr;	/* IOMMU control register */
-	volatile uint64_t	iommu_tsb;	/* IOMMU TSB base register */
-	volatile uint64_t	iommu_flush;	/* IOMMU flush register */
-	volatile u_int64_t	iommu_ctxflush;
-	volatile u_int64_t	iommu_reserved[28];
-	volatile u_int64_t	iommu_cache_flush;
-	volatile u_int64_t	iommu_cache_invalidate;
-	volatile u_int64_t	iommu_reserved2[30];
+	uint64_t	iommu_cr;	/* IOMMU control register */
+	uint64_t	iommu_tsb;	/* IOMMU TSB base register */
+	uint64_t	iommu_flush;	/* IOMMU flush register */
 };
 
 /* streaming buffer registers */
@@ -75,7 +64,6 @@
 
 #define	IOMMUREG(x)	(offsetof(struct iommureg, x))
 #define	STRBUFREG(x)	(offsetof(struct iommu_strbuf, x))
-
 /* streaming buffer control register */
 #define STRBUF_EN	0x000000000000000001LL
 #define STRBUF_D	0x000000000000000002LL

Index: src/sys/arch/sparc64/dev/iommuvar.h
diff -u src/sys/arch/sparc64/dev/iommuvar.h:1.18 src/sys/arch/sparc64/dev/iommuvar.h:1.19
--- src/sys/arch/sparc64/dev/iommuvar.h:1.18	Wed Mar 16 02:41:19 2011
+++ src/sys/arch/sparc64/dev/iommuvar.h	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommuvar.h,v 1.18 2011/03/16 02:41:19 mrg Exp $	*/
+/*	$NetBSD: iommuvar.h,v 1.19 2011/03/16 05:49:43 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -55,8 +55,6 @@
 	u_int			is_dvmaend;
 	int64_t			is_cr;		/* IOMMU control regiter value */
 	struct extent		*is_dvmamap;	/* DVMA map for this instance */
-	int			is_flags;
-#define IOMMU_FLUSH_CACHE	0x00000001
 
 	struct strbuf_ctl	*is_sb[2];	/* Streaming buffers if any */
 
@@ -86,15 +84,4 @@
 		void **, int);
 void	iommu_dvmamem_unmap(bus_dma_tag_t, void *, size_t);
 
-#define IOMMUREG_READ(is, reg)				\
-	bus_space_read_8((is)->is_bustag,		\
-		(is)->is_iommu,				\
-		IOMMUREG(reg))	
-
-#define IOMMUREG_WRITE(is, reg, v)			\
-	bus_space_write_8((is)->is_bustag,		\
-		(is)->is_iommu,				\
-		IOMMUREG(reg),				\
-		(v))
-
 #endif /* _SPARC64_DEV_IOMMUVAR_H_ */

Index: src/sys/arch/sparc64/dev/psycho.c
diff -u src/sys/arch/sparc64/dev/psycho.c:1.103 src/sys/arch/sparc64/dev/psycho.c:1.104
--- src/sys/arch/sparc64/dev/psycho.c:1.103	Wed Mar 16 03:51:29 2011
+++ src/sys/arch/sparc64/dev/psycho.c	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: psycho.c,v 1.103 2011/03/16 03:51:29 mrg Exp $	*/
+/*	$NetBSD: psycho.c,v 1.104 2011/03/16 05:49:43 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.103 2011/03/16 03:51:29 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.104 2011/03/16 05:49:43 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -996,7 +996,7 @@
 	is->is_bustag = sc->sc_bustag;
 	bus_space_subregion(sc->sc_bustag, sc->sc_bh,
 		offsetof(struct psychoreg, psy_iommu),
-		sizeof (struct iommureg_old),
+		sizeof (struct iommureg),
 		&is->is_iommu);
 
 	/*

Index: src/sys/arch/sparc64/dev/psychoreg.h
diff -u src/sys/arch/sparc64/dev/psychoreg.h:1.16 src/sys/arch/sparc64/dev/psychoreg.h:1.17
--- src/sys/arch/sparc64/dev/psychoreg.h:1.16	Wed Mar 16 03:51:29 2011
+++ src/sys/arch/sparc64/dev/psychoreg.h	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: psychoreg.h,v 1.16 2011/03/16 03:51:29 mrg Exp $ */
+/*	$NetBSD: psychoreg.h,v 1.17 2011/03/16 05:49:43 mrg Exp $ */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -110,7 +110,7 @@
 
 	uint64_t	pad2[30];
 
-	struct iommureg_old psy_iommu;						/* 1fe.0000.0200,0210 */
+	struct iommureg psy_iommu;							/* 1fe.0000.0200,0210 */
 
 	uint64_t	pad3[317];
 

Index: src/sys/arch/sparc64/dev/sbus.c
diff -u src/sys/arch/sparc64/dev/sbus.c:1.86 src/sys/arch/sparc64/dev/sbus.c:1.87
--- src/sys/arch/sparc64/dev/sbus.c:1.86	Wed Mar 16 03:51:29 2011
+++ src/sys/arch/sparc64/dev/sbus.c	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbus.c,v 1.86 2011/03/16 03:51:29 mrg Exp $ */
+/*	$NetBSD: sbus.c,v 1.87 2011/03/16 05:49:43 mrg Exp $ */
 
 /*
  * Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.86 2011/03/16 03:51:29 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.87 2011/03/16 05:49:43 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -234,7 +234,7 @@
 	sc->sc_is.is_bustag = sc->sc_bustag;
 	bus_space_subregion(sc->sc_bustag, sc->sc_bh, 
 		(vaddr_t)&((struct sysioreg *)NULL)->sys_iommu, 
-		sizeof (struct iommureg_old), &sc->sc_is.is_iommu);
+		sizeof (struct iommureg), &sc->sc_is.is_iommu);
  
 	/* initialize our strbuf_ctl */
 	sc->sc_is.is_sb[0] = &sc->sc_sb;

Index: src/sys/arch/sparc64/dev/sbusreg.h
diff -u src/sys/arch/sparc64/dev/sbusreg.h:1.9 src/sys/arch/sparc64/dev/sbusreg.h:1.10
--- src/sys/arch/sparc64/dev/sbusreg.h:1.9	Wed Mar 16 03:51:29 2011
+++ src/sys/arch/sparc64/dev/sbusreg.h	Wed Mar 16 05:49:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbusreg.h,v 1.9 2011/03/16 03:51:29 mrg Exp $ */
+/*	$NetBSD: sbusreg.h,v 1.10 2011/03/16 05:49:43 mrg Exp $ */
 
 /*
  * Copyright (c) 1996-1999 Eduardo Horvath
@@ -94,7 +94,7 @@
 
 	uint64_t	pad3[117];
 
-	struct iommureg_old	sys_iommu;						/* 1fe.0000.2400,2410 */
+	struct iommureg sys_iommu;							/* 1fe.0000.2400,2410 */
 
 	uint64_t	pad4[125];
 

Reply via email to