Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Apr 2014 22:01:03 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r264949 - stable/10/sys/dev/mpt
Message-ID:  <201404252201.s3PM137U063397@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Fri Apr 25 22:01:02 2014
New Revision: 264949
URL: http://svnweb.freebsd.org/changeset/base/264949

Log:
  MFC: r260058
  
  - Remove a redundant variable in mpt_pci_attach().
  - #if 0 the currently unused paired port linking and unlinking of dual
    adapters.
  - Simplify MSI/MSI-X allocation and release. For a single one, we don't need
    to fiddle with the MSI/MSI-X count and pci_release_msi(9) is smart enough
    to just do nothing in case of INTx.
  - Canonicalize actions taken on attach failure and detach.
  - Remove the remainder of incomplete support for older FreeBSD versions.

Modified:
  stable/10/sys/dev/mpt/mpt.h
  stable/10/sys/dev/mpt/mpt_cam.c
  stable/10/sys/dev/mpt/mpt_pci.c
  stable/10/sys/dev/mpt/mpt_raid.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mpt/mpt.h
==============================================================================
--- stable/10/sys/dev/mpt/mpt.h	Fri Apr 25 21:58:28 2014	(r264948)
+++ stable/10/sys/dev/mpt/mpt.h	Fri Apr 25 22:01:02 2014	(r264949)
@@ -220,9 +220,6 @@ int mpt_modevent(module_t, int, void *);
 #define bus_dmamap_sync_range(dma_tag, dmamap, offset, len, op)	\
 	bus_dmamap_sync(dma_tag, dmamap, op)
 
-#if __FreeBSD_version < 600000
-#define	bus_get_dma_tag(x)	NULL
-#endif
 #define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary,	\
 			   lowaddr, highaddr, filter, filterarg,	\
 			   maxsize, nsegments, maxsegsz, flags,		\
@@ -239,34 +236,6 @@ struct mpt_map_info {
 };
 
 void mpt_map_rquest(void *, bus_dma_segment_t *, int, int);
-/* **************************** NewBUS interrupt Crock ************************/
-#if __FreeBSD_version < 700031
-#define	mpt_setup_intr(d, i, f, U, if, ifa, hp)	\
-	bus_setup_intr(d, i, f, if, ifa, hp)
-#else
-#define	mpt_setup_intr	bus_setup_intr
-#endif
-
-/* **************************** NewBUS CAM Support ****************************/
-#if __FreeBSD_version < 700049
-#define mpt_xpt_bus_register(sim, parent, bus)	\
-	xpt_bus_register(sim, bus)
-#else
-#define mpt_xpt_bus_register	xpt_bus_register
-#endif
-
-/**************************** Kernel Thread Support ***************************/
-#if __FreeBSD_version > 800001
-#define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
-	kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
-#define	mpt_kthread_exit(status)	\
-	kproc_exit(status)
-#else
-#define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
-	kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
-#define	mpt_kthread_exit(status)	\
-	kthread_exit(status)
-#endif
 
 /********************************** Endianess *********************************/
 #define	MPT_2_HOST64(ptr, tag)	ptr->tag = le64toh(ptr->tag)
@@ -671,7 +640,6 @@ struct mpt_softc {
 	/*
 	 * PCI Hardware info
 	 */
-	int			pci_msi_count;
 	struct resource *	pci_irq;	/* Interrupt map for chip */
 	void *			ih;		/* Interrupt handle */
 #if 0
@@ -754,9 +722,10 @@ struct mpt_softc {
 	uint16_t		sequence;	/* Sequence Number */
 	uint16_t		pad3;
 
-
+#if 0
 	/* Paired port in some dual adapters configurations */
 	struct mpt_softc *	mpt2;
+#endif
 
 	/* FW Image management */
 	uint32_t		fw_image_size;

Modified: stable/10/sys/dev/mpt/mpt_cam.c
==============================================================================
--- stable/10/sys/dev/mpt/mpt_cam.c	Fri Apr 25 21:58:28 2014	(r264948)
+++ stable/10/sys/dev/mpt/mpt_cam.c	Fri Apr 25 22:01:02 2014	(r264949)
@@ -110,12 +110,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/kthread.h>
 #include <sys/sysctl.h>
 
-#if __FreeBSD_version >= 700025
-#ifndef	CAM_NEW_TRAN_CODE
-#define	CAM_NEW_TRAN_CODE	1
-#endif
-#endif
-
 static void mpt_poll(struct cam_sim *);
 static timeout_t mpt_timeout;
 static void mpt_action(struct cam_sim *, union ccb *);
@@ -344,7 +338,7 @@ mpt_cam_attach(struct mpt_softc *mpt)
 	 * Register exactly this bus.
 	 */
 	MPT_LOCK(mpt);
-	if (mpt_xpt_bus_register(mpt->sim, mpt->dev, 0) != CAM_SUCCESS) {
+	if (xpt_bus_register(mpt->sim, mpt->dev, 0) != CAM_SUCCESS) {
 		mpt_prt(mpt, "Bus registration Failed!\n");
 		error = ENOMEM;
 		MPT_UNLOCK(mpt);
@@ -383,7 +377,7 @@ mpt_cam_attach(struct mpt_softc *mpt)
 	 * Register this bus.
 	 */
 	MPT_LOCK(mpt);
-	if (mpt_xpt_bus_register(mpt->phydisk_sim, mpt->dev, 1) !=
+	if (xpt_bus_register(mpt->phydisk_sim, mpt->dev, 1) !=
 	    CAM_SUCCESS) {
 		mpt_prt(mpt, "Physical Disk Bus registration Failed!\n");
 		error = ENOMEM;
@@ -2338,7 +2332,6 @@ mpt_cam_event(struct mpt_softc *mpt, req
 		break;
 
 	case MPI_EVENT_RESCAN:
-#if __FreeBSD_version >= 600000
 	{
 		union ccb *ccb;
 		uint32_t pathid;
@@ -2373,10 +2366,7 @@ mpt_cam_event(struct mpt_softc *mpt, req
 		xpt_rescan(ccb);
 		break;
 	}
-#else
-		mpt_prt(mpt, "Rescan Port: %d\n", (data0 >> 8) & 0xff);
-		break;
-#endif
+
 	case MPI_EVENT_LINK_STATUS_CHANGE:
 		mpt_prt(mpt, "Port %d: LinkState: %s\n",
 		    (data1 >> 8) & 0xff,
@@ -3324,11 +3314,8 @@ mpt_action(struct cam_sim *sim, union cc
 		break;
 	}
 
-#ifdef	CAM_NEW_TRAN_CODE
 #define	IS_CURRENT_SETTINGS(c)	((c)->type == CTS_TYPE_CURRENT_SETTINGS)
-#else
-#define	IS_CURRENT_SETTINGS(c)	((c)->flags & CCB_TRANS_CURRENT_SETTINGS)
-#endif
+
 #define	DP_DISC_ENABLE	0x1
 #define	DP_DISC_DISABL	0x2
 #define	DP_DISC		(DP_DISC_ENABLE|DP_DISC_DISABL)
@@ -3345,10 +3332,8 @@ mpt_action(struct cam_sim *sim, union cc
 
 	case XPT_SET_TRAN_SETTINGS:	/* Nexus Settings */
 	{
-#ifdef	CAM_NEW_TRAN_CODE
 		struct ccb_trans_settings_scsi *scsi;
 		struct ccb_trans_settings_spi *spi;
-#endif
 		uint8_t dval;
 		u_int period;
 		u_int offset;
@@ -3361,7 +3346,6 @@ mpt_action(struct cam_sim *sim, union cc
 			break;
 		}
 
-#ifdef	CAM_NEW_TRAN_CODE
 		scsi = &cts->proto_specific.scsi;
 		spi = &cts->xport_specific.spi;
 
@@ -3372,7 +3356,6 @@ mpt_action(struct cam_sim *sim, union cc
 			mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 			break;
 		}
-#endif
 
 		/*
 		 * Skip attempting settings on RAID volume disks.
@@ -3402,28 +3385,6 @@ mpt_action(struct cam_sim *sim, union cc
 		period = 0;
 		offset = 0;
 
-#ifndef	CAM_NEW_TRAN_CODE
-		if ((cts->valid & CCB_TRANS_DISC_VALID) != 0) {
-			dval |= (cts->flags & CCB_TRANS_DISC_ENB) ?
-			    DP_DISC_ENABLE : DP_DISC_DISABL;
-		}
-
-		if ((cts->valid & CCB_TRANS_TQ_VALID) != 0) {
-			dval |= (cts->flags & CCB_TRANS_TAG_ENB) ?
-			    DP_TQING_ENABLE : DP_TQING_DISABL;
-		}
-
-		if ((cts->valid & CCB_TRANS_BUS_WIDTH_VALID) != 0) {
-			dval |= cts->bus_width ? DP_WIDE : DP_NARROW;
-		}
-
-		if ((cts->valid & CCB_TRANS_SYNC_RATE_VALID) &&
-		    (cts->valid & CCB_TRANS_SYNC_OFFSET_VALID)) {
-			dval |= DP_SYNC;
-			period = cts->sync_period;
-			offset = cts->sync_offset;
-		}
-#else
 		if ((spi->valid & CTS_SPI_VALID_DISC) != 0) {
 			dval |= ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) ?
 			    DP_DISC_ENABLE : DP_DISC_DISABL;
@@ -3459,7 +3420,7 @@ mpt_action(struct cam_sim *sim, union cc
 			period &= MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK;
 	    		period >>= MPI_SCSIDEVPAGE1_RP_SHIFT_MIN_SYNC_PERIOD;
 		}
-#endif
+
 		if (dval & DP_DISC_ENABLE) {
 			mpt->mpt_disc_enable |= (1 << tgt);
 		} else if (dval & DP_DISC_DISABL) {
@@ -3492,7 +3453,6 @@ mpt_action(struct cam_sim *sim, union cc
 	}
 	case XPT_GET_TRAN_SETTINGS:
 	{
-#ifdef	CAM_NEW_TRAN_CODE
 		struct ccb_trans_settings_scsi *scsi;
 		cts = &ccb->cts;
 		cts->protocol = PROTO_SCSI;
@@ -3524,21 +3484,6 @@ mpt_action(struct cam_sim *sim, union cc
 		scsi = &cts->proto_specific.scsi;
 		scsi->valid = CTS_SCSI_VALID_TQ;
 		scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
-#else
-		cts = &ccb->cts;
-		if (mpt->is_fc) {
-			cts->flags = CCB_TRANS_TAG_ENB | CCB_TRANS_DISC_ENB;
-			cts->valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
-			cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
-		} else if (mpt->is_sas) {
-			cts->flags = CCB_TRANS_TAG_ENB | CCB_TRANS_DISC_ENB;
-			cts->valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
-			cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
-		} else if (mpt_get_spi_settings(mpt, cts) != 0) {
-			mpt_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
-			break;
-		}
-#endif
 		mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 		break;
 	}
@@ -3592,7 +3537,6 @@ mpt_action(struct cam_sim *sim, union cc
 		/*
 		 * The base speed is the speed of the underlying connection.
 		 */
-#ifdef	CAM_NEW_TRAN_CODE
 		cpi->protocol = PROTO_SCSI;
 		if (mpt->is_fc) {
 			cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED;
@@ -3616,21 +3560,6 @@ mpt_action(struct cam_sim *sim, union cc
 			cpi->transport_version = 2;
 			cpi->protocol_version = SCSI_REV_2;
 		}
-#else
-		if (mpt->is_fc) {
-			cpi->hba_misc = PIM_NOBUSRESET;
-			cpi->base_transfer_speed = 100000;
-			cpi->hba_inquiry = PI_TAG_ABLE;
-		} else if (mpt->is_sas) {
-			cpi->hba_misc = PIM_NOBUSRESET;
-			cpi->base_transfer_speed = 300000;
-			cpi->hba_inquiry = PI_TAG_ABLE;
-		} else {
-			cpi->hba_misc = PIM_SEQSCAN;
-			cpi->base_transfer_speed = 3300;
-			cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
-		}
-#endif
 
 		/*
 		 * We give our fake RAID passhtru bus a width that is MaxVolumes
@@ -3726,10 +3655,8 @@ mpt_action(struct cam_sim *sim, union cc
 static int
 mpt_get_spi_settings(struct mpt_softc *mpt, struct ccb_trans_settings *cts)
 {
-#ifdef	CAM_NEW_TRAN_CODE
 	struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi;
 	struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi;
-#endif
 	target_id_t tgt;
 	uint32_t dval, pval, oval;
 	int rv;
@@ -3790,29 +3717,6 @@ mpt_get_spi_settings(struct mpt_softc *m
 		pval = MPI_SCSIPORTPAGE0_CAP_GET_MIN_SYNC_PERIOD(pval);
 	}
 
-#ifndef	CAM_NEW_TRAN_CODE
-	cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB);
-	cts->valid = 0;
-	cts->sync_period = pval;
-	cts->sync_offset = oval;
-	cts->valid |= CCB_TRANS_SYNC_RATE_VALID;
-	cts->valid |= CCB_TRANS_SYNC_OFFSET_VALID;
-	cts->valid |= CCB_TRANS_BUS_WIDTH_VALID;
-	if (dval & DP_WIDE) {
-		cts->bus_width = MSG_EXT_WDTR_BUS_16_BIT;
-	} else {
-		cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
-	}
-	if (cts->ccb_h.target_lun != CAM_LUN_WILDCARD) {
-		cts->valid |= CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
-		if (dval & DP_DISC_ENABLE) {
-			cts->flags |= CCB_TRANS_DISC_ENB;
-		}
-		if (dval & DP_TQING_ENABLE) {
-			cts->flags |= CCB_TRANS_TAG_ENB;
-		}
-	}
-#else
 	spi->valid = 0;
 	scsi->valid = 0;
 	spi->flags = 0;
@@ -3837,10 +3741,10 @@ mpt_get_spi_settings(struct mpt_softc *m
 			spi->flags |= CTS_SPI_FLAGS_DISC_ENB;
 		}
 	}
-#endif
+
 	mpt_lprt(mpt, MPT_PRT_NEGOTIATION,
 	    "mpt_get_spi_settings[%d]: %s flags 0x%x per 0x%x off=%d\n", tgt,
-	    IS_CURRENT_SETTINGS(cts)? "ACTIVE" : "NVRAM ", dval, pval, oval);
+	    IS_CURRENT_SETTINGS(cts) ? "ACTIVE" : "NVRAM ", dval, pval, oval);
 	return (0);
 }
 
@@ -3910,7 +3814,7 @@ mpt_spawn_recovery_thread(struct mpt_sof
 {
 	int error;
 
-	error = mpt_kthread_create(mpt_recovery_thread, mpt,
+	error = kproc_create(mpt_recovery_thread, mpt,
 	    &mpt->recovery_thread, /*flags*/0,
 	    /*altstack*/0, "mpt_recovery%d", mpt->unit);
 	return (error);
@@ -3953,7 +3857,7 @@ mpt_recovery_thread(void *arg)
 	mpt->recovery_thread = NULL;
 	wakeup(&mpt->recovery_thread);
 	MPT_UNLOCK(mpt);
-	mpt_kthread_exit(0);
+	kproc_exit(0);
 }
 
 static int

Modified: stable/10/sys/dev/mpt/mpt_pci.c
==============================================================================
--- stable/10/sys/dev/mpt/mpt_pci.c	Fri Apr 25 21:58:28 2014	(r264948)
+++ stable/10/sys/dev/mpt/mpt_pci.c	Fri Apr 25 22:01:02 2014	(r264949)
@@ -105,14 +105,6 @@ __FBSDID("$FreeBSD$");
 #include <dev/mpt/mpt_cam.h>
 #include <dev/mpt/mpt_raid.h>
 
-#if __FreeBSD_version < 700000
-#define	pci_msix_count(x)	0
-#define	pci_msi_count(x)	0
-#define	pci_alloc_msi(x, y)	1
-#define	pci_alloc_msix(x, y)	1
-#define	pci_release_msi(x)	do { ; } while (0)
-#endif
-
 /*
  * XXX it seems no other MPT driver knows about the following chips.
  */
@@ -149,10 +141,6 @@ __FBSDID("$FreeBSD$");
 #define	MPI_MANUFACTPAGE_DEVID_SAS1078DE_FB	0x007C
 #endif
 
-#ifndef	PCIM_CMD_SERRESPEN
-#define	PCIM_CMD_SERRESPEN	0x0100
-#endif
-
 static int mpt_pci_probe(device_t);
 static int mpt_pci_attach(device_t);
 static void mpt_free_bus_resources(struct mpt_softc *mpt);
@@ -178,6 +166,7 @@ static device_method_t mpt_methods[] = {
 static driver_t mpt_driver = {
 	"mpt", mpt_methods, sizeof(struct mpt_softc)
 };
+
 static devclass_t mpt_devclass;
 DRIVER_MODULE(mpt, pci, mpt_driver, mpt_devclass, NULL, NULL);
 MODULE_DEPEND(mpt, pci, 1, 1, 1);
@@ -288,6 +277,7 @@ mpt_set_options(struct mpt_softc *mpt)
 	}
 }
 
+#if 0
 static void
 mpt_link_peer(struct mpt_softc *mpt)
 {
@@ -326,13 +316,14 @@ mpt_unlink_peer(struct mpt_softc *mpt)
 		mpt->mpt2->mpt2 = NULL;
 	}
 }
+#endif
 
 static int
 mpt_pci_attach(device_t dev)
 {
 	struct mpt_softc *mpt;
 	int		  iqd;
-	uint32_t	  data, cmd;
+	uint32_t	  val;
 	int		  mpt_io_bar, mpt_mem_bar;
 
 	mpt  = (struct mpt_softc*)device_get_softc(dev);
@@ -393,19 +384,19 @@ mpt_pci_attach(device_t dev)
 	/*
 	 * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER are set.
 	 */
-	cmd = pci_read_config(dev, PCIR_COMMAND, 2);
-	cmd |=
-	    PCIM_CMD_SERRESPEN | PCIM_CMD_PERRESPEN |
+	val = pci_read_config(dev, PCIR_COMMAND, 2);
+	val |= PCIM_CMD_SERRESPEN | PCIM_CMD_PERRESPEN |
 	    PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN;
-	pci_write_config(dev, PCIR_COMMAND, cmd, 2);
+	pci_write_config(dev, PCIR_COMMAND, val, 2);
 
 	/*
 	 * Make sure we've disabled the ROM.
 	 */
-	data = pci_read_config(dev, PCIR_BIOS, 4);
-	data &= ~PCIM_BIOS_ENABLE;
-	pci_write_config(dev, PCIR_BIOS, data, 4);
+	val = pci_read_config(dev, PCIR_BIOS, 4);
+	val &= ~PCIM_BIOS_ENABLE;
+	pci_write_config(dev, PCIR_BIOS, val, 4);
 
+#if 0
 	/*
 	 * Is this part a dual?
 	 * If so, link with our partner (around yet)
@@ -422,12 +413,13 @@ mpt_pci_attach(device_t dev)
 	default:
 		break;
 	}
+#endif
 
 	/*
 	 * Figure out which are the I/O and MEM Bars
 	 */
-	data = pci_read_config(dev, PCIR_BAR(0), 4);
-	if (PCI_BAR_IO(data)) {
+	val = pci_read_config(dev, PCIR_BAR(0), 4);
+	if (PCI_BAR_IO(val)) {
 		/* BAR0 is IO, BAR1 is memory */
 		mpt_io_bar = 0;
 		mpt_mem_bar = 1;
@@ -484,25 +476,15 @@ mpt_pci_attach(device_t dev)
 		 * First try to alloc an MSI-X message.  If that
 		 * fails, then try to alloc an MSI message instead.
 		 */
-		if (pci_msix_count(dev) == 1) {
-			mpt->pci_msi_count = 1;
-			if (pci_alloc_msix(dev, &mpt->pci_msi_count) == 0) {
-				iqd = 1;
-			} else {
-				mpt->pci_msi_count = 0;
-			}
-		}
-		if (iqd == 0 && pci_msi_count(dev) == 1) {
-			mpt->pci_msi_count = 1;
-			if (pci_alloc_msi(dev, &mpt->pci_msi_count) == 0) {
-				iqd = 1;
-			} else {
-				mpt->pci_msi_count = 0;
-			}
-		}
+		val = 1;
+		if (pci_alloc_msix(dev, &val) == 0)
+			iqd = 1;
+		val = 1;
+		if (iqd == 0 && pci_alloc_msi(dev, &val) == 0)
+			iqd = 1;
 	}
 	mpt->pci_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd,
-	    RF_ACTIVE | (mpt->pci_msi_count ? 0 : RF_SHAREABLE));
+	    RF_ACTIVE | (iqd != 0 ? 0 : RF_SHAREABLE));
 	if (mpt->pci_irq == NULL) {
 		device_printf(dev, "could not allocate interrupt\n");
 		goto bad;
@@ -514,7 +496,7 @@ mpt_pci_attach(device_t dev)
 	mpt_disable_ints(mpt);
 
 	/* Register the interrupt handler */
-	if (mpt_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, NULL, mpt_pci_intr,
+	if (bus_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, NULL, mpt_pci_intr,
 	    mpt, &mpt->ih)) {
 		device_printf(dev, "could not setup interrupt\n");
 		goto bad;
@@ -562,7 +544,10 @@ mpt_pci_attach(device_t dev)
 
 	if (mpt->eh == NULL) {
 		mpt_prt(mpt, "shutdown event registration failed\n");
+		mpt_disable_ints(mpt);
 		(void) mpt_detach(mpt);
+		mpt_reset(mpt, /*reinit*/FALSE);
+		mpt_raid_free_mem(mpt);
 		goto bad;
 	}
 	return (0);
@@ -570,7 +555,9 @@ mpt_pci_attach(device_t dev)
 bad:
 	mpt_dma_mem_free(mpt);
 	mpt_free_bus_resources(mpt);
+#if 0
 	mpt_unlink_peer(mpt);
+#endif
 
 	MPT_LOCK_DESTROY(mpt);
 
@@ -595,25 +582,21 @@ mpt_free_bus_resources(struct mpt_softc 
 	if (mpt->pci_irq) {
 		bus_release_resource(mpt->dev, SYS_RES_IRQ,
 		    rman_get_rid(mpt->pci_irq), mpt->pci_irq);
+		pci_release_msi(mpt->dev);
 		mpt->pci_irq = NULL;
 	}
 
-	if (mpt->pci_msi_count) {
-		pci_release_msi(mpt->dev);
-		mpt->pci_msi_count = 0;
-	}
-		
 	if (mpt->pci_pio_reg) {
 		bus_release_resource(mpt->dev, SYS_RES_IOPORT,
 		    rman_get_rid(mpt->pci_pio_reg), mpt->pci_pio_reg);
 		mpt->pci_pio_reg = NULL;
 	}
+
 	if (mpt->pci_reg) {
 		bus_release_resource(mpt->dev, SYS_RES_MEMORY,
 		    rman_get_rid(mpt->pci_reg), mpt->pci_reg);
 		mpt->pci_reg = NULL;
 	}
-	MPT_LOCK_DESTROY(mpt);
 }
 
 /*
@@ -630,12 +613,16 @@ mpt_pci_detach(device_t dev)
 		mpt_disable_ints(mpt);
 		mpt_detach(mpt);
 		mpt_reset(mpt, /*reinit*/FALSE);
+		mpt_raid_free_mem(mpt);
 		mpt_dma_mem_free(mpt);
 		mpt_free_bus_resources(mpt);
-		mpt_raid_free_mem(mpt);
+#if 0
+		mpt_unlink_peer(mpt);
+#endif
 		if (mpt->eh != NULL) {
                         EVENTHANDLER_DEREGISTER(shutdown_post_sync, mpt->eh);
 		}
+		MPT_LOCK_DESTROY(mpt);
 	}
 	return(0);
 }
@@ -649,11 +636,8 @@ mpt_pci_shutdown(device_t dev)
 	struct mpt_softc *mpt;
 
 	mpt = (struct mpt_softc *)device_get_softc(dev);
-	if (mpt) {
-		int r;
-		r = mpt_shutdown(mpt);
-		return (r);
-	}
+	if (mpt)
+		return (mpt_shutdown(mpt));
 	return(0);
 }
 
@@ -669,20 +653,11 @@ mpt_dma_mem_alloc(struct mpt_softc *mpt)
 	}
 
 	len = sizeof (request_t) * MPT_MAX_REQUESTS(mpt);
-#ifdef	RELENG_4
-	mpt->request_pool = (request_t *)malloc(len, M_DEVBUF, M_WAITOK);
-	if (mpt->request_pool == NULL) {
-		mpt_prt(mpt, "cannot allocate request pool\n");
-		return (1);
-	}
-	memset(mpt->request_pool, 0, len);
-#else
 	mpt->request_pool = (request_t *)malloc(len, M_DEVBUF, M_WAITOK|M_ZERO);
 	if (mpt->request_pool == NULL) {
 		mpt_prt(mpt, "cannot allocate request pool\n");
 		return (1);
 	}
-#endif
 
 	/*
 	 * Create a parent dma tag for this device.

Modified: stable/10/sys/dev/mpt/mpt_raid.c
==============================================================================
--- stable/10/sys/dev/mpt/mpt_raid.c	Fri Apr 25 21:58:28 2014	(r264948)
+++ stable/10/sys/dev/mpt/mpt_raid.c	Fri Apr 25 22:01:02 2014	(r264949)
@@ -636,7 +636,7 @@ mpt_spawn_raid_thread(struct mpt_softc *
 	MPT_LOCK(mpt);
 	xpt_freeze_simq(mpt->phydisk_sim, 1);
 	MPT_UNLOCK(mpt);
-	error = mpt_kthread_create(mpt_raid_thread, mpt,
+	error = kproc_create(mpt_raid_thread, mpt,
 	    &mpt->raid_thread, /*flags*/0, /*altstack*/0,
 	    "mpt_raid%d", mpt->unit);
 	if (error != 0) {
@@ -719,7 +719,7 @@ mpt_raid_thread(void *arg)
 	mpt->raid_thread = NULL;
 	wakeup(&mpt->raid_thread);
 	MPT_UNLOCK(mpt);
-	mpt_kthread_exit(0);
+	kproc_exit(0);
 }
 
 #if 0



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404252201.s3PM137U063397>