Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Feb 2020 19:15:08 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r358351 - in head/sys/dev: mpr mps
Message-ID:  <202002261915.01QJF886052426@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Wed Feb 26 19:15:08 2020
New Revision: 358351
URL: https://svnweb.freebsd.org/changeset/base/358351

Log:
  Remove support for all pre FreeBSD 11.0 versions from mpr and mps.
  
  Remove a number of workarounds for older versions of FreeBSD. FreeBSD stable/10
  was branched over 6 years ago. All of these changes date from about that time or
  earlier. These workarounds are extensive and get in the way of understanding
  the current flow in the driver.

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mpr/mpr_sas_lsi.c
  head/sys/dev/mpr/mprvar.h
  head/sys/dev/mps/mps_sas.c
  head/sys/dev/mps/mps_sas_lsi.c
  head/sys/dev/mps/mpsvar.h

Modified: head/sys/dev/mpr/mpr.c
==============================================================================
--- head/sys/dev/mpr/mpr.c	Wed Feb 26 19:12:36 2020	(r358350)
+++ head/sys/dev/mpr/mpr.c	Wed Feb 26 19:15:08 2020	(r358351)
@@ -165,11 +165,7 @@ mpr_diag_reset(struct mpr_softc *sc,int sleep_flag)
 	 * Force NO_SLEEP for threads prohibited to sleep
  	 * e.a Thread from interrupt handler are prohibited to sleep.
  	 */
-#if __FreeBSD_version >= 1000029
 	if (curthread->td_no_sleeping)
-#else //__FreeBSD_version < 1000029
-	if (curthread->td_pflags & TDP_NOSLEEPING)
-#endif //__FreeBSD_version >= 1000029
 		sleep_flag = NO_SLEEP;
 
 	mpr_dprint(sc, MPR_INIT, "sequence start, sleep_flag=%d\n", sleep_flag);
@@ -1005,11 +1001,7 @@ mpr_request_sync(struct mpr_softc *sc, void *req, MPI2
 	int i, count, ioc_sz, residual;
 	int sleep_flags = CAN_SLEEP;
 	
-#if __FreeBSD_version >= 1000029
 	if (curthread->td_no_sleeping)
-#else //__FreeBSD_version < 1000029
-	if (curthread->td_pflags & TDP_NOSLEEPING)
-#endif //__FreeBSD_version >= 1000029
 		sleep_flags = NO_SLEEP;
 
 	/* Step 1 */
@@ -3762,11 +3754,7 @@ mpr_wait_command(struct mpr_softc *sc, struct mpr_comm
 	// Check for context and wait for 50 mSec at a time until time has
 	// expired or the command has finished.  If msleep can't be used, need
 	// to poll.
-#if __FreeBSD_version >= 1000029
 	if (curthread->td_no_sleeping)
-#else //__FreeBSD_version < 1000029
-	if (curthread->td_pflags & TDP_NOSLEEPING)
-#endif //__FreeBSD_version >= 1000029
 		sleep_flag = NO_SLEEP;
 	getmicrouptime(&start_time);
 	if (mtx_owned(&sc->mpr_mtx) && sleep_flag == CAN_SLEEP) {

Modified: head/sys/dev/mpr/mpr_sas.c
==============================================================================
--- head/sys/dev/mpr/mpr_sas.c	Wed Feb 26 19:12:36 2020	(r358350)
+++ head/sys/dev/mpr/mpr_sas.c	Wed Feb 26 19:15:08 2020	(r358351)
@@ -69,9 +69,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_periph.h>
 #include <cam/scsi/scsi_all.h>
 #include <cam/scsi/scsi_message.h>
-#if __FreeBSD_version >= 900026
 #include <cam/scsi/smp_all.h>
-#endif
 
 #include <dev/nvme/nvme.h>
 
@@ -132,23 +130,14 @@ static int mprsas_send_abort(struct mpr_softc *sc, str
     struct mpr_command *cm);
 static void mprsas_async(void *callback_arg, uint32_t code,
     struct cam_path *path, void *arg);
-#if (__FreeBSD_version < 901503) || \
-    ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006))
-static void mprsas_check_eedp(struct mpr_softc *sc, struct cam_path *path,
-    struct ccb_getdev *cgd);
-static void mprsas_read_cap_done(struct cam_periph *periph,
-    union ccb *done_ccb);
-#endif
 static int mprsas_send_portenable(struct mpr_softc *sc);
 static void mprsas_portenable_complete(struct mpr_softc *sc,
     struct mpr_command *cm);
 
-#if __FreeBSD_version >= 900026
 static void mprsas_smpio_complete(struct mpr_softc *sc, struct mpr_command *cm);
 static void mprsas_send_smpcmd(struct mprsas_softc *sassc, union ccb *ccb,
     uint64_t sasaddr);
 static void mprsas_action_smpio(struct mprsas_softc *sassc, union ccb *ccb);
-#endif //FreeBSD_version >= 900026
 
 struct mprsas_target *
 mprsas_find_target_by_handle(struct mprsas_softc *sassc, int start,
@@ -183,10 +172,7 @@ mprsas_startup_increment(struct mprsas_softc *sassc)
 			/* just starting, freeze the simq */
 			mpr_dprint(sassc->sc, MPR_INIT,
 			    "%s freezing simq\n", __func__);
-#if (__FreeBSD_version >= 1000039) || \
-    ((__FreeBSD_version < 1000000) && (__FreeBSD_version >= 902502))
 			xpt_hold_boot();
-#endif
 			xpt_freeze_simq(sassc->sim, 1);
 		}
 		mpr_dprint(sassc->sc, MPR_INIT, "%s refcount %u\n", __func__,
@@ -218,12 +204,7 @@ mprsas_startup_decrement(struct mprsas_softc *sassc)
 			    "%s releasing simq\n", __func__);
 			sassc->flags &= ~MPRSAS_IN_STARTUP;
 			xpt_release_simq(sassc->sim, 1);
-#if (__FreeBSD_version >= 1000039) || \
-    ((__FreeBSD_version < 1000000) && (__FreeBSD_version >= 902502))
 			xpt_release_boot();
-#else
-			mprsas_rescan_target(sassc->sc, NULL);
-#endif
 		}
 		mpr_dprint(sassc->sc, MPR_INIT, "%s refcount %u\n", __func__,
 		    sassc->startup_refcount);
@@ -843,54 +824,9 @@ mpr_attach_sas(struct mpr_softc *sc)
 	} else {
 		int event;
 
-#if (__FreeBSD_version >= 1000006) || \
-    ((__FreeBSD_version >= 901503) && (__FreeBSD_version < 1000000))
 		event = AC_ADVINFO_CHANGED | AC_FOUND_DEVICE;
-#else
-		event = AC_FOUND_DEVICE;
-#endif
-
-		/*
-		 * Prior to the CAM locking improvements, we can't call
-		 * xpt_register_async() with a particular path specified.
-		 *
-		 * If a path isn't specified, xpt_register_async() will
-		 * generate a wildcard path and acquire the XPT lock while
-		 * it calls xpt_action() to execute the XPT_SASYNC_CB CCB.
-		 * It will then drop the XPT lock once that is done.
-		 * 
-		 * If a path is specified for xpt_register_async(), it will
-		 * not acquire and drop the XPT lock around the call to
-		 * xpt_action().  xpt_action() asserts that the caller
-		 * holds the SIM lock, so the SIM lock has to be held when
-		 * calling xpt_register_async() when the path is specified.
-		 * 
-		 * But xpt_register_async calls xpt_for_all_devices(),
-		 * which calls xptbustraverse(), which will acquire each
-		 * SIM lock.  When it traverses our particular bus, it will
-		 * necessarily acquire the SIM lock, which will lead to a
-		 * recursive lock acquisition.
-		 * 
-		 * The CAM locking changes fix this problem by acquiring
-		 * the XPT topology lock around bus traversal in
-		 * xptbustraverse(), so the caller can hold the SIM lock
-		 * and it does not cause a recursive lock acquisition.
-		 *
-		 * These __FreeBSD_version values are approximate, especially
-		 * for stable/10, which is two months later than the actual
-		 * change.
-		 */
-
-#if (__FreeBSD_version < 1000703) || \
-    ((__FreeBSD_version >= 1100000) && (__FreeBSD_version < 1100002))
-		mpr_unlock(sc);
 		status = xpt_register_async(event, mprsas_async, sc,
-					    NULL);
-		mpr_lock(sc);
-#else
-		status = xpt_register_async(event, mprsas_async, sc,
 					    sassc->path);
-#endif
 
 		if (status != CAM_REQ_CMP) {
 			mpr_dprint(sc, MPR_ERROR,
@@ -1034,12 +970,7 @@ mprsas_action(struct cam_sim *sim, union ccb *ccb)
 		cpi->version_num = 1;
 		cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
 		cpi->target_sprt = 0;
-#if (__FreeBSD_version >= 1000039) || \
-    ((__FreeBSD_version < 1000000) && (__FreeBSD_version >= 902502))
 		cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | PIM_NOSCAN;
-#else
-		cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED;
-#endif
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = sassc->maxtargets - 1;
 		cpi->max_lun = 255;
@@ -1135,11 +1066,9 @@ mprsas_action(struct cam_sim *sim, union ccb *ccb)
 	case XPT_SCSI_IO:
 		mprsas_action_scsiio(sassc, ccb);
 		return;
-#if __FreeBSD_version >= 900026
 	case XPT_SMP_IO:
 		mprsas_action_smpio(sassc, ccb);
 		return;
-#endif
 	default:
 		mprsas_set_ccbstatus(ccb, CAM_FUNC_NOTAVAIL);
 		break;
@@ -1789,17 +1718,7 @@ mprsas_build_nvme_unmap(struct mpr_softc *sc, struct m
 	uint64_t nvme_dsm_ranges_dma_handle;
 
 	csio = &ccb->csio;
-#if __FreeBSD_version >= 1100103
 	list_len = (scsiio_cdb_ptr(csio)[7] << 8 | scsiio_cdb_ptr(csio)[8]);
-#else
-	if (csio->ccb_h.flags & CAM_CDB_POINTER) {
-		list_len = (ccb->csio.cdb_io.cdb_ptr[7] << 8 |
-		    ccb->csio.cdb_io.cdb_ptr[8]);
-	} else {
-		list_len = (ccb->csio.cdb_io.cdb_bytes[7] << 8 |
-		    ccb->csio.cdb_io.cdb_bytes[8]);
-	}
-#endif
 	if (!list_len) {
 		mpr_dprint(sc, MPR_ERROR, "Parameter list length is Zero\n");
 		return -EINVAL;
@@ -1896,13 +1815,8 @@ mprsas_build_nvme_unmap(struct mpr_softc *sc, struct m
 	    MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED;
 
 	csio->ccb_h.qos.sim_data = sbinuptime();
-#if __FreeBSD_version >= 1000029
 	callout_reset_sbt(&cm->cm_callout, SBT_1MS * ccb->ccb_h.timeout, 0,
 	    mprsas_scsiio_timeout, cm, 0);
-#else //__FreeBSD_version < 1000029
-	callout_reset(&cm->cm_callout, (ccb->ccb_h.timeout * hz) / 1000,
-	    mprsas_scsiio_timeout, cm);
-#endif //__FreeBSD_version >= 1000029
 
 	targ->issued++;
 	targ->outstanding++;
@@ -2026,14 +1940,7 @@ mprsas_action_scsiio(struct mprsas_softc *sassc, union
 	/* For NVME device's issue UNMAP command directly to NVME drives by
 	 * constructing equivalent native NVMe DataSetManagement command.
 	 */
-#if __FreeBSD_version >= 1100103
 	scsi_opcode = scsiio_cdb_ptr(csio)[0];
-#else
-	if (csio->ccb_h.flags & CAM_CDB_POINTER)
-		scsi_opcode = csio->cdb_io.cdb_ptr[0];
-	else
-		scsi_opcode = csio->cdb_io.cdb_bytes[0];
-#endif
 	if (scsi_opcode == UNMAP &&
 	    targ->is_nvme &&
 	    (csio->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) {
@@ -2219,13 +2126,8 @@ mprsas_action_scsiio(struct mprsas_softc *sassc, union
 	}
 
 	csio->ccb_h.qos.sim_data = sbinuptime();
-#if __FreeBSD_version >= 1000029
 	callout_reset_sbt(&cm->cm_callout, SBT_1MS * ccb->ccb_h.timeout, 0,
 	    mprsas_scsiio_timeout, cm, 0);
-#else //__FreeBSD_version < 1000029
-	callout_reset(&cm->cm_callout, (ccb->ccb_h.timeout * hz) / 1000,
-	    mprsas_scsiio_timeout, cm);
-#endif //__FreeBSD_version >= 1000029
 
 	targ->issued++;
 	targ->outstanding++;
@@ -2610,14 +2512,7 @@ mprsas_scsiio_complete(struct mpr_softc *sc, struct mp
 	 * flag, and use it in a few places in the rest of this function for
 	 * convenience. Use the macro if available.
 	 */
-#if __FreeBSD_version >= 1100103
 	scsi_cdb = scsiio_cdb_ptr(csio);
-#else
-	if (csio->ccb_h.flags & CAM_CDB_POINTER)
-		scsi_cdb = csio->cdb_io.cdb_ptr;
-	else
-		scsi_cdb = csio->cdb_io.cdb_bytes;
-#endif
 
 	/*
 	 * If this is a Start Stop Unit command and it was issued by the driver
@@ -2939,7 +2834,6 @@ mprsas_scsiio_complete(struct mpr_softc *sc, struct mp
 	xpt_done(ccb);
 }
 
-#if __FreeBSD_version >= 900026
 static void
 mprsas_smpio_complete(struct mpr_softc *sc, struct mpr_command *cm)
 {
@@ -3017,8 +2911,6 @@ mprsas_send_smpcmd(struct mprsas_softc *sassc, union c
 	sg = NULL;
 	error = 0;
 
-#if (__FreeBSD_version >= 1000028) || \
-    ((__FreeBSD_version >= 902001) && (__FreeBSD_version < 1000000))
 	switch (ccb->ccb_h.flags & CAM_DATA_MASK) {
 	case CAM_DATA_PADDR:
 	case CAM_DATA_SG_PADDR:
@@ -3078,66 +2970,7 @@ mprsas_send_smpcmd(struct mprsas_softc *sassc, union c
 		xpt_done(ccb);
 		return;
 	}
-#else /* __FreeBSD_version < 1000028 */
-	/*
-	 * XXX We don't yet support physical addresses here.
-	 */
-	if (ccb->ccb_h.flags & (CAM_DATA_PHYS|CAM_SG_LIST_PHYS)) {
-		mpr_dprint(sc, MPR_ERROR, "%s: physical addresses not "
-		    "supported\n", __func__);
-		mprsas_set_ccbstatus(ccb, CAM_REQ_INVALID);
-		xpt_done(ccb);
-		return;
-	}
 
-	/*
-	 * If the user wants to send an S/G list, check to make sure they
-	 * have single buffers.
-	 */
-	if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
-		/*
-		 * The chip does not support more than one buffer for the
-		 * request or response.
-		 */
-	 	if ((ccb->smpio.smp_request_sglist_cnt > 1)
-		  || (ccb->smpio.smp_response_sglist_cnt > 1)) {
-			mpr_dprint(sc, MPR_ERROR, "%s: multiple request or "
-			    "response buffer segments not supported for SMP\n",
-			    __func__);
-			mprsas_set_ccbstatus(ccb, CAM_REQ_INVALID);
-			xpt_done(ccb);
-			return;
-		}
-
-		/*
-		 * The CAM_SCATTER_VALID flag was originally implemented
-		 * for the XPT_SCSI_IO CCB, which only has one data pointer.
-		 * We have two.  So, just take that flag to mean that we
-		 * might have S/G lists, and look at the S/G segment count
-		 * to figure out whether that is the case for each individual
-		 * buffer.
-		 */
-		if (ccb->smpio.smp_request_sglist_cnt != 0) {
-			bus_dma_segment_t *req_sg;
-
-			req_sg = (bus_dma_segment_t *)ccb->smpio.smp_request;
-			request = (uint8_t *)(uintptr_t)req_sg[0].ds_addr;
-		} else
-			request = ccb->smpio.smp_request;
-
-		if (ccb->smpio.smp_response_sglist_cnt != 0) {
-			bus_dma_segment_t *rsp_sg;
-
-			rsp_sg = (bus_dma_segment_t *)ccb->smpio.smp_response;
-			response = (uint8_t *)(uintptr_t)rsp_sg[0].ds_addr;
-		} else
-			response = ccb->smpio.smp_response;
-	} else {
-		request = ccb->smpio.smp_request;
-		response = ccb->smpio.smp_response;
-	}
-#endif /* __FreeBSD_version < 1000028 */
-
 	cm = mpr_alloc_command(sc);
 	if (cm == NULL) {
 		mpr_dprint(sc, MPR_ERROR, "%s: cannot allocate command\n",
@@ -3361,7 +3194,6 @@ bailout:
 	xpt_done(ccb);
 
 }
-#endif //__FreeBSD_version >= 900026
 
 static void
 mprsas_action_resetdev(struct mprsas_softc *sassc, union ccb *ccb)
@@ -3486,8 +3318,6 @@ mprsas_async(void *callback_arg, uint32_t code, struct
 	sc = (struct mpr_softc *)callback_arg;
 
 	switch (code) {
-#if (__FreeBSD_version >= 1000006) || \
-    ((__FreeBSD_version >= 901503) && (__FreeBSD_version < 1000000))
 	case AC_ADVINFO_CHANGED: {
 		struct mprsas_target *target;
 		struct mprsas_softc *sassc;
@@ -3510,18 +3340,6 @@ mprsas_async(void *callback_arg, uint32_t code, struct
 			break;
 
 		/*
-		 * See the comment in mpr_attach_sas() for a detailed
-		 * explanation.  In these versions of FreeBSD we register
-		 * for all events and filter out the events that don't
-		 * apply to us.
-		 */
-#if (__FreeBSD_version < 1000703) || \
-    ((__FreeBSD_version >= 1100000) && (__FreeBSD_version < 1100002))
-		if (xpt_path_path_id(path) != sassc->sim->path_id)
-			break;
-#endif
-
-		/*
 		 * We should have a handle for this, but check to make sure.
 		 */
 		KASSERT(xpt_path_target_id(path) < sassc->maxtargets,
@@ -3557,12 +3375,7 @@ mprsas_async(void *callback_arg, uint32_t code, struct
 		cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
 		cdai.ccb_h.flags = CAM_DIR_IN;
 		cdai.buftype = CDAI_TYPE_RCAPLONG;
-#if (__FreeBSD_version >= 1100061) || \
-    ((__FreeBSD_version >= 1001510) && (__FreeBSD_version < 1100000))
 		cdai.flags = CDAI_FLAG_NONE;
-#else
-		cdai.flags = 0;
-#endif
 		cdai.bufsiz = sizeof(rcap_buf);
 		cdai.buf = (uint8_t *)&rcap_buf;
 		xpt_action((union ccb *)&cdai);
@@ -3590,228 +3403,11 @@ mprsas_async(void *callback_arg, uint32_t code, struct
 		}
 		break;
 	}
-#endif
-	case AC_FOUND_DEVICE: {
-		struct ccb_getdev *cgd;
-
-		/*
-		 * See the comment in mpr_attach_sas() for a detailed
-		 * explanation.  In these versions of FreeBSD we register
-		 * for all events and filter out the events that don't
-		 * apply to us.
-		 */
-#if (__FreeBSD_version < 1000703) || \
-    ((__FreeBSD_version >= 1100000) && (__FreeBSD_version < 1100002))
-		if (xpt_path_path_id(path) != sc->sassc->sim->path_id)
-			break;
-#endif
-
-		cgd = arg;
-#if (__FreeBSD_version < 901503) || \
-    ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006))
-		mprsas_check_eedp(sc, path, cgd);
-#endif
-		break;
-	}
+	case AC_FOUND_DEVICE:
 	default:
 		break;
 	}
 }
-
-#if (__FreeBSD_version < 901503) || \
-    ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006))
-static void
-mprsas_check_eedp(struct mpr_softc *sc, struct cam_path *path,
-    struct ccb_getdev *cgd)
-{
-	struct mprsas_softc *sassc = sc->sassc;
-	struct ccb_scsiio *csio;
-	struct scsi_read_capacity_16 *scsi_cmd;
-	struct scsi_read_capacity_eedp *rcap_buf;
-	path_id_t pathid;
-	target_id_t targetid;
-	lun_id_t lunid;
-	union ccb *ccb;
-	struct cam_path *local_path;
-	struct mprsas_target *target;
-	struct mprsas_lun *lun;
-	uint8_t	found_lun;
-	char path_str[64];
-
-	pathid = cam_sim_path(sassc->sim);
-	targetid = xpt_path_target_id(path);
-	lunid = xpt_path_lun_id(path);
-
-	KASSERT(targetid < sassc->maxtargets, ("Target %d out of bounds in "
-	    "mprsas_check_eedp\n", targetid));
-	target = &sassc->targets[targetid];
-	if (target->handle == 0x0)
-		return;
-
-	/*
-	 * Determine if the device is EEDP capable.
-	 *
-	 * If this flag is set in the inquiry data, the device supports
-	 * protection information, and must support the 16 byte read capacity
-	 * command, otherwise continue without sending read cap 16.
-	 */
-	if ((cgd->inq_data.spc3_flags & SPC3_SID_PROTECT) == 0)
-		return;
-
-	/*
-	 * Issue a READ CAPACITY 16 command.  This info is used to determine if
-	 * the LUN is formatted for EEDP support.
-	 */
-	ccb = xpt_alloc_ccb_nowait();
-	if (ccb == NULL) {
-		mpr_dprint(sc, MPR_ERROR, "Unable to alloc CCB for EEDP "
-		    "support.\n");
-		return;
-	}
-
-	if (xpt_create_path(&local_path, xpt_periph, pathid, targetid, lunid) !=
-	    CAM_REQ_CMP) {
-		mpr_dprint(sc, MPR_ERROR, "Unable to create path for EEDP "
-		    "support.\n");
-		xpt_free_ccb(ccb);
-		return;
-	}
-
-	/*
-	 * If LUN is already in list, don't create a new one.
-	 */
-	found_lun = FALSE;
-	SLIST_FOREACH(lun, &target->luns, lun_link) {
-		if (lun->lun_id == lunid) {
-			found_lun = TRUE;
-			break;
-		}
-	}
-	if (!found_lun) {
-		lun = malloc(sizeof(struct mprsas_lun), M_MPR,
-		    M_NOWAIT | M_ZERO);
-		if (lun == NULL) {
-			mpr_dprint(sc, MPR_ERROR, "Unable to alloc LUN for "
-			    "EEDP support.\n");
-			xpt_free_path(local_path);
-			xpt_free_ccb(ccb);
-			return;
-		}
-		lun->lun_id = lunid;
-		SLIST_INSERT_HEAD(&target->luns, lun, lun_link);
-	}
-
-	xpt_path_string(local_path, path_str, sizeof(path_str));
-	mpr_dprint(sc, MPR_INFO, "Sending read cap: path %s handle %d\n",
-	    path_str, target->handle);
-
-	/*
-	 * Issue a READ CAPACITY 16 command for the LUN.  The
-	 * mprsas_read_cap_done function will load the read cap info into the
-	 * LUN struct.
-	 */
-	rcap_buf = malloc(sizeof(struct scsi_read_capacity_eedp), M_MPR,
-	    M_NOWAIT | M_ZERO);
-	if (rcap_buf == NULL) {
-		mpr_dprint(sc, MPR_ERROR, "Unable to alloc read capacity "
-		    "buffer for EEDP support.\n");
-		xpt_free_path(ccb->ccb_h.path);
-		xpt_free_ccb(ccb);
-		return;
-	}
-	xpt_setup_ccb(&ccb->ccb_h, local_path, CAM_PRIORITY_XPT);
-	csio = &ccb->csio;
-	csio->ccb_h.func_code = XPT_SCSI_IO;
-	csio->ccb_h.flags = CAM_DIR_IN;
-	csio->ccb_h.retry_count = 4;	
-	csio->ccb_h.cbfcnp = mprsas_read_cap_done;
-	csio->ccb_h.timeout = 60000;
-	csio->data_ptr = (uint8_t *)rcap_buf;
-	csio->dxfer_len = sizeof(struct scsi_read_capacity_eedp);
-	csio->sense_len = MPR_SENSE_LEN;
-	csio->cdb_len = sizeof(*scsi_cmd);
-	csio->tag_action = MSG_SIMPLE_Q_TAG;
-
-	scsi_cmd = (struct scsi_read_capacity_16 *)&csio->cdb_io.cdb_bytes;
-	bzero(scsi_cmd, sizeof(*scsi_cmd));
-	scsi_cmd->opcode = 0x9E;
-	scsi_cmd->service_action = SRC16_SERVICE_ACTION;
-	((uint8_t *)scsi_cmd)[13] = sizeof(struct scsi_read_capacity_eedp);
-
-	ccb->ccb_h.ppriv_ptr1 = sassc;
-	xpt_action(ccb);
-}
-
-static void
-mprsas_read_cap_done(struct cam_periph *periph, union ccb *done_ccb)
-{
-	struct mprsas_softc *sassc;
-	struct mprsas_target *target;
-	struct mprsas_lun *lun;
-	struct scsi_read_capacity_eedp *rcap_buf;
-
-	if (done_ccb == NULL)
-		return;
-	
-	/* Driver need to release devq, it Scsi command is
-	 * generated by driver internally.
-	 * Currently there is a single place where driver
-	 * calls scsi command internally. In future if driver
-	 * calls more scsi command internally, it needs to release
-	 * devq internally, since those command will not go back to
-	 * cam_periph.
-	 */
-	if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) ) {
-        	done_ccb->ccb_h.status &= ~CAM_DEV_QFRZN;
-		xpt_release_devq(done_ccb->ccb_h.path,
-			       	/*count*/ 1, /*run_queue*/TRUE);
-	}
-
-	rcap_buf = (struct scsi_read_capacity_eedp *)done_ccb->csio.data_ptr;
-
-	/*
-	 * Get the LUN ID for the path and look it up in the LUN list for the
-	 * target.
-	 */
-	sassc = (struct mprsas_softc *)done_ccb->ccb_h.ppriv_ptr1;
-	KASSERT(done_ccb->ccb_h.target_id < sassc->maxtargets, ("Target %d out "
-	    "of bounds in mprsas_read_cap_done\n", done_ccb->ccb_h.target_id));
-	target = &sassc->targets[done_ccb->ccb_h.target_id];
-	SLIST_FOREACH(lun, &target->luns, lun_link) {
-		if (lun->lun_id != done_ccb->ccb_h.target_lun)
-			continue;
-
-		/*
-		 * Got the LUN in the target's LUN list.  Fill it in with EEDP
-		 * info. If the READ CAP 16 command had some SCSI error (common
-		 * if command is not supported), mark the lun as not supporting
-		 * EEDP and set the block size to 0.
-		 */
-		if ((mprsas_get_ccbstatus(done_ccb) != CAM_REQ_CMP) ||
-		    (done_ccb->csio.scsi_status != SCSI_STATUS_OK)) {
-			lun->eedp_formatted = FALSE;
-			lun->eedp_block_size = 0;
-			break;
-		}
-
-		if (rcap_buf->protect & 0x01) {
-			mpr_dprint(sassc->sc, MPR_INFO, "LUN %d for target ID "
-			    "%d is formatted for EEDP support.\n",
-			    done_ccb->ccb_h.target_lun,
-			    done_ccb->ccb_h.target_id);
-			lun->eedp_formatted = TRUE;
-			lun->eedp_block_size = scsi_4btoul(rcap_buf->length);
-		}
-		break;
-	}
-
-	// Finished with this CCB and path.
-	free(rcap_buf, M_MPR);
-	xpt_free_path(done_ccb->ccb_h.path);
-	xpt_free_ccb(done_ccb);
-}
-#endif /* (__FreeBSD_version < 901503) || \
-          ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006)) */
 
 /*
  * Set the INRESET flag for this target so that no I/O will be sent to

Modified: head/sys/dev/mpr/mpr_sas_lsi.c
==============================================================================
--- head/sys/dev/mpr/mpr_sas_lsi.c	Wed Feb 26 19:12:36 2020	(r358350)
+++ head/sys/dev/mpr/mpr_sas_lsi.c	Wed Feb 26 19:15:08 2020	(r358351)
@@ -998,11 +998,7 @@ mprsas_add_device(struct mpr_softc *sc, u16 handle, u8
 		    "and connector name (%4s)\n", targ->encl_level,
 		    targ->connector_name);
 	}
-#if ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000039)) || \
-    (__FreeBSD_version < 902502)
-	if ((sassc->flags & MPRSAS_IN_STARTUP) == 0)
-#endif
-		mprsas_rescan_target(sc, targ);
+	mprsas_rescan_target(sc, targ);
 	mpr_dprint(sc, MPR_MAPPING, "Target id 0x%x added\n", targ->tid);
 
 	/*
@@ -1379,11 +1375,7 @@ mprsas_add_pcie_device(struct mpr_softc *sc, u16 handl
 		    "and connector name (%4s)\n", targ->encl_level,
 		    targ->connector_name);
 	}
-#if ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000039)) || \
-    (__FreeBSD_version < 902502)
-	if ((sassc->flags & MPRSAS_IN_STARTUP) == 0)
-#endif
-		mprsas_rescan_target(sc, targ);
+	mprsas_rescan_target(sc, targ);
 	mpr_dprint(sc, MPR_MAPPING, "Target id 0x%x added\n", targ->tid);
 
 out:
@@ -1433,11 +1425,7 @@ mprsas_volume_add(struct mpr_softc *sc, u16 handle)
 		free(lun, M_MPR);
 	}
 	SLIST_INIT(&targ->luns);
-#if ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000039)) || \
-    (__FreeBSD_version < 902502)
-	if ((sassc->flags & MPRSAS_IN_STARTUP) == 0)
-#endif
-		mprsas_rescan_target(sc, targ);
+	mprsas_rescan_target(sc, targ);
 	mpr_dprint(sc, MPR_MAPPING, "RAID target id %d added (WWID = 0x%jx)\n",
 	    targ->tid, wwid);
 out:

Modified: head/sys/dev/mpr/mprvar.h
==============================================================================
--- head/sys/dev/mpr/mprvar.h	Wed Feb 26 19:12:36 2020	(r358350)
+++ head/sys/dev/mpr/mprvar.h	Wed Feb 26 19:15:08 2020	(r358351)
@@ -909,35 +909,14 @@ int mprsas_send_reset(struct mpr_softc *sc, struct mpr
 SYSCTL_DECL(_hw_mpr);
 
 /* Compatibility shims for different OS versions */
-#if __FreeBSD_version >= 800001
 #define mpr_kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
     kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
 #define mpr_kproc_exit(arg)	kproc_exit(arg)
-#else
-#define mpr_kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \
-    kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg)
-#define mpr_kproc_exit(arg)	kthread_exit(arg)
-#endif
 
 #if defined(CAM_PRIORITY_XPT)
 #define MPR_PRIORITY_XPT	CAM_PRIORITY_XPT
 #else
 #define MPR_PRIORITY_XPT	5
-#endif
-
-#if __FreeBSD_version < 800107
-// Prior to FreeBSD-8.0 scp3_flags was not defined.
-#define spc3_flags reserved
-
-#define SPC3_SID_PROTECT    0x01
-#define SPC3_SID_3PC        0x08
-#define SPC3_SID_TPGS_MASK  0x30
-#define SPC3_SID_TPGS_IMPLICIT  0x10
-#define SPC3_SID_TPGS_EXPLICIT  0x20
-#define SPC3_SID_ACC        0x40
-#define SPC3_SID_SCCS       0x80
-
-#define CAM_PRIORITY_NORMAL CAM_PRIORITY_NONE
 #endif
 
 /* Definitions for SCSI unmap translation to NVMe DSM command */

Modified: head/sys/dev/mps/mps_sas.c
==============================================================================
--- head/sys/dev/mps/mps_sas.c	Wed Feb 26 19:12:36 2020	(r358350)
+++ head/sys/dev/mps/mps_sas.c	Wed Feb 26 19:15:08 2020	(r358351)
@@ -72,9 +72,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_periph.h>
 #include <cam/scsi/scsi_all.h>
 #include <cam/scsi/scsi_message.h>
-#if __FreeBSD_version >= 900026
 #include <cam/scsi/smp_all.h>
-#endif
 
 #include <dev/mps/mpi/mpi2_type.h>
 #include <dev/mps/mpi/mpi2.h>
@@ -131,21 +129,13 @@ static void mpssas_direct_drive_io(struct mpssas_softc
 static void mpssas_action_scsiio(struct mpssas_softc *, union ccb *);
 static void mpssas_scsiio_complete(struct mps_softc *, struct mps_command *);
 static void mpssas_action_resetdev(struct mpssas_softc *, union ccb *);
-#if __FreeBSD_version >= 900026
 static void mpssas_smpio_complete(struct mps_softc *sc, struct mps_command *cm);
 static void mpssas_send_smpcmd(struct mpssas_softc *sassc, union ccb *ccb,
 			       uint64_t sasaddr);
 static void mpssas_action_smpio(struct mpssas_softc *sassc, union ccb *ccb);
-#endif //FreeBSD_version >= 900026
 static void mpssas_resetdev_complete(struct mps_softc *, struct mps_command *);
 static void mpssas_async(void *callback_arg, uint32_t code,
 			 struct cam_path *path, void *arg);
-#if (__FreeBSD_version < 901503) || \
-    ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006))
-static void mpssas_check_eedp(struct mps_softc *sc, struct cam_path *path,
-			      struct ccb_getdev *cgd);
-static void mpssas_read_cap_done(struct cam_periph *periph, union ccb *done_ccb);
-#endif
 static int mpssas_send_portenable(struct mps_softc *sc);
 static void mpssas_portenable_complete(struct mps_softc *sc,
     struct mps_command *cm);
@@ -182,9 +172,7 @@ mpssas_startup_increment(struct mpssas_softc *sassc)
 			/* just starting, freeze the simq */
 			mps_dprint(sassc->sc, MPS_INIT,
 			    "%s freezing simq\n", __func__);
-#if __FreeBSD_version >= 1000039
 			xpt_hold_boot();
-#endif
 			xpt_freeze_simq(sassc->sim, 1);
 		}
 		mps_dprint(sassc->sc, MPS_INIT, "%s refcount %u\n", __func__,
@@ -216,11 +204,7 @@ mpssas_startup_decrement(struct mpssas_softc *sassc)
 			    "%s releasing simq\n", __func__);
 			sassc->flags &= ~MPSSAS_IN_STARTUP;
 			xpt_release_simq(sassc->sim, 1);
-#if __FreeBSD_version >= 1000039
 			xpt_release_boot();
-#else
-			mpssas_rescan_target(sassc->sc, NULL);
-#endif
 		}
 		mps_dprint(sassc->sc, MPS_INIT, "%s refcount %u\n", __func__,
 		    sassc->startup_refcount);
@@ -826,12 +810,7 @@ mps_attach_sas(struct mps_softc *sc)
 	} else {
 		int event;
 
-#if (__FreeBSD_version >= 1000006) || \
-    ((__FreeBSD_version >= 901503) && (__FreeBSD_version < 1000000))
 		event = AC_ADVINFO_CHANGED;
-#else
-		event = AC_FOUND_DEVICE;
-#endif
 		status = xpt_register_async(event, mpssas_async, sc,
 					    sassc->path);
 		if (status != CAM_REQ_CMP) {
@@ -976,11 +955,7 @@ mpssas_action(struct cam_sim *sim, union ccb *ccb)
 		cpi->version_num = 1;
 		cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
 		cpi->target_sprt = 0;
-#if __FreeBSD_version >= 1000039
 		cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | PIM_NOSCAN;
-#else
-		cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED;
-#endif
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = sassc->maxtargets - 1;
 		cpi->max_lun = 255;
@@ -1068,11 +1043,9 @@ mpssas_action(struct cam_sim *sim, union ccb *ccb)
 	case XPT_SCSI_IO:
 		mpssas_action_scsiio(sassc, ccb);
 		return;
-#if __FreeBSD_version >= 900026
 	case XPT_SMP_IO:
 		mpssas_action_smpio(sassc, ccb);
 		return;
-#endif
 	default:
 		mpssas_set_ccbstatus(ccb, CAM_FUNC_NOTAVAIL);
 		break;
@@ -2710,7 +2683,6 @@ mpssas_direct_drive_io(struct mpssas_softc *sassc, str
 	}
 }
 
-#if __FreeBSD_version >= 900026
 static void
 mpssas_smpio_complete(struct mps_softc *sc, struct mps_command *cm)
 {
@@ -3081,7 +3053,6 @@ bailout:
 	xpt_done(ccb);
 
 }
-#endif //__FreeBSD_version >= 900026
 
 static void
 mpssas_action_resetdev(struct mpssas_softc *sassc, union ccb *ccb)
@@ -3199,8 +3170,6 @@ mpssas_async(void *callback_arg, uint32_t code, struct
 	sc = (struct mps_softc *)callback_arg;
 
 	switch (code) {
-#if (__FreeBSD_version >= 1000006) || \
-    ((__FreeBSD_version >= 901503) && (__FreeBSD_version < 1000000))
 	case AC_ADVINFO_CHANGED: {
 		struct mpssas_target *target;
 		struct mpssas_softc *sassc;
@@ -3258,12 +3227,7 @@ mpssas_async(void *callback_arg, uint32_t code, struct
 		cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
 		cdai.ccb_h.flags = CAM_DIR_IN;
 		cdai.buftype = CDAI_TYPE_RCAPLONG;
-#if (__FreeBSD_version >= 1100061) || \
-    ((__FreeBSD_version >= 1001510) && (__FreeBSD_version < 1100000))
 		cdai.flags = CDAI_FLAG_NONE;
-#else
-		cdai.flags = 0;
-#endif
 		cdai.bufsiz = sizeof(rcap_buf);
 		cdai.buf = (uint8_t *)&rcap_buf;
 		xpt_action((union ccb *)&cdai);
@@ -3292,224 +3256,10 @@ mpssas_async(void *callback_arg, uint32_t code, struct
 		}
 		break;
 	}
-#else
-	case AC_FOUND_DEVICE: {
-		struct ccb_getdev *cgd;
-
-		cgd = arg;
-		mpssas_check_eedp(sc, path, cgd);
-		break;
-	}
-#endif
 	default:
 		break;
 	}
 }
-
-#if (__FreeBSD_version < 901503) || \
-    ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006))
-static void
-mpssas_check_eedp(struct mps_softc *sc, struct cam_path *path,
-		  struct ccb_getdev *cgd)
-{
-	struct mpssas_softc *sassc = sc->sassc;
-	struct ccb_scsiio *csio;
-	struct scsi_read_capacity_16 *scsi_cmd;
-	struct scsi_read_capacity_eedp *rcap_buf;
-	path_id_t pathid;
-	target_id_t targetid;
-	lun_id_t lunid;
-	union ccb *ccb;
-	struct cam_path *local_path;
-	struct mpssas_target *target;
-	struct mpssas_lun *lun;
-	uint8_t	found_lun;
-	char path_str[64];
-
-	sassc = sc->sassc;
-	pathid = cam_sim_path(sassc->sim);
-	targetid = xpt_path_target_id(path);
-	lunid = xpt_path_lun_id(path);
-
-	KASSERT(targetid < sassc->maxtargets,
-	    ("Target %d out of bounds in mpssas_check_eedp\n",
-	     targetid));
-	target = &sassc->targets[targetid];
-	if (target->handle == 0x0)
-		return;
-
-	/*
-	 * Determine if the device is EEDP capable.
-	 *
-	 * If this flag is set in the inquiry data, 
-	 * the device supports protection information,
-	 * and must support the 16 byte read
-	 * capacity command, otherwise continue without
-	 * sending read cap 16
-	 */
-	if ((cgd->inq_data.spc3_flags & SPC3_SID_PROTECT) == 0)
-		return;
-
-	/*
-	 * Issue a READ CAPACITY 16 command.  This info
-	 * is used to determine if the LUN is formatted
-	 * for EEDP support.
-	 */
-	ccb = xpt_alloc_ccb_nowait();
-	if (ccb == NULL) {
-		mps_dprint(sc, MPS_ERROR, "Unable to alloc CCB "
-		    "for EEDP support.\n");
-		return;
-	}
-
-	if (xpt_create_path(&local_path, xpt_periph,
-	    pathid, targetid, lunid) != CAM_REQ_CMP) {
-		mps_dprint(sc, MPS_ERROR, "Unable to create "
-		    "path for EEDP support\n");
-		xpt_free_ccb(ccb);
-		return;
-	}
-
-	/*
-	 * If LUN is already in list, don't create a new
-	 * one.
-	 */
-	found_lun = FALSE;
-	SLIST_FOREACH(lun, &target->luns, lun_link) {
-		if (lun->lun_id == lunid) {
-			found_lun = TRUE;
-			break;
-		}
-	}
-	if (!found_lun) {
-		lun = malloc(sizeof(struct mpssas_lun), M_MPT2,
-		    M_NOWAIT | M_ZERO);
-		if (lun == NULL) {
-			mps_dprint(sc, MPS_ERROR,
-			    "Unable to alloc LUN for EEDP support.\n");
-			xpt_free_path(local_path);
-			xpt_free_ccb(ccb);
-			return;
-		}
-		lun->lun_id = lunid;
-		SLIST_INSERT_HEAD(&target->luns, lun,
-		    lun_link);
-	}
-
-	xpt_path_string(local_path, path_str, sizeof(path_str));
-
-	mps_dprint(sc, MPS_INFO, "Sending read cap: path %s handle %d\n",
-	    path_str, target->handle);
-
-	/*
-	 * Issue a READ CAPACITY 16 command for the LUN.
-	 * The mpssas_read_cap_done function will load
-	 * the read cap info into the LUN struct.
-	 */
-	rcap_buf = malloc(sizeof(struct scsi_read_capacity_eedp),
-	    M_MPT2, M_NOWAIT | M_ZERO);
-	if (rcap_buf == NULL) {
-		mps_dprint(sc, MPS_FAULT,
-		    "Unable to alloc read capacity buffer for EEDP support.\n");
-		xpt_free_path(ccb->ccb_h.path);
-		xpt_free_ccb(ccb);
-		return;
-	}
-	xpt_setup_ccb(&ccb->ccb_h, local_path, CAM_PRIORITY_XPT);
-	csio = &ccb->csio;
-	csio->ccb_h.func_code = XPT_SCSI_IO;
-	csio->ccb_h.flags = CAM_DIR_IN;
-	csio->ccb_h.retry_count = 4;	
-	csio->ccb_h.cbfcnp = mpssas_read_cap_done;
-	csio->ccb_h.timeout = 60000;
-	csio->data_ptr = (uint8_t *)rcap_buf;
-	csio->dxfer_len = sizeof(struct scsi_read_capacity_eedp);
-	csio->sense_len = MPS_SENSE_LEN;
-	csio->cdb_len = sizeof(*scsi_cmd);
-	csio->tag_action = MSG_SIMPLE_Q_TAG;
-
-	scsi_cmd = (struct scsi_read_capacity_16 *)&csio->cdb_io.cdb_bytes;
-	bzero(scsi_cmd, sizeof(*scsi_cmd));
-	scsi_cmd->opcode = 0x9E;
-	scsi_cmd->service_action = SRC16_SERVICE_ACTION;
-	((uint8_t *)scsi_cmd)[13] = sizeof(struct scsi_read_capacity_eedp);
-
-	ccb->ccb_h.ppriv_ptr1 = sassc;
-	xpt_action(ccb);
-}
-
-static void
-mpssas_read_cap_done(struct cam_periph *periph, union ccb *done_ccb)
-{
-	struct mpssas_softc *sassc;
-	struct mpssas_target *target;
-	struct mpssas_lun *lun;
-	struct scsi_read_capacity_eedp *rcap_buf;
-
-	if (done_ccb == NULL)
-		return;
-	
-	/* Driver need to release devq, it Scsi command is
-	 * generated by driver internally.
-	 * Currently there is a single place where driver
-	 * calls scsi command internally. In future if driver
-	 * calls more scsi command internally, it needs to release
-	 * devq internally, since those command will not go back to
-	 * cam_periph.
-	 */
-	if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) ) {
-        	done_ccb->ccb_h.status &= ~CAM_DEV_QFRZN;
-		xpt_release_devq(done_ccb->ccb_h.path,
-			       	/*count*/ 1, /*run_queue*/TRUE);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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