Module Name:    src
Committed By:   mrg
Date:           Sat Feb  9 11:27:06 UTC 2019

Modified Files:
        src/sys/arch/sparc64/dev: iommu.c iommuvar.h schizo.c

Log Message:
on tomatillo unload the map before flushing the iommu, instead of
the reverse.  from opensolaris.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sparc64/dev/iommuvar.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/sparc64/dev/schizo.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/sparc64/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.114 src/sys/arch/sparc64/dev/iommu.c:1.115
--- src/sys/arch/sparc64/dev/iommu.c:1.114	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sparc64/dev/iommu.c	Sat Feb  9 11:27:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.114 2018/09/03 16:29:27 riastradh Exp $	*/
+/*	$NetBSD: iommu.c,v 1.115 2019/02/09 11:27:05 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.114 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.115 2019/02/09 11:27:05 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -748,10 +748,21 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bu
 	/* Flush the iommu */
 	if (!map->_dm_dvmastart)
 		panic("%s: error dvmastart is zero!\n", __func__);
-	iommu_remove(is, map->_dm_dvmastart, map->_dm_dvmasize);
 
-	/* Flush the caches */
-	bus_dmamap_unload(t->_parent, map);
+	if (is->is_flags & IOMMU_SYNC_BEFORE_UNMAP) {
+
+		/* Flush the caches */
+		bus_dmamap_unload(t->_parent, map);
+
+		iommu_remove(is, map->_dm_dvmastart, map->_dm_dvmasize);
+
+	} else {
+
+		iommu_remove(is, map->_dm_dvmastart, map->_dm_dvmasize);
+
+		/* Flush the caches */
+		bus_dmamap_unload(t->_parent, map);
+	}
 
 	mutex_enter(&is->is_lock);
 	error = extent_free(is->is_dvmamap, map->_dm_dvmastart,

Index: src/sys/arch/sparc64/dev/iommuvar.h
diff -u src/sys/arch/sparc64/dev/iommuvar.h:1.22 src/sys/arch/sparc64/dev/iommuvar.h:1.23
--- src/sys/arch/sparc64/dev/iommuvar.h:1.22	Thu Sep  3 19:43:35 2015
+++ src/sys/arch/sparc64/dev/iommuvar.h	Sat Feb  9 11:27:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommuvar.h,v 1.22 2015/09/03 19:43:35 palle Exp $	*/
+/*	$NetBSD: iommuvar.h,v 1.23 2019/02/09 11:27:05 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -59,6 +59,7 @@ struct iommu_state {
 	int			is_flags;
 #define IOMMU_FLUSH_CACHE	0x00000001
 #define IOMMU_TSBSIZE_IN_PTSB	0x00000002	/* PCIe */
+#define IOMMU_SYNC_BEFORE_UNMAP	0x00000004
 
 	struct strbuf_ctl	*is_sb[2];	/* Streaming buffers if any */
 

Index: src/sys/arch/sparc64/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.40 src/sys/arch/sparc64/dev/schizo.c:1.41
--- src/sys/arch/sparc64/dev/schizo.c:1.40	Tue Feb  5 06:10:53 2019
+++ src/sys/arch/sparc64/dev/schizo.c	Sat Feb  9 11:27:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.40 2019/02/05 06:10:53 mrg Exp $	*/
+/*	$NetBSD: schizo.c,v 1.41 2019/02/09 11:27:05 mrg Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.40 2019/02/05 06:10:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.41 2019/02/09 11:27:05 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -263,6 +263,8 @@ schizo_attach(device_t parent, device_t 
 	}
 
 	aprint_normal_dev(sc->sc_dev, " ");
+	if (sc->sc_tomatillo)
+		is->is_flags |= IOMMU_SYNC_BEFORE_UNMAP;
 	schizo_init_iommu(sc, pbm);
 
 	pbm->sp_memt = schizo_alloc_mem_tag(pbm);

Reply via email to