changeset 5328:a4b7d8483567

6377121 virtual-dma property should be removed on attach failure. 6532510 system panic when vmem_xalloc cannot satisfy mandatory allocation during dr testing.
author danice
date Wed, 24 Oct 2007 19:08:06 -0700
parents 7341f36188f5
children 33cb98223b2d
files usr/src/uts/sun4/io/px/px_dma.c usr/src/uts/sun4/io/px/px_mmu.c usr/src/uts/sun4/io/px/px_space.c usr/src/uts/sun4/io/px/px_space.h usr/src/uts/sun4u/io/px/px_lib4u.c
diffstat 5 files changed, 38 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/sun4/io/px/px_dma.c	Wed Oct 24 17:40:39 2007 -0700
+++ b/usr/src/uts/sun4/io/px/px_dma.c	Wed Oct 24 19:08:06 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -1506,9 +1506,14 @@
 	uint64_t mask = ~(1ull << mmu_p->mmu_inst);
 	cmn_err(CE_NOTE, "PCI Express DVMA %p stat OFF", mmu_p);
 
-	kmem_free(mmu_p->dvma_alloc_rec, sz);
-	kmem_free(mmu_p->dvma_free_rec, sz);
-	mmu_p->dvma_alloc_rec = mmu_p->dvma_free_rec = NULL;
+	if (mmu_p->dvma_alloc_rec) {
+		kmem_free(mmu_p->dvma_alloc_rec, sz);
+		mmu_p->dvma_alloc_rec = NULL;
+	}
+	if (mmu_p->dvma_free_rec) {
+		kmem_free(mmu_p->dvma_free_rec, sz);
+		mmu_p->dvma_free_rec = NULL;
+	}
 
 	prev = mmu_p->dvma_active_list;
 	if (!prev)
--- a/usr/src/uts/sun4/io/px/px_mmu.c	Wed Oct 24 17:40:39 2007 -0700
+++ b/usr/src/uts/sun4/io/px/px_mmu.c	Wed Oct 24 19:08:06 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -44,7 +44,7 @@
 {
 	dev_info_t		*dip = px_p->px_dip;
 	px_mmu_t			*mmu_p;
-	uint32_t		base_pg_index, i = 0;
+	uint32_t		tsb_i = 0;
 	char			map_name[32];
 	px_dvma_range_prop_t	*dvma_prop;
 	int			dvma_prop_len;
@@ -114,16 +114,31 @@
 
 	mutex_init(&mmu_p->dvma_debug_lock, NULL, MUTEX_DRIVER, NULL);
 
-	base_pg_index = MMU_BTOP(mmu_p->mmu_dvma_end) - tsb_entries + 1;
-
-	for (i = 0; i < tsb_entries; i++) {
+	for (tsb_i = 0; tsb_i < tsb_entries; tsb_i++) {
 		r_addr_t ra = 0;
 		io_attributes_t attr;
 		caddr_t va;
 
-		if (px_lib_iommu_getmap(px_p->px_dip, PCI_TSBID(0, i),
-		    &attr, &ra) == DDI_SUCCESS) {
-			va = (caddr_t)(MMU_PTOB(base_pg_index + i));
+		if (px_lib_iommu_getmap(px_p->px_dip, PCI_TSBID(0, tsb_i),
+		    &attr, &ra) != DDI_SUCCESS)
+			continue;
+
+		va = (caddr_t)(MMU_PTOB(mmu_p->dvma_base_pg + tsb_i));
+
+		if (va <= (caddr_t)mmu_p->mmu_dvma_fast_end) {
+			uint32_t cache_i;
+
+			/*
+			 * the va is within the *fast* dvma range; therefore,
+			 * lock its fast dvma page cache cluster in order to
+			 * both preserve the TTE and prevent the use of this
+			 * fast dvma page cache cluster by px_dvma_map_fast().
+			 * the lock value 0xFF comes from ldstub().
+			 */
+			cache_i = tsb_i / px_dvma_page_cache_clustsz;
+			ASSERT(cache_i < px_dvma_page_cache_entries);
+			mmu_p->mmu_dvma_cache_locks[cache_i] = 0xFF;
+		} else {
 			(void) vmem_xalloc(mmu_p->mmu_dvma_map, MMU_PAGE_SIZE,
 			    MMU_PAGE_SIZE, 0, 0, va, va + MMU_PAGE_SIZE,
 			    VM_NOSLEEP | VM_BESTFIT | VM_PANIC);
--- a/usr/src/uts/sun4/io/px/px_space.c	Wed Oct 24 17:40:39 2007 -0700
+++ b/usr/src/uts/sun4/io/px/px_space.c	Wed Oct 24 19:08:06 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -141,13 +141,6 @@
 uint_t px_mmu_ctx_lock_failure = 0;
 
 /*
- * This flag preserves prom MMU settings by copying prom TSB entries
- * to corresponding kernel TSB entry locations. It should be removed
- * after the interface properties from obp have become default.
- */
-uint_t px_preserve_mmu_tsb = 1;
-
-/*
  * memory callback list id callback list for kmem_alloc failure clients
  */
 uintptr_t px_kmem_clid = 0;
--- a/usr/src/uts/sun4/io/px/px_space.h	Wed Oct 24 17:40:39 2007 -0700
+++ b/usr/src/uts/sun4/io/px/px_space.h	Wed Oct 24 19:08:06 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -93,7 +93,6 @@
 extern uint_t px_disable_fdvma;
 
 extern uint_t px_iommu_ctx_lock_failure;
-extern uint_t px_preserve_iommu_tsb;
 extern uintptr_t px_kmem_clid;
 
 /* timeout length in micro seconds */
--- a/usr/src/uts/sun4u/io/px/px_lib4u.c	Wed Oct 24 17:40:39 2007 -0700
+++ b/usr/src/uts/sun4u/io/px/px_lib4u.c	Wed Oct 24 19:08:06 2007 -0700
@@ -209,9 +209,9 @@
 	px_dvma_range.dvma_len = (uint32_t)
 	    px_mmu_dvma_end - px_dvma_range.dvma_base + 1;
 
-	(void) ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
-		"virtual-dma", (caddr_t)&px_dvma_range,
-		sizeof (px_dvma_range_prop_t));
+	(void) ddi_prop_update_int_array(DDI_DEV_T_NONE, dip,
+	    "virtual-dma", (int *)&px_dvma_range,
+	    sizeof (px_dvma_range_prop_t) / sizeof (int));
 	/*
 	 * Initilize all fire hardware specific blocks.
 	 */
@@ -294,6 +294,7 @@
 	px_lib_unmap_regs((pxu_t *)px_p->px_plat_p);
 	kmem_free(px_p->px_plat_p, sizeof (pxu_t));
 	px_p->px_plat_p = NULL;
+	(void) ddi_prop_remove(DDI_DEV_T_NONE, dip, "virtual-dma");
 
 	return (DDI_SUCCESS);
 }