Module Name:    src
Committed By:   mrg
Date:           Sun Mar 25 03:51:33 UTC 2012

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

Log Message:
replace splhigh() usage with an IPL_HIGH mutex.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc64/dev/iommuvar.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.106 src/sys/arch/sparc64/dev/iommu.c:1.107
--- src/sys/arch/sparc64/dev/iommu.c:1.106	Fri Jan 27 18:53:03 2012
+++ src/sys/arch/sparc64/dev/iommu.c	Sun Mar 25 03:51:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.106 2012/01/27 18:53:03 para Exp $	*/
+/*	$NetBSD: iommu.c,v 1.107 2012/03/25 03:51:33 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.106 2012/01/27 18:53:03 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.107 2012/03/25 03:51:33 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -203,6 +203,8 @@ iommu_init(char *name, struct iommu_stat
 	    0, 0, EX_NOWAIT);
 	/* XXXMRG Check is_dvmamap is valid. */
 
+	mutex_init(&is->is_lock, MUTEX_DEFAULT, IPL_HIGH);
+
 	/*
 	 * Set the TSB size.  The relevant bits were moved to the TSB
 	 * base register in the PCIe host bridges.
@@ -456,7 +458,6 @@ iommu_dvmamap_load(bus_dma_tag_t t, bus_
 {
 	struct strbuf_ctl *sb = (struct strbuf_ctl *)map->_dm_cookie;
 	struct iommu_state *is = sb->sb_is;
-	int s;
 	int err, needsflush;
 	bus_size_t sgsize;
 	paddr_t curaddr;
@@ -503,11 +504,11 @@ iommu_dvmamap_load(bus_dma_tag_t t, bus_
 	 * split the transfer up int little pieces ourselves.
 	 */
 	KASSERT(is->is_dvmamap);
-	s = splhigh();
+	mutex_enter(&is->is_lock);
 	err = extent_alloc(is->is_dvmamap, sgsize, align,
 	    (sgsize > boundary) ? 0 : boundary,
 	    EX_NOWAIT|EX_BOUNDZERO, &dvmaddr);
-	splx(s);
+	mutex_exit(&is->is_lock);
 
 #ifdef DEBUG
 	if (err || (dvmaddr == (u_long)-1)) {
@@ -555,12 +556,12 @@ iommu_dvmamap_load(bus_dma_tag_t t, bus_
 			/* Too many segments.  Fail the operation. */
 			DPRINTF(IDB_INFO, ("iommu_dvmamap_load: "
 			    "too many segments %d\n", seg));
-			s = splhigh();
+			mutex_enter(&is->is_lock);
 			err = extent_free(is->is_dvmamap,
 			    dvmaddr, sgsize, EX_NOWAIT);
 			map->_dm_dvmastart = 0;
 			map->_dm_dvmasize = 0;
-			splx(s);
+			mutex_exit(&is->is_lock);
 			if (err != 0)
 				printf("warning: %s: %" PRId64
 				    " of DVMA space lost\n", __func__, sgsize);
@@ -647,7 +648,7 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bu
 {
 	struct strbuf_ctl *sb = (struct strbuf_ctl *)map->_dm_cookie;
 	struct iommu_state *is = sb->sb_is;
-	int error, s;
+	int error;
 	bus_size_t sgsize = map->_dm_dvmasize;
 
 	/* Flush the iommu */
@@ -664,12 +665,12 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bu
 	/* Flush the caches */
 	bus_dmamap_unload(t->_parent, map);
 
-	s = splhigh();
+	mutex_enter(&is->is_lock);
 	error = extent_free(is->is_dvmamap, map->_dm_dvmastart,
 		map->_dm_dvmasize, EX_NOWAIT);
 	map->_dm_dvmastart = 0;
 	map->_dm_dvmasize = 0;
-	splx(s);
+	mutex_exit(&is->is_lock);
 	if (error != 0)
 		printf("warning: %s: %" PRId64 " of DVMA space lost\n",
 		    __func__, sgsize);
@@ -685,7 +686,7 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, 
 	struct strbuf_ctl *sb = (struct strbuf_ctl *)map->_dm_cookie;
 	struct iommu_state *is = sb->sb_is;
 	struct vm_page *pg;
-	int i, j, s;
+	int i, j;
 	int left;
 	int err, needsflush;
 	bus_size_t sgsize;
@@ -734,7 +735,7 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, 
 	}
 	sgsize = round_page(sgsize);
 
-	s = splhigh();
+	mutex_enter(&is->is_lock);
 	/*
 	 * If our segment size is larger than the boundary we need to
 	 * split the transfer up into little pieces ourselves.
@@ -743,7 +744,7 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, 
 		(sgsize > boundary) ? 0 : boundary,
 		((flags & BUS_DMA_NOWAIT) == 0 ? EX_WAITOK : EX_NOWAIT) |
 		EX_BOUNDZERO, &dvmaddr);
-	splx(s);
+	mutex_exit(&is->is_lock);
 
 	if (err != 0)
 		return (err);
@@ -976,12 +977,12 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, 
 	return (0);
 
 fail:
-	s = splhigh();
+	mutex_enter(&is->is_lock);
 	err = extent_free(is->is_dvmamap, map->_dm_dvmastart, sgsize,
 	    EX_NOWAIT);
 	map->_dm_dvmastart = 0;
 	map->_dm_dvmasize = 0;
-	splx(s);
+	mutex_exit(&is->is_lock);
 	if (err != 0)
 		printf("warning: %s: %" PRId64 " of DVMA space lost\n",
 		    __func__, sgsize);

Index: src/sys/arch/sparc64/dev/iommuvar.h
diff -u src/sys/arch/sparc64/dev/iommuvar.h:1.20 src/sys/arch/sparc64/dev/iommuvar.h:1.21
--- src/sys/arch/sparc64/dev/iommuvar.h:1.20	Sun Mar 20 20:47:10 2011
+++ src/sys/arch/sparc64/dev/iommuvar.h	Sun Mar 25 03:51:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommuvar.h,v 1.20 2011/03/20 20:47:10 mrg Exp $	*/
+/*	$NetBSD: iommuvar.h,v 1.21 2012/03/25 03:51:33 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -55,6 +55,7 @@ struct iommu_state {
 	u_int			is_dvmaend;
 	int64_t			is_cr;		/* IOMMU control regiter value */
 	struct extent		*is_dvmamap;	/* DVMA map for this instance */
+	kmutex_t		is_lock;	/* lock for DVMA map */
 	int			is_flags;
 #define IOMMU_FLUSH_CACHE	0x00000001
 #define IOMMU_TSBSIZE_IN_PTSB	0x00000002	/* PCIe */

Reply via email to