PERFORCE change 98112 for review

George V. Neville-Neil gnn at FreeBSD.org
Mon May 29 22:49:16 PDT 2006


http://perforce.freebsd.org/chv.cgi?CH=98112

Change 98112 by gnn at fast_ipsec_integ on 2006/05/30 05:47:35

	Integrate from HEAD

Affected files ...

.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt.c#9 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt.h#10 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_cam.c#10 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_cam.h#3 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_debug.c#5 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_pci.c#7 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_raid.c#7 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_raid.h#3 integrate
.. //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_reg.h#4 integrate
.. //depot/projects/fast_ipsec/src/sys/kern/kern_exit.c#8 integrate
.. //depot/projects/fast_ipsec/src/sys/vm/vm_extern.h#3 integrate
.. //depot/projects/fast_ipsec/src/sys/vm/vm_glue.c#3 integrate
.. //depot/projects/fast_ipsec/src/sys/vm/vm_map.c#6 integrate
.. //depot/projects/fast_ipsec/src/sys/vm/vm_map.h#3 integrate
.. //depot/projects/fast_ipsec/src/sys/vm/vm_meter.c#2 integrate

Differences ...

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt.c#9 (text+ko) ====

@@ -57,6 +57,10 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 /*-
  * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
@@ -92,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt.c,v 1.29 2006/05/27 17:26:57 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt.c,v 1.30 2006/05/29 20:34:28 mjacob Exp $");
 
 #include <dev/mpt/mpt.h>
 #include <dev/mpt/mpt_cam.h> /* XXX For static handler registration */

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt.h#10 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/mpt/mpt.h,v 1.20 2006/05/27 17:26:57 mjacob Exp $ */
+/* $FreeBSD: src/sys/dev/mpt/mpt.h,v 1.22 2006/05/29 20:34:28 mjacob Exp $ */
 /*-
  * Generic defines for LSI '909 FC  adapters.
  * FreeBSD Version.
@@ -58,6 +58,10 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 /*
  * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
@@ -942,6 +946,7 @@
 	MPT_PRT_ERROR,
 	MPT_PRT_WARN,
 	MPT_PRT_INFO,
+	MPT_PRT_NEGOTIATION,
 	MPT_PRT_DEBUG,
 	MPT_PRT_DEBUG1,
 	MPT_PRT_DEBUG2,

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_cam.c#10 (text+ko) ====

@@ -57,6 +57,9 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 /*-
  * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
@@ -91,7 +94,7 @@
  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_cam.c,v 1.19 2006/05/27 17:26:57 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_cam.c,v 1.21 2006/05/29 20:34:28 mjacob Exp $");
 
 #include <dev/mpt/mpt.h>
 #include <dev/mpt/mpt_cam.h>
@@ -647,7 +650,7 @@
 static int
 mpt_set_initial_config_spi(struct mpt_softc *mpt)
 {
-	int i, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id;
+	int i, j, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id;
 	int error;
 
 	mpt->mpt_disc_enable = 0xff;
@@ -682,12 +685,17 @@
 	 * The purpose of this exercise is to get
 	 * all targets back to async/narrow.
 	 *
-	 * We skip this if the BIOS has already negotiated speeds with targets.
+	 * We skip this step if the BIOS has already negotiated
+	 * speeds with the targets and does not require us to
+	 * do Domain Validation.
 	 */
 	i = mpt->mpt_port_page2.PortSettings &
 	    MPI_SCSIPORTPAGE2_PORT_MASK_NEGO_MASTER_SETTINGS;
-	if (i == MPI_SCSIPORTPAGE2_PORT_ALL_MASTER_SETTINGS) {
-		mpt_lprt(mpt, /* MPT_PRT_INFO */ MPT_PRT_ALWAYS,
+	j = mpt->mpt_port_page2.PortFlags &
+	    MPI_SCSIPORTPAGE2_PORT_FLAGS_DV_MASK;
+	if (i == MPI_SCSIPORTPAGE2_PORT_ALL_MASTER_SETTINGS &&
+	    j == MPI_SCSIPORTPAGE2_PORT_FLAGS_OFF_DV) {
+		mpt_lprt(mpt, MPT_PRT_NEGOTIATION,
 		    "honoring BIOS transfer negotiations\n");
 		return (0);
 	}
@@ -2782,7 +2790,7 @@
 		uint8_t dval;
 		u_int period;
 		u_int offset;
-		int m;
+		int i, j;
 
 		cts = &ccb->cts;
 		if (!IS_CURRENT_SETTINGS(cts)) {
@@ -2790,27 +2798,37 @@
 			mpt_set_ccb_status(ccb, CAM_REQ_INVALID);
 			break;
 		}
+
 		if (mpt->is_fc || mpt->is_sas) {
 			mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 			break;
 		}
 
-		if (mpt->ioc_page2 && mpt->ioc_page2->MaxPhysDisks != 0 &&
-		    raid_passthru == 0) {
+		/*
+		 * Skip attempting settings on RAID volume disks.
+		 * Other devices on the bus get the normal treatment.
+		 */
+		if (mpt->phydisk_sim && raid_passthru == 0 &&
+		    mpt_is_raid_volume(mpt, tgt) != 0) {
+			mpt_lprt(mpt, MPT_PRT_ALWAYS,
+			    "skipping transfer settings for RAID volumes\n");
 			mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 			break;
 		}
 
-		m = mpt->mpt_port_page2.PortSettings;
-		if ((m & MPI_SCSIPORTPAGE2_PORT_MASK_NEGO_MASTER_SETTINGS) ==
-		    MPI_SCSIPORTPAGE2_PORT_ALL_MASTER_SETTINGS) {
-mpt_prt(mpt, "master settings\n");
-if (raid_passthru == 0) {
+		i = mpt->mpt_port_page2.PortSettings &
+		    MPI_SCSIPORTPAGE2_PORT_MASK_NEGO_MASTER_SETTINGS;
+		j = mpt->mpt_port_page2.PortFlags &
+		    MPI_SCSIPORTPAGE2_PORT_FLAGS_DV_MASK;
+		if (i == MPI_SCSIPORTPAGE2_PORT_ALL_MASTER_SETTINGS &&
+		    j == MPI_SCSIPORTPAGE2_PORT_FLAGS_OFF_DV) {
+			mpt_lprt(mpt, MPT_PRT_ALWAYS,
+			    "honoring BIOS transfer negotiations\n");
 			mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 			break;
-}
 		}
 
+
 		dval = 0;
 		period = 0;
 		offset = 0;
@@ -2846,24 +2864,27 @@
 		spi = &cts->xport_specific.spi;
 
 		if ((spi->valid & CTS_SPI_VALID_DISC) != 0) {
-			if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0)
+			if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) {
 				dval |= DP_DISC_ENABLE;
-			else
+			} else {
 				dval |= DP_DISC_DISABL;
+			}
 		}
 
 		if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) {
-			if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0)
+			if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) {
 				dval |= DP_TQING_ENABLE;
-			else
+			} else {
 				dval |= DP_TQING_DISABL;
+			}
 		}
 
 		if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) {
-			if (spi->bus_width == MSG_EXT_WDTR_BUS_16_BIT)
+			if (spi->bus_width == MSG_EXT_WDTR_BUS_16_BIT) {
 				dval |= DP_WIDE;
-			else
+			} else {
 				dval |= DP_NARROW;
+			}
 		}
 
 		if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) &&
@@ -2874,6 +2895,9 @@
 			offset = spi->sync_offset;
 		}
 #endif
+		mpt_lprt(mpt, MPT_PRT_NEGOTIATION,
+		    "mpt_action: SET tgt %d flags %x period %x off %x\n",
+		    tgt, dval, period, offset);
 		CAMLOCK_2_MPTLOCK(mpt);
 		if (dval & DP_DISC_ENABLE) {
 			mpt->mpt_disc_enable |= (1 << tgt);
@@ -2891,10 +2915,12 @@
 		if (dval & DP_SYNC) {
 			mpt_setsync(mpt, tgt, period, offset);
 		}
+		if (mpt_update_spi_config(mpt, tgt)) {
+			MPTLOCK_2_CAMLOCK(mpt);
+			mpt_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
+			break;
+		}
 		MPTLOCK_2_CAMLOCK(mpt);
-		mpt_lprt(mpt, MPT_PRT_DEBUG,
-		    "SET tgt %d flags %x period %x off %x\n",
-		    tgt, dval, period, offset);
 		mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 		break;
 	}
@@ -2952,11 +2978,9 @@
 			sas->valid = CTS_SAS_VALID_SPEED;
 			sas->bitrate = 300000;	/* XXX: Default 3Gbps */
 #endif
-		} else {
-			if (mpt_get_spi_settings(mpt, cts) != 0) {
-				mpt_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
-				break;
-			}
+		} else if (mpt_get_spi_settings(mpt, cts) != 0) {
+			mpt_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
+			break;
 		}
 		mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 		break;
@@ -3005,10 +3029,17 @@
 			cpi->base_transfer_speed = 3300;
 			cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
 		}
+
+		/*
+		 * We give our fake RAID passhtru bus a width that is MaxVolumes
+		 * wide, restrict it to one lun and have it *not* be a bus
+		 * that can have a SCSI bus reset.
+		 */
 		if (raid_passthru) {
+			cpi->max_target = mpt->ioc_page2->MaxPhysDisks - 1;
+			cpi->initiator_id = cpi->max_target+1;
 			cpi->max_lun = 0;
 			cpi->hba_misc = PIM_NOBUSRESET;
-			cpi->initiator_id = cpi->max_target+1;
 		}
 
 		if ((mpt->role & MPT_ROLE_INITIATOR) == 0) {
@@ -3109,30 +3140,12 @@
 	uint8_t dval, pval, oval;
 	int rv;
 
-	/*
-	 * Check to see if this is an Integrated Raid card.
-	 *
-	 * If it is, and we're the RAID bus side, both current
-	 * and goal settings are synthesized as we only look at
-	 * or change actual settings for the physical disk side.
-	 *
-	 * NB: In the future we can just do this on the blacked out
-	 * NB: portion that the RAID volume covers- there may be
-	 * NB: other entities on this bus as well.
-	 */
-
-	if (mpt->phydisk_sim) {
-		if (xpt_path_sim(cts->ccb_h.path) != mpt->phydisk_sim) {
-			dval = DP_WIDE|DP_DISC|DP_TQING;
-			oval = (mpt->mpt_port_page0.Capabilities >> 16);
-			pval = (mpt->mpt_port_page0.Capabilities >>  8);
-			tgt = cts->ccb_h.target_id;
-			goto skip;
+	if (xpt_path_sim(cts->ccb_h.path) == mpt->phydisk_sim) {
+		if (mpt_map_physdisk(mpt, (union ccb *)cts, &tgt)) {
+			return (-1);
 		}
-	}
-
-	if (mpt_map_physdisk(mpt, (union ccb *)cts, &tgt) != 0) {
-		return (-1);
+	} else {
+		tgt = cts->ccb_h.target_id;
 	}
 
 	/*
@@ -3156,10 +3169,6 @@
 			return (rv);
 		}
 		MPTLOCK_2_CAMLOCK(mpt);
-
-		mpt_lprt(mpt, MPT_PRT_DEBUG,
-		    "mpt_get_spi: SPI Tgt %d Page 0: NParms %x Info %x\n",
-		    tgt, tmp.NegotiatedParameters, tmp.Information);
 		if (tmp.NegotiatedParameters & MPI_SCSIDEVPAGE0_NP_WIDE) {
 			dval |= DP_WIDE;
 		}
@@ -3181,7 +3190,6 @@
 		oval = (mpt->mpt_port_page0.Capabilities >> 16);
 		pval = (mpt->mpt_port_page0.Capabilities >>  8);
 	}
- skip:
 #ifndef	CAM_NEW_TRAN_CODE
 	cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB);
 	if (dval & DP_DISC_ENABLE) {
@@ -3236,9 +3244,9 @@
 		scsi->valid = 0;
 	}
 #endif
-	mpt_lprt(mpt, MPT_PRT_DEBUG,
-	    "mpt_get_spi: tgt %d %s settings flags %x period %x offset %x\n",
-	    tgt, IS_CURRENT_SETTINGS(cts)? "ACTIVE" : "NVRAM",
+	mpt_lprt(mpt, MPT_PRT_NEGOTIATION,
+	    "mpt_get_spi_settings: tgt %d %s settings flags 0x%x period 0x%x "
+	    "offset %x\n", tgt, IS_CURRENT_SETTINGS(cts)? "ACTIVE" : "NVRAM ",
 	    dval, pval, oval);
 	return (0);
 }
@@ -3246,27 +3254,27 @@
 static void
 mpt_setwidth(struct mpt_softc *mpt, int tgt, int onoff)
 {
-	PTR_CONFIG_PAGE_SCSI_DEVICE_1 tmp;
+	PTR_CONFIG_PAGE_SCSI_DEVICE_1 ptr;
 
-	tmp = &mpt->mpt_dev_page1[tgt];
+	ptr = &mpt->mpt_dev_page1[tgt];
 	if (onoff) {
-		tmp->RequestedParameters |= MPI_SCSIDEVPAGE1_RP_WIDE;
+		ptr->RequestedParameters |= MPI_SCSIDEVPAGE1_RP_WIDE;
 	} else {
-		tmp->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_WIDE;
+		ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_WIDE;
 	}
 }
 
 static void
 mpt_setsync(struct mpt_softc *mpt, int tgt, int period, int offset)
 {
-	PTR_CONFIG_PAGE_SCSI_DEVICE_1 tmp;
+	PTR_CONFIG_PAGE_SCSI_DEVICE_1 ptr;
 
-	tmp = &mpt->mpt_dev_page1[tgt];
-	tmp->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK;
-	tmp->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK;
-	tmp->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_DT;
-	tmp->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_QAS;
-	tmp->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_IU;
+	ptr = &mpt->mpt_dev_page1[tgt];
+	ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK;
+	ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK;
+	ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_DT;
+	ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_QAS;
+	ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_IU;
 
 	/*
 	 * XXX: For now, we're ignoring specific settings
@@ -3284,7 +3292,7 @@
 			np |= MPI_SCSIDEVPAGE1_RP_DT;
 		}
 		np |= (factor << 8) | (offset << 16);
-		tmp->RequestedParameters |= np;
+		ptr->RequestedParameters |= np;
 	}
 }
 
@@ -3308,9 +3316,9 @@
 		return (-1);
 	}
 	mpt->mpt_dev_page1[tgt] = tmp;
-	mpt_lprt(mpt, MPT_PRT_DEBUG,
-	    "mpt_update_spi_config[%d]: Page 1: RParams %x Config %x\n", tgt,
-	    mpt->mpt_dev_page1[tgt].RequestedParameters,
+	mpt_lprt(mpt, MPT_PRT_NEGOTIATION,
+	    "mpt_update_spi_config[%d].page1: RParams 0x%x Config 0x%x\n",
+	    tgt, mpt->mpt_dev_page1[tgt].RequestedParameters,
 	    mpt->mpt_dev_page1[tgt].Configuration);
 	return (0);
 }

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_cam.h#3 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/mpt/mpt_cam.h,v 1.3 2006/02/25 07:45:54 mjacob Exp $ */
+/* $FreeBSD: src/sys/dev/mpt/mpt_cam.h,v 1.4 2006/05/29 20:34:28 mjacob Exp $ */
 /*-
  * LSI MPT Host Adapter FreeBSD Wrapper Definitions (CAM version)
  *
@@ -57,6 +57,9 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 /*-
  * Copyright (c) 2004, Avid Technology, Inc. and its contributors.

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_debug.c#5 (text+ko) ====

@@ -58,10 +58,13 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_debug.c,v 1.15 2006/05/26 05:54:21 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_debug.c,v 1.16 2006/05/29 20:34:28 mjacob Exp $");
 
 #include <dev/mpt/mpt.h>
 

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_pci.c#7 (text+ko) ====

@@ -61,6 +61,9 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 /*
  * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
@@ -96,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.30 2006/05/29 16:59:38 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.31 2006/05/29 20:34:28 mjacob Exp $");
 
 #include <dev/mpt/mpt.h>
 #include <dev/mpt/mpt_cam.h>

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_raid.c#7 (text+ko) ====

@@ -31,9 +31,17 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+/*-
+ * Some Breakage and Bug Fixing added later.
+ * Copyright (c) 2006, by Matthew Jacob
+ * All Rights Reserved
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
+ */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_raid.c,v 1.8 2006/05/27 17:26:57 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_raid.c,v 1.10 2006/05/29 20:34:28 mjacob Exp $");
 
 #include <dev/mpt/mpt.h>
 #include <dev/mpt/mpt_raid.h>
@@ -226,7 +234,7 @@
 			break;
 		}
 
-		mpt_lprt(mpt, MPT_PRT_DEBUG, " Callback for %d\n",
+		mpt_lprt(mpt, MPT_PRT_DEBUG, "Callback for %d\n",
 			 cgd->ccb_h.target_id);
 		
 		RAID_VOL_FOREACH(mpt, mpt_vol) {
@@ -779,11 +787,28 @@
 		*tgt = mpt_disk->config_page.PhysDiskID;
 		return (0);
 	}
-	mpt_lprt(mpt, MPT_PRT_DEBUG, "mpt_map_physdisk(%d) - Not Active\n",
+	mpt_lprt(mpt, MPT_PRT_DEBUG1, "mpt_map_physdisk(%d) - Not Active\n",
 		 ccb->ccb_h.target_id);
 	return (-1);
 }
 
+/* XXX Ignores that there may be multiple busses/IOCs involved. */
+int
+mpt_is_raid_volume(struct mpt_softc *mpt, int tgt)
+{
+	CONFIG_PAGE_IOC_2_RAID_VOL *ioc_vol;
+	CONFIG_PAGE_IOC_2_RAID_VOL *ioc_last_vol;
+
+	ioc_vol = mpt->ioc_page2->RaidVolume;
+	ioc_last_vol = ioc_vol + mpt->ioc_page2->NumActiveVolumes;
+	for (;ioc_vol != ioc_last_vol; ioc_vol++) {
+		if (ioc_vol->VolumeID == tgt) {
+			return (1);
+		}
+	}
+	return (0);
+}
+
 #if 0
 static void
 mpt_enable_vol(struct mpt_softc *mpt, struct mpt_raid_volume *mpt_vol,

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_raid.h#3 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/mpt/mpt_raid.h,v 1.4 2006/05/27 17:26:57 mjacob Exp $ */
+/* $FreeBSD: src/sys/dev/mpt/mpt_raid.h,v 1.6 2006/05/29 20:34:28 mjacob Exp $ */
 /*-
  * Definitions for the integrated RAID features LSI MPT Fusion adapters.
  *
@@ -32,6 +32,14 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+/*-
+ * Some Breakage and Bug Fixing added later.
+ * Copyright (c) 2006, by Matthew Jacob
+ * All Rights Reserved
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
+ */
 #ifndef  _MPT_RAID_H_
 #define  _MPT_RAID_H_
 
@@ -60,6 +68,7 @@
 
 cam_status
 mpt_map_physdisk(struct mpt_softc *, union ccb *, target_id_t *);
+int mpt_is_raid_volume(struct mpt_softc *, int);
 cam_status
 mpt_raid_quiesce_disk(struct mpt_softc *, struct mpt_raid_disk *, request_t *);
 

==== //depot/projects/fast_ipsec/src/sys/dev/mpt/mpt_reg.h#4 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/mpt/mpt_reg.h,v 1.3 2006/03/25 07:08:27 mjacob Exp $ */
+/* $FreeBSD: src/sys/dev/mpt/mpt_reg.h,v 1.4 2006/05/29 20:34:28 mjacob Exp $ */
 /*-
  * Generic defines for LSI '909 FC  adapters.
  * FreeBSD Version.
@@ -58,6 +58,9 @@
  *
  * Support from Chris Ellsworth in order to make SAS adapters work
  * is gratefully acknowledged.
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
  */
 #ifndef _MPT_REG_H_
 #define	_MPT_REG_H_

==== //depot/projects/fast_ipsec/src/sys/kern/kern_exit.c#8 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.288 2006/04/10 14:07:28 csjp Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.289 2006/05/29 21:28:56 tegge Exp $");
 
 #include "opt_compat.h"
 #include "opt_ktrace.h"
@@ -113,14 +113,13 @@
 	struct proc *p, *nq, *q;
 	struct tty *tp;
 	struct vnode *ttyvp;
-	struct vmspace *vm;
 	struct vnode *vtmp;
 #ifdef KTRACE
 	struct vnode *tracevp;
 	struct ucred *tracecred;
 #endif
 	struct plimit *plim;
-	int locked, refcnt;
+	int locked;
 
 	/*
 	 * Drop Giant if caller has it.  Eventually we should warn about
@@ -300,33 +299,7 @@
 	}
 	mtx_unlock(&ppeers_lock);
 
-	/* The next two chunks should probably be moved to vmspace_exit. */
-	vm = p->p_vmspace;
-	/*
-	 * Release user portion of address space.
-	 * This releases references to vnodes,
-	 * which could cause I/O if the file has been unlinked.
-	 * Need to do this early enough that we can still sleep.
-	 * Can't free the entire vmspace as the kernel stack
-	 * may be mapped within that space also.
-	 *
-	 * Processes sharing the same vmspace may exit in one order, and
-	 * get cleaned up by vmspace_exit() in a different order.  The
-	 * last exiting process to reach this point releases as much of
-	 * the environment as it can, and the last process cleaned up
-	 * by vmspace_exit() (which decrements exitingcnt) cleans up the
-	 * remainder.
-	 */
-	atomic_add_int(&vm->vm_exitingcnt, 1);
-	do
-		refcnt = vm->vm_refcnt;
-	while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt - 1));
-	if (refcnt == 1) {
-		shmexit(vm);
-		pmap_remove_pages(vmspace_pmap(vm));
-		(void) vm_map_remove(&vm->vm_map, vm_map_min(&vm->vm_map),
-		    vm_map_max(&vm->vm_map));
-	}
+	vmspace_exit(td);
 
 	sx_xlock(&proctree_lock);
 	if (SESS_LEADER(p)) {

==== //depot/projects/fast_ipsec/src/sys/vm/vm_extern.h#3 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)vm_extern.h	8.2 (Berkeley) 1/12/94
- * $FreeBSD: src/sys/vm/vm_extern.h,v 1.77 2005/12/16 18:34:14 alc Exp $
+ * $FreeBSD: src/sys/vm/vm_extern.h,v 1.78 2006/05/29 21:28:56 tegge Exp $
  */
 
 #ifndef _VM_EXTERN_H_
@@ -78,6 +78,8 @@
 struct vmspace *vmspace_fork(struct vmspace *);
 void vmspace_exec(struct proc *, vm_offset_t, vm_offset_t);
 void vmspace_unshare(struct proc *);
+void vmspace_exit(struct thread *);
+struct vmspace *vmspace_acquire_ref(struct proc *);
 void vmspace_free(struct vmspace *);
 void vmspace_exitfree(struct proc *);
 void vnode_pager_setsize(struct vnode *, vm_ooffset_t);

==== //depot/projects/fast_ipsec/src/sys/vm/vm_glue.c#3 (text+ko) ====

@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/vm/vm_glue.c,v 1.214 2005/12/16 18:34:14 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/vm/vm_glue.c,v 1.215 2006/05/29 21:28:56 tegge Exp $");
 
 #include "opt_vm.h"
 #include "opt_kstack_pages.h"
@@ -852,12 +852,9 @@
 		 * process may attempt to alter
 		 * the map.
 		 */
-		PROC_LOCK(p);
-		vm = p->p_vmspace;
-		KASSERT(vm != NULL,
-			("swapout_procs: a process has no address space"));
-		atomic_add_int(&vm->vm_refcnt, 1);
-		PROC_UNLOCK(p);
+		vm = vmspace_acquire_ref(p);
+		if (vm == NULL)
+			continue;
 		if (!vm_map_trylock(&vm->vm_map))
 			goto nextproc1;
 

==== //depot/projects/fast_ipsec/src/sys/vm/vm_map.c#6 (text+ko) ====

@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/vm/vm_map.c,v 1.373 2006/03/08 06:31:46 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/vm/vm_map.c,v 1.374 2006/05/29 21:28:56 tegge Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -148,6 +148,13 @@
 static void vmspace_zdtor(void *mem, int size, void *arg);
 #endif
 
+/* 
+ * PROC_VMSPACE_{UN,}LOCK() can be a noop as long as vmspaces are type
+ * stable.
+ */
+#define PROC_VMSPACE_LOCK(p) do { } while (0)
+#define PROC_VMSPACE_UNLOCK(p) do { } while (0)
+
 void
 vm_map_startup(void)
 {
@@ -261,7 +268,6 @@
 	vm->vm_taddr = 0;
 	vm->vm_daddr = 0;
 	vm->vm_maxsaddr = 0;
-	vm->vm_exitingcnt = 0;
 	return (vm);
 }
 
@@ -313,7 +319,7 @@
 	do
 		refcnt = vm->vm_refcnt;
 	while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt - 1));
-	if (refcnt == 1 && vm->vm_exitingcnt == 0)
+	if (refcnt == 1)
 		vmspace_dofree(vm);
 }
 
@@ -321,28 +327,93 @@
 vmspace_exitfree(struct proc *p)
 {
 	struct vmspace *vm;
-	int exitingcnt;
 
+	PROC_VMSPACE_LOCK(p);
 	vm = p->p_vmspace;
 	p->p_vmspace = NULL;
+	PROC_VMSPACE_UNLOCK(p);
+	KASSERT(vm == &vmspace0, ("vmspace_exitfree: wrong vmspace"));
+	vmspace_free(vm);
+}
+
+void
+vmspace_exit(struct thread *td)
+{
+	int refcnt;
+	struct vmspace *vm;
+	struct proc *p;
 
 	/*
-	 * cleanup by parent process wait()ing on exiting child.  vm_refcnt
-	 * may not be 0 (e.g. fork() and child exits without exec()ing).
-	 * exitingcnt may increment above 0 and drop back down to zero
-	 * several times while vm_refcnt is held non-zero.  vm_refcnt
-	 * may also increment above 0 and drop back down to zero several
-	 * times while vm_exitingcnt is held non-zero.
+	 * Release user portion of address space.
+	 * This releases references to vnodes,
+	 * which could cause I/O if the file has been unlinked.
+	 * Need to do this early enough that we can still sleep.
 	 *
-	 * The last wait on the exiting child's vmspace will clean up
-	 * the remainder of the vmspace.
+	 * The last exiting process to reach this point releases as
+	 * much of the environment as it can. vmspace_dofree() is the
+	 * slower fallback in case another process had a temporary
+	 * reference to the vmspace.
 	 */
-	do
-		exitingcnt = vm->vm_exitingcnt;
-	while (!atomic_cmpset_int(&vm->vm_exitingcnt, exitingcnt,
-	    exitingcnt - 1));
-	if (vm->vm_refcnt == 0 && exitingcnt == 1)
+
+	p = td->td_proc;
+	vm = p->p_vmspace;
+	atomic_add_int(&vmspace0.vm_refcnt, 1);
+	do {
+		refcnt = vm->vm_refcnt;
+		if (refcnt > 1 && p->p_vmspace != &vmspace0) {
+			/* Switch now since other proc might free vmspace */
+			PROC_VMSPACE_LOCK(p);
+			p->p_vmspace = &vmspace0;
+			PROC_VMSPACE_UNLOCK(p);
+			pmap_activate(td);
+		}
+	} while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt - 1));
+	if (refcnt == 1) {
+		if (p->p_vmspace != vm) {
+			/* vmspace not yet freed, switch back */
+			PROC_VMSPACE_LOCK(p);
+			p->p_vmspace = vm;
+			PROC_VMSPACE_UNLOCK(p);
+			pmap_activate(td);
+		}
+		pmap_remove_pages(vmspace_pmap(vm));
+		/* Switch now since this proc will free vmspace */
+		PROC_VMSPACE_LOCK(p);
+		p->p_vmspace = &vmspace0;
+		PROC_VMSPACE_UNLOCK(p);
+		pmap_activate(td);
 		vmspace_dofree(vm);
+	}
+}
+
+/* Acquire reference to vmspace owned by another process. */
+
+struct vmspace *
+vmspace_acquire_ref(struct proc *p)
+{
+	struct vmspace *vm;
+	int refcnt;
+
+	PROC_VMSPACE_LOCK(p);
+	vm = p->p_vmspace;
+	if (vm == NULL) {
+		PROC_VMSPACE_UNLOCK(p);
+		return (NULL);
+	}
+	do {
+		refcnt = vm->vm_refcnt;
+		if (refcnt <= 0) { 	/* Avoid 0->1 transition */
+			PROC_VMSPACE_UNLOCK(p);
+			return (NULL);
+		}
+	} while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt + 1));
+	if (vm != p->p_vmspace) {
+		PROC_VMSPACE_UNLOCK(p);
+		vmspace_free(vm);
+		return (NULL);
+	}
+	PROC_VMSPACE_UNLOCK(p);
+	return (vm);
 }
 
 void
@@ -2923,7 +2994,9 @@
 	 * run it down.  Even though there is little or no chance of blocking
 	 * here, it is a good idea to keep this form for future mods.
 	 */
+	PROC_VMSPACE_LOCK(p);
 	p->p_vmspace = newvmspace;
+	PROC_VMSPACE_UNLOCK(p);
 	if (p == curthread->td_proc)		/* XXXKSE ? */
 		pmap_activate(curthread);
 	vmspace_free(oldvmspace);
@@ -2942,7 +3015,9 @@
 	if (oldvmspace->vm_refcnt == 1)
 		return;
 	newvmspace = vmspace_fork(oldvmspace);
+	PROC_VMSPACE_LOCK(p);
 	p->p_vmspace = newvmspace;
+	PROC_VMSPACE_UNLOCK(p);
 	if (p == curthread->td_proc)		/* XXXKSE ? */
 		pmap_activate(curthread);
 	vmspace_free(oldvmspace);

==== //depot/projects/fast_ipsec/src/sys/vm/vm_map.h#3 (text+ko) ====

@@ -57,7 +57,7 @@
  * any improvements or extensions that they make and grant Carnegie the
  * rights to redistribute these changes.
  *
- * $FreeBSD: src/sys/vm/vm_map.h,v 1.118 2005/12/03 22:41:15 alc Exp $
+ * $FreeBSD: src/sys/vm/vm_map.h,v 1.119 2006/05/29 21:28:56 tegge Exp $
  */
 
 /*
@@ -242,7 +242,6 @@
 	caddr_t vm_taddr;	/* (c) user virtual address of text */
 	caddr_t vm_daddr;	/* (c) user virtual address of data */
 	caddr_t vm_maxsaddr;	/* user VA at max stack growth */
-	int	vm_exitingcnt;	/* several processes zombied in exit1  */
 	int	vm_refcnt;	/* number of references */
 };
 

==== //depot/projects/fast_ipsec/src/sys/vm/vm_meter.c#2 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/vm/vm_meter.c,v 1.85 2005/05/08 23:56:16 marcel Exp $");
+__FBSDID("$FreeBSD: src/sys/vm/vm_meter.c,v 1.86 2006/05/29 21:28:56 tegge Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -115,6 +115,7 @@
 	vm_map_t map;
 	int paging;
 	struct thread *td;
+	struct vmspace *vm;
 
 	totalp = &total;
 	bzero(totalp, sizeof *totalp);
@@ -185,7 +186,10 @@
 		 * Note active objects.
 		 */
 		paging = 0;
-		map = &p->p_vmspace->vm_map;
+		vm = vmspace_acquire_ref(p);
+		if (vm == NULL)
+			continue;
+		map = &vm->vm_map;
 		vm_map_lock_read(map);
 		for (entry = map->header.next;
 		    entry != &map->header; entry = entry->next) {
@@ -198,6 +202,7 @@
 			VM_OBJECT_UNLOCK(object);
 		}
 		vm_map_unlock_read(map);
+		vmspace_free(vm);
 		if (paging)
 			totalp->t_pw++;
 	}


More information about the p4-projects mailing list