From d1835b0ca5fc6aa112701a3b0f871a105582e3bc Mon Sep 17 00:00:00 2001 From: ken Date: Thu, 22 May 2014 16:34:00 +0000 Subject: [PATCH] MFC mpr(4) changes: r265484, r265485, r265709 and r265712 ------------------------------------------------------------------------ r265484 | ken | 2014-05-06 23:11:16 -0600 (Tue, 06 May 2014) | 5 lines Remove some debugging code. Submitted by: Steve McConnell ------------------------------------------------------------------------ ------------------------------------------------------------------------ r265485 | ken | 2014-05-06 23:14:48 -0600 (Tue, 06 May 2014) | 9 lines Hold the SIM lock when calling xpt_create_path() and xpt_action() in mprsas_SSU_to_SATA_devices(). This fixes an assertion on shutdown with INVARIANTS enabled with SATA drives present on an IR firmware controller. Reviewed by: Steve McConnell . ------------------------------------------------------------------------ ------------------------------------------------------------------------ r265709 | ken | 2014-05-08 14:28:22 -0600 (Thu, 08 May 2014) | 15 lines Fix TLR (Transport Layer Retry) support in the mps(4) and mpr(4) drivers. TLR is necessary for reliable communication with SAS tape drives. This was broken by change 246713 in the mps(4) driver. It changed the cm_data field for SCSI I/O requests to point to the CCB instead of the data buffer. So, instead, look at the CCB's data pointer to determine whether or not we're talking to a tape drive. Also, take the residual into account to make sure that we don't go off the end of the request. Sponsored by: Spectra Logic Corporation ------------------------------------------------------------------------ ------------------------------------------------------------------------ r265712 | ken | 2014-05-08 14:46:46 -0600 (Thu, 08 May 2014) | 10 lines Add #ifdefs in the mpr(4) driver so that versions of stable/9 that have implemented the PIM_NOSCAN rescan functionality will have it enabled. This is a no-op for head. Reviewed by: slm Sponsored by: Spectra Logic Corporation ------------------------------------------------------------------------ Sponsored by: Spectra Logic, Avago git-svn-id: svn://svn.freebsd.org/base/stable/10@266548 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/mpr/mpr.c | 2 -- sys/dev/mpr/mpr_sas.c | 15 ++++++++++----- sys/dev/mpr/mpr_sas_lsi.c | 12 ++++++++++-- sys/dev/mps/mps_sas.c | 6 ++++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index fe187a53c..3656eec36 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -2182,8 +2182,6 @@ mpr_add_chain(struct mpr_command *cm, int segsleft) * code other than 0. */ if (cm->cm_flags & MPR_CM_FLAGS_SGE_SIMPLE) { -//SLM-test -printf("Trying to add a chain element to an MPI SGL\n"); mpr_dprint(sc, MPR_ERROR, "A chain element cannot be added to " "an MPI SGL.\n"); return(ENOBUFS); diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c index 1a51109c1..1f95358c8 100644 --- a/sys/dev/mpr/mpr_sas.c +++ b/sys/dev/mpr/mpr_sas.c @@ -183,7 +183,8 @@ 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 +#if (__FreeBSD_version >= 1000039) || \ + ((__FreeBSD_version < 1000000) && (__FreeBSD_version >= 902502)) xpt_hold_boot(); #endif xpt_freeze_simq(sassc->sim, 1); @@ -217,7 +218,8 @@ 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 +#if (__FreeBSD_version >= 1000039) || \ + ((__FreeBSD_version < 1000000) && (__FreeBSD_version >= 902502)) xpt_release_boot(); #else mprsas_rescan_target(sassc->sc, NULL); @@ -974,7 +976,8 @@ 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 +#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; @@ -2355,8 +2358,9 @@ mprsas_scsiio_complete(struct mpr_softc *sc, struct mpr_command *cm) (csio->cdb_io.cdb_bytes[1] & SI_EVPD) && (csio->cdb_io.cdb_bytes[2] == SVPD_SUPPORTED_PAGE_LIST) && ((csio->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) && - (csio->data_ptr != NULL) && (((uint8_t *)cm->cm_data)[0] == - T_SEQUENTIAL) && (sc->control_TLR) && + (csio->data_ptr != NULL) && + ((csio->data_ptr[0] & 0x1f) == T_SEQUENTIAL) && + (sc->control_TLR) && (sc->mapping_table[csio->ccb_h.target_id].device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET)) { vpd_list = (struct scsi_vpd_supported_page_list *) @@ -2367,6 +2371,7 @@ mprsas_scsiio_complete(struct mpr_softc *sc, struct mpr_command *cm) TLR_on = (u8)MPI2_SCSIIO_CONTROL_TLR_ON; alloc_len = ((u16)csio->cdb_io.cdb_bytes[3] << 8) + csio->cdb_io.cdb_bytes[4]; + alloc_len -= csio->resid; for (i = 0; i < MIN(vpd_list->length, alloc_len); i++) { if (vpd_list->list[i] == 0x90) { *TLR_bits = TLR_on; diff --git a/sys/dev/mpr/mpr_sas_lsi.c b/sys/dev/mpr/mpr_sas_lsi.c index cf5be2b26..32e9b3a07 100644 --- a/sys/dev/mpr/mpr_sas_lsi.c +++ b/sys/dev/mpr/mpr_sas_lsi.c @@ -801,7 +801,8 @@ mprsas_add_device(struct mpr_softc *sc, u16 handle, u8 linkrate){ "and connector name (%4s)\n", targ->encl_level, targ->connector_name); } -#if __FreeBSD_version < 1000039 +#if ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000039)) || \ + (__FreeBSD_version < 902502) if ((sassc->flags & MPRSAS_IN_STARTUP) == 0) #endif mprsas_rescan_target(sc, targ); @@ -992,7 +993,8 @@ mprsas_volume_add(struct mpr_softc *sc, u16 handle) free(lun, M_MPR); } SLIST_INIT(&targ->luns); -#if __FreeBSD_version < 1000039 +#if ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000039)) || \ + (__FreeBSD_version < 902502) if ((sassc->flags & MPRSAS_IN_STARTUP) == 0) #endif mprsas_rescan_target(sc, targ); @@ -1026,6 +1028,8 @@ mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) char path_str[64]; struct timeval cur_time, start_time; + mpr_lock(sc); + /* * For each LUN of each target, issue a StartStopUnit command to stop * the device. @@ -1041,6 +1045,7 @@ mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) SLIST_FOREACH(lun, &target->luns, lun_link) { ccb = xpt_alloc_ccb_nowait(); if (ccb == NULL) { + mpr_unlock(sc); mpr_dprint(sc, MPR_FAULT, "Unable to alloc " "CCB to stop unit.\n"); return; @@ -1057,6 +1062,7 @@ mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) mpr_dprint(sc, MPR_FAULT, "Unable to " "create LUN path to stop unit.\n"); xpt_free_ccb(ccb); + mpr_unlock(sc); return; } xpt_path_string(ccb->ccb_h.path, path_str, @@ -1092,6 +1098,8 @@ mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) } } + mpr_unlock(sc); + /* * Wait until all of the SSU commands have completed or time has * expired (60 seconds). pause for 100ms each time through. If any diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c index 32e695984..639730422 100644 --- a/sys/dev/mps/mps_sas.c +++ b/sys/dev/mps/mps_sas.c @@ -2316,8 +2316,9 @@ mpssas_scsiio_complete(struct mps_softc *sc, struct mps_command *cm) (csio->cdb_io.cdb_bytes[1] & SI_EVPD) && (csio->cdb_io.cdb_bytes[2] == SVPD_SUPPORTED_PAGE_LIST) && ((csio->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) && - (csio->data_ptr != NULL) && (((uint8_t *)cm->cm_data)[0] == - T_SEQUENTIAL) && (sc->control_TLR) && + (csio->data_ptr != NULL) && + ((csio->data_ptr[0] & 0x1f) == T_SEQUENTIAL) && + (sc->control_TLR) && (sc->mapping_table[csio->ccb_h.target_id].device_info & MPI2_SAS_DEVICE_INFO_SSP_TARGET)) { vpd_list = (struct scsi_vpd_supported_page_list *) @@ -2328,6 +2329,7 @@ mpssas_scsiio_complete(struct mps_softc *sc, struct mps_command *cm) TLR_on = (u8)MPI2_SCSIIO_CONTROL_TLR_ON; alloc_len = ((u16)csio->cdb_io.cdb_bytes[3] << 8) + csio->cdb_io.cdb_bytes[4]; + alloc_len -= csio->resid; for (i = 0; i < MIN(vpd_list->length, alloc_len); i++) { if (vpd_list->list[i] == 0x90) { *TLR_bits = TLR_on; -- 2.45.0