Author: slm
Date: Wed Apr 15 21:47:15 2015
New Revision: 281564
URL: https://svnweb.freebsd.org/changeset/base/281564

Log:
  MFI r257381:
      Adjust to handle either a 32-bit or 64-bit lun_id_t in printf.
  
  MFC r266615:
      Increase taskqueue thread priority from idle to PRIBIO.
  
  MFC r279253:
      - Copyright to Avago
      - SSU changes
      - SATA ID timeout handling (PR 191348)
      - reset handling changes
      - Bump version to 20.00.00.00-fbsd
  
  MFC r279695:
      Change that should have been done with r279253

Modified:
  stable/10/sys/dev/mps/mpi/mpi2.h
  stable/10/sys/dev/mps/mpi/mpi2_cnfg.h
  stable/10/sys/dev/mps/mpi/mpi2_hbd.h
  stable/10/sys/dev/mps/mpi/mpi2_history.txt
  stable/10/sys/dev/mps/mpi/mpi2_init.h
  stable/10/sys/dev/mps/mpi/mpi2_ioc.h
  stable/10/sys/dev/mps/mpi/mpi2_ra.h
  stable/10/sys/dev/mps/mpi/mpi2_raid.h
  stable/10/sys/dev/mps/mpi/mpi2_sas.h
  stable/10/sys/dev/mps/mpi/mpi2_targ.h
  stable/10/sys/dev/mps/mpi/mpi2_tool.h
  stable/10/sys/dev/mps/mpi/mpi2_type.h
  stable/10/sys/dev/mps/mps.c
  stable/10/sys/dev/mps/mps_config.c
  stable/10/sys/dev/mps/mps_ioctl.h
  stable/10/sys/dev/mps/mps_mapping.c
  stable/10/sys/dev/mps/mps_mapping.h
  stable/10/sys/dev/mps/mps_pci.c
  stable/10/sys/dev/mps/mps_sas.c
  stable/10/sys/dev/mps/mps_sas.h
  stable/10/sys/dev/mps/mps_sas_lsi.c
  stable/10/sys/dev/mps/mps_user.c
  stable/10/sys/dev/mps/mpsvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mps/mpi/mpi2.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2.h    Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2.h    Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2006-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2006-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_cnfg.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_cnfg.h       Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_cnfg.h       Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2006-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2006-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_cnfg.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_hbd.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_hbd.h        Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_hbd.h        Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2009-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2009-2012 LSI Corporation.
+ *  Copyright (c) 2009-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_hbd.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_history.txt
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_history.txt  Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_history.txt  Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2000-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
@@ -32,7 +33,8 @@
  Fusion-MPT MPI 2.0 Header File Change History
  ==============================
 
- Copyright (c) 2000-2012 LSI Corporation.
+ Copyright (c) 2000-2015 LSI Corporation.
+ Copyright (c) 2013-2015 Avago Technologies
 
  ---------------------------------------
  Header Set Release Version:    02.00.18

Modified: stable/10/sys/dev/mps/mpi/mpi2_init.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_init.h       Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_init.h       Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2006-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2006-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_init.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_ioc.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_ioc.h        Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_ioc.h        Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2006-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2006-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_ioc.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_ra.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_ra.h Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_ra.h Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2009-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2012 LSI Corporation.
+ *  Copyright (c) 2009-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_ra.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_raid.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_raid.h       Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_raid.h       Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2007-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2007-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_raid.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_sas.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_sas.h        Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_sas.h        Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2007-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2007-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_sas.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_targ.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_targ.h       Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_targ.h       Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2006-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2006-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_targ.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_tool.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_tool.h       Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_tool.h       Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2007-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2007-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_tool.h

Modified: stable/10/sys/dev/mps/mpi/mpi2_type.h
==============================================================================
--- stable/10/sys/dev/mps/mpi/mpi2_type.h       Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mpi/mpi2_type.h       Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2006-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,13 +24,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
 
 /*
- *  Copyright (c) 2000-2012 LSI Corporation.
+ *  Copyright (c) 2006-2015 LSI Corporation.
+ *  Copyright (c) 2013-2015 Avago Technologies
  *
  *
  *           Name:  mpi2_type.h

Modified: stable/10/sys/dev/mps/mps.c
==============================================================================
--- stable/10/sys/dev/mps/mps.c Wed Apr 15 20:55:43 2015        (r281563)
+++ stable/10/sys/dev/mps/mps.c Wed Apr 15 21:47:15 2015        (r281564)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2009 Yahoo! Inc.
- * Copyright (c) 2012 LSI Corp.
+ * Copyright (c) 2011-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
@@ -32,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-/* Communications core for LSI MPT2 */
+/* Communications core for Avago Technologies (LSI) MPT2 */
 
 /* TODO Move headers to mpsvar */
 #include <sys/types.h>
@@ -1349,6 +1350,8 @@ mps_get_tunables(struct mps_softc *sc)
        sc->disable_msix = 0;
        sc->disable_msi = 0;
        sc->max_chains = MPS_CHAIN_FRAMES;
+       sc->enable_ssu = MPS_SSU_ENABLE_SSD_DISABLE_HDD;
+       sc->spinup_wait_time = DEFAULT_SPINUP_WAIT;
 
        /*
         * Grab the global variables.
@@ -1357,6 +1360,8 @@ mps_get_tunables(struct mps_softc *sc)
        TUNABLE_INT_FETCH("hw.mps.disable_msix", &sc->disable_msix);
        TUNABLE_INT_FETCH("hw.mps.disable_msi", &sc->disable_msi);
        TUNABLE_INT_FETCH("hw.mps.max_chains", &sc->max_chains);
+       TUNABLE_INT_FETCH("hw.mps.enable_ssu", &sc->enable_ssu);
+       TUNABLE_INT_FETCH("hw.mps.spinup_wait_time", &sc->spinup_wait_time);
 
        /* Grab the unit-instance variables */
        snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.debug_level",
@@ -1379,6 +1384,14 @@ mps_get_tunables(struct mps_softc *sc)
        snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.exclude_ids",
            device_get_unit(sc->mps_dev));
        TUNABLE_STR_FETCH(tmpstr, sc->exclude_ids, sizeof(sc->exclude_ids));
+
+       snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.enable_ssu",
+           device_get_unit(sc->mps_dev));
+       TUNABLE_INT_FETCH(tmpstr, &sc->enable_ssu);
+
+       snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.spinup_wait_time",
+           device_get_unit(sc->mps_dev));
+       TUNABLE_INT_FETCH(tmpstr, &sc->spinup_wait_time);
 }
 
 static void
@@ -1451,11 +1464,20 @@ mps_setup_sysctl(struct mps_softc *sc)
            OID_AUTO, "max_chains", CTLFLAG_RD,
            &sc->max_chains, 0,"maximum chain frames that will be allocated");
 
+       SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+           OID_AUTO, "enable_ssu", CTLFLAG_RW, &sc->enable_ssu, 0,
+           "enable SSU to SATA SSD/HDD at shutdown");
+
 #if __FreeBSD_version >= 900030
        SYSCTL_ADD_UQUAD(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
            OID_AUTO, "chain_alloc_fail", CTLFLAG_RD,
            &sc->chain_alloc_fail, "chain allocation failures");
 #endif //FreeBSD_version >= 900030
+
+       SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+           OID_AUTO, "spinup_wait_time", CTLFLAG_RD,
+           &sc->spinup_wait_time, DEFAULT_SPINUP_WAIT, "seconds to wait for "
+           "spinup after SATA ID error");
 }
 
 int

Modified: stable/10/sys/dev/mps/mps_config.c
==============================================================================
--- stable/10/sys/dev/mps/mps_config.c  Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mps_config.c  Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2011-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  */
 
 #include <sys/cdefs.h>

Modified: stable/10/sys/dev/mps/mps_ioctl.h
==============================================================================
--- stable/10/sys/dev/mps/mps_ioctl.h   Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mps_ioctl.h   Wed Apr 15 21:47:15 2015        
(r281564)
@@ -27,12 +27,13 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD userland interface
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD userland interface
  *
  * $FreeBSD$
  */
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2011-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,7 +57,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */

Modified: stable/10/sys/dev/mps/mps_mapping.c
==============================================================================
--- stable/10/sys/dev/mps/mps_mapping.c Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mps_mapping.c Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2011-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  */
 
 #include <sys/cdefs.h>
@@ -889,14 +890,14 @@ _mapping_get_dev_info(struct mps_softc *
        u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags);
        Mpi2ConfigReply_t mpi_reply;
        Mpi2SasDevicePage0_t sas_device_pg0;
-       u8 entry, enc_idx, phy_idx;
+       u8 entry, enc_idx, phy_idx, sata_end_device;
        u32 map_idx, index, device_info;
        struct _map_phy_change *phy_change, *tmp_phy_change;
        uint64_t sas_address;
        struct enc_mapping_table *et_entry;
        struct dev_mapping_table *mt_entry;
        u8 add_code = MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED;
-       int rc;
+       int rc = 1;
 
        for (entry = 0; entry < topo_change->num_entries; entry++) {
                phy_change = &topo_change->phy_details[entry];
@@ -910,42 +911,36 @@ _mapping_get_dev_info(struct mps_softc *
                        continue;
                }
 
+               /*
+                * Always get SATA Identify information because this is used
+                * to determine if Start/Stop Unit should be sent to the drive
+                * when the system is shutdown.
+                */
                device_info = le32toh(sas_device_pg0.DeviceInfo);
-               if ((ioc_pg8_flags & MPI2_IOCPAGE8_FLAGS_MASK_MAPPING_MODE) ==
-                   MPI2_IOCPAGE8_FLAGS_DEVICE_PERSISTENCE_MAPPING) {
-                       if ((device_info & MPI2_SAS_DEVICE_INFO_END_DEVICE) &&
-                           (device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE)) {
-                               rc = mpssas_get_sas_address_for_sata_disk(sc,
-                                   &sas_address, phy_change->dev_handle,
-                                   device_info);
-                               if (rc) {
-                                       printf("%s: failed to compute the "
-                                           "hashed SAS Address for SATA "
-                                           "device with handle 0x%04x\n",
-                                           __func__, phy_change->dev_handle);
-                                       sas_address =
-                                           sas_device_pg0.SASAddress.High;
-                                       sas_address = (sas_address << 32) |
-                                           sas_device_pg0.SASAddress.Low;
-                               }
-                               mps_dprint(sc, MPS_MAPPING,
-                                   "SAS Address for SATA device = %jx\n",
-                                   sas_address);
+               sas_address = sas_device_pg0.SASAddress.High;
+               sas_address = (sas_address << 32) |
+                   sas_device_pg0.SASAddress.Low;
+               sata_end_device = 0;
+               if ((device_info & MPI2_SAS_DEVICE_INFO_END_DEVICE) &&
+                   (device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE)) {
+                       sata_end_device = 1;
+                       rc = mpssas_get_sas_address_for_sata_disk(sc,
+                           &sas_address, phy_change->dev_handle, device_info,
+                           &phy_change->is_SATA_SSD);
+                       if (rc) {
+                               mps_dprint(sc, MPS_ERROR, "%s: failed to get "
+                                   "disk type (SSD or HDD) and SAS Address "
+                                   "for SATA device with handle 0x%04x\n",
+                                   __func__, phy_change->dev_handle);
                        } else {
-                               sas_address =
-                                       sas_device_pg0.SASAddress.High;
-                               sas_address = (sas_address << 32) |
-                                       sas_device_pg0.SASAddress.Low;
+                               mps_dprint(sc, MPS_INFO, "SAS Address for SATA "
+                                   "device = %jx\n", sas_address);
                        }
-               } else {
-                       sas_address = sas_device_pg0.SASAddress.High;
-                       sas_address = (sas_address << 32) |
-                          sas_device_pg0.SASAddress.Low;
                }
+
                phy_change->physical_id = sas_address;
                phy_change->slot = le16toh(sas_device_pg0.Slot);
-               phy_change->device_info =
-                   le32toh(sas_device_pg0.DeviceInfo);
+               phy_change->device_info = le32toh(sas_device_pg0.DeviceInfo);
 
                if ((ioc_pg8_flags & MPI2_IOCPAGE8_FLAGS_MASK_MAPPING_MODE) ==
                    MPI2_IOCPAGE8_FLAGS_ENCLOSURE_SLOT_MAPPING) {
@@ -953,10 +948,10 @@ _mapping_get_dev_info(struct mps_softc *
                            topo_change->enc_handle);
                        if (enc_idx == MPS_ENCTABLE_BAD_IDX) {
                                phy_change->is_processed = 1;
-                               printf("%s: failed to add the device with "
-                                   "handle 0x%04x because the enclosure is "
-                                   "not in the mapping table\n", __func__,
-                                   phy_change->dev_handle);
+                               mps_dprint(sc, MPS_MAPPING, "%s: failed to add "
+                                   "the device with handle 0x%04x because the "
+                                   "enclosure is not in the mapping table\n",
+                                   __func__, phy_change->dev_handle);
                                continue;
                        }
                        if (!((phy_change->device_info &

Modified: stable/10/sys/dev/mps/mps_mapping.h
==============================================================================
--- stable/10/sys/dev/mps/mps_mapping.h Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mps_mapping.h Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2011-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
@@ -38,6 +39,7 @@
  * @dev_handle: device handle for the device pointed by this entry
  * @slot: slot ID
  * @is_processed: Flag to indicate whether this entry is processed or not
+ * @is_SATA_SSD: 1 if this is a SATA device AND an SSD, 0 otherwise
  */
 struct _map_phy_change {
        uint64_t        physical_id;
@@ -46,6 +48,8 @@ struct _map_phy_change {
        uint16_t        slot;
        uint8_t reason;
        uint8_t is_processed;
+       uint8_t is_SATA_SSD;
+       uint8_t reserved;
 };
 
 /**
@@ -66,6 +70,6 @@ struct _map_topology_change {
 
 extern int
 mpssas_get_sas_address_for_sata_disk(struct mps_softc *ioc,
-    u64 *sas_address, u16 handle, u32 device_info);
+    u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD);
 
 #endif

Modified: stable/10/sys/dev/mps/mps_pci.c
==============================================================================
--- stable/10/sys/dev/mps/mps_pci.c     Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mps_pci.c     Wed Apr 15 21:47:15 2015        
(r281564)
@@ -27,7 +27,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-/* PCI/PCI-X/PCIe bus interface for the LSI MPT2 controllers */
+/* PCI/PCI-X/PCIe bus interface for the Avago Tech (LSI) MPT2 controllers */
 
 /* TODO Move headers to mpsvar */
 #include <sys/types.h>
@@ -98,33 +98,33 @@ struct mps_ident {
        const char      *desc;
 } mps_identifiers[] = {
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2004,
-           0xffff, 0xffff, 0, "LSI SAS2004" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2004" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2008,
-           0xffff, 0xffff, 0, "LSI SAS2008" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2008" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_1,
-           0xffff, 0xffff, 0, "LSI SAS2108" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2108" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_2,
-           0xffff, 0xffff, 0, "LSI SAS2108" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2108" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_3,
-           0xffff, 0xffff, 0, "LSI SAS2108" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2108" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_1,
-           0xffff, 0xffff, 0, "LSI SAS2116" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2116" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_2,
-           0xffff, 0xffff, 0, "LSI SAS2116" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2116" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_1,
-           0xffff, 0xffff, 0, "LSI SAS2208" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_2,
-           0xffff, 0xffff, 0, "LSI SAS2208" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_3,
-           0xffff, 0xffff, 0, "LSI SAS2208" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_4,
-           0xffff, 0xffff, 0, "LSI SAS2208" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_5,
-           0xffff, 0xffff, 0, "LSI SAS2208" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_6,
-           0xffff, 0xffff, 0, "LSI SAS2208" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2208" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_1,
-           0xffff, 0xffff, 0, "LSI SAS2308" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2308" },
        // Add Customer specific vender/subdevice id before generic
        // (0xffff) vender/subdevice id.
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
@@ -136,11 +136,11 @@ struct mps_ident {
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
            0x8086, 0x3519, 0, "Intel(R) Integrated RAID Module RMS25KB040" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
-           0xffff, 0xffff, 0, "LSI SAS2308" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2308" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_3,
-           0xffff, 0xffff, 0, "LSI SAS2308" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SAS2308" },
        { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SSS6200,
-           0xffff, 0xffff, MPS_FLAGS_WD_AVAILABLE, "LSI SSS6200" },
+           0xffff, 0xffff, 0, "Avago Technologies (LSI) SSS6200" },
        { 0, 0, 0, 0, 0, NULL }
 };
 

Modified: stable/10/sys/dev/mps/mps_sas.c
==============================================================================
--- stable/10/sys/dev/mps/mps_sas.c     Wed Apr 15 20:55:43 2015        
(r281563)
+++ stable/10/sys/dev/mps/mps_sas.c     Wed Apr 15 21:47:15 2015        
(r281564)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2009 Yahoo! Inc.
- * Copyright (c) 2011, 2012 LSI Corp.
+ * Copyright (c) 2011-2015 LSI Corp.
+ * Copyright (c) 2013-2015 Avago Technologies
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * LSI MPT-Fusion Host Adapter FreeBSD
+ * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
  *
  * $FreeBSD$
  */
@@ -32,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-/* Communications core for LSI MPT2 */
+/* Communications core for Avago Technologies (LSI) MPT2 */
 
 /* TODO Move headers to mpsvar */
 #include <sys/types.h>
@@ -119,6 +120,8 @@ static void mpssas_remove_device(struct 
 static void mpssas_remove_complete(struct mps_softc *, struct mps_command *);
 static void mpssas_action(struct cam_sim *sim, union ccb *ccb);
 static void mpssas_poll(struct cam_sim *sim);
+static int mpssas_send_abort(struct mps_softc *sc, struct mps_command *tm,
+    struct mps_command *cm);
 static void mpssas_scsiio_timeout(void *data);
 static void mpssas_abort_complete(struct mps_softc *sc, struct mps_command 
*cm);
 static void mpssas_direct_drive_io(struct mpssas_softc *sassc,
@@ -133,8 +136,6 @@ static void mpssas_send_smpcmd(struct mp
 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 int  mpssas_send_abort(struct mps_softc *sc, struct mps_command *tm, 
struct mps_command *cm);
-static int  mpssas_send_reset(struct mps_softc *sc, struct mps_command *tm, 
uint8_t type);
 static void mpssas_async(void *callback_arg, uint32_t code,
                         struct cam_path *path, void *arg);
 #if (__FreeBSD_version < 901503) || \
@@ -224,7 +225,7 @@ mpssas_startup_decrement(struct mpssas_s
        }
 }
 
-/* LSI's firmware requires us to stop sending commands when we're doing task
+/* The firmware requires us to stop sending commands when we're doing task
  * management, so refcount the TMs and keep the simq frozen when any are in
  * use.
  */
@@ -233,37 +234,31 @@ mpssas_alloc_tm(struct mps_softc *sc)
 {
        struct mps_command *tm;
 
-       MPS_FUNCTRACE(sc);
        tm = mps_alloc_high_priority_command(sc);
-       if (tm != NULL) {
-               if (sc->sassc->tm_count++ == 0) {
-                       mps_dprint(sc, MPS_RECOVERY,
-                           "%s freezing simq\n", __func__);
-                       xpt_freeze_simq(sc->sassc->sim, 1);
-               }
-               mps_dprint(sc, MPS_RECOVERY, "%s tm_count %u\n", __func__,
-                   sc->sassc->tm_count);
-       }
        return tm;
 }
 
 void
 mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm)
 {
-       mps_dprint(sc, MPS_TRACE, "%s", __func__);
        if (tm == NULL)
                return;
 
-       /* if there are no TMs in use, we can release the simq.  We use our
-        * own refcount so that it's easier for a diag reset to cleanup and
-        * release the simq.
-        */
-       if (--sc->sassc->tm_count == 0) {
-               mps_dprint(sc, MPS_RECOVERY, "%s releasing simq\n", __func__);
-               xpt_release_simq(sc->sassc->sim, 1);
+       /*
+        * For TM's the devq is frozen for the device.  Unfreeze it here and
+        * free the resources used for freezing the devq.  Must clear the
+        * INRESET flag as well or scsi I/O will not work.
+        */
+       if (tm->cm_targ != NULL) {
+               tm->cm_targ->flags &= ~MPSSAS_TARGET_INRESET;
+       }
+       if (tm->cm_ccb) {
+               mps_dprint(sc, MPS_INFO, "Unfreezing devq for target ID %d\n",
+                   tm->cm_targ->tid);
+               xpt_release_devq(tm->cm_ccb->ccb_h.path, 1, TRUE);
+               xpt_free_path(tm->cm_ccb->ccb_h.path);
+               xpt_free_ccb(tm->cm_ccb);
        }
-       mps_dprint(sc, MPS_RECOVERY, "%s tm_count %u\n", __func__,
-           sc->sassc->tm_count);
 
        mps_free_high_priority_command(sc, tm);
 }
@@ -371,7 +366,8 @@ mpssas_remove_volume(struct mps_softc *s
        if (reply == NULL) {
                /* XXX retry the remove after the diag reset completes? */
                mps_dprint(sc, MPS_FAULT,
-                   "%s NULL reply reseting device 0x%04x\n", __func__, handle);
+                   "%s NULL reply resetting device 0x%04x\n", __func__,
+                   handle);
                mpssas_free_tm(sc, tm);
                return;
        }
@@ -475,6 +471,11 @@ mpssas_prepare_volume_remove(struct mpss
            MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
        cm->cm_complete = mpssas_remove_volume;
        cm->cm_complete_data = (void *)(uintptr_t)handle;
+
+       mps_dprint(sc, MPS_INFO, "%s: Sending reset for target ID %d\n",
+           __func__, targ->tid);
+       mpssas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD);
+
        mps_map_command(sc, cm);
 }
 
@@ -533,6 +534,11 @@ mpssas_prepare_remove(struct mpssas_soft
        cm->cm_desc.HighPriority.RequestFlags = 
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
        cm->cm_complete = mpssas_remove_device;
        cm->cm_complete_data = (void *)(uintptr_t)handle;
+
+       mps_dprint(sc, MPS_INFO, "%s: Sending reset for target ID %d\n",
+           __func__, targ->tid);
+       mpssas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD);
+
        mps_map_command(sc, cm);
 }
 
@@ -758,9 +764,7 @@ mps_attach_sas(struct mps_softc *sc)
        TASK_INIT(&sassc->ev_task, 0, mpssas_firmware_event_work, sc);
        sassc->ev_tq = taskqueue_create("mps_taskq", M_NOWAIT | M_ZERO,
            taskqueue_thread_enqueue, &sassc->ev_tq);
-
-       /* Run the task queue with lowest priority */
-       taskqueue_start_threads(&sassc->ev_tq, 1, 255, "%s taskq", 
+       taskqueue_start_threads(&sassc->ev_tq, 1, PRIBIO, "%s taskq", 
            device_get_nameunit(sc->mps_dev));
 
        mps_lock(sc);
@@ -787,9 +791,6 @@ mps_attach_sas(struct mps_softc *sc)
        mpssas_startup_increment(sassc);
 
        callout_init(&sassc->discovery_callout, 1 /*mpsafe*/);
-       sassc->discovery_timeouts = 0;
-
-       sassc->tm_count = 0;
 
        /*
         * Register for async events so we can determine the EEDP
@@ -940,7 +941,7 @@ mpssas_action(struct cam_sim *sim, union
                cpi->max_lun = 255;
                cpi->initiator_id = sassc->maxtargets - 1;
                strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-               strncpy(cpi->hba_vid, "LSILogic", HBA_IDLEN);
+               strncpy(cpi->hba_vid, "Avago Tech (LSI)", HBA_IDLEN);
                strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
                cpi->unit_number = cam_sim_unit(sim);
                cpi->bus_id = cam_sim_bus(sim);
@@ -1042,8 +1043,8 @@ mpssas_announce_reset(struct mps_softc *
        path_id_t path_id = cam_sim_path(sc->sassc->sim);
        struct cam_path *path;
 
-       mps_dprint(sc, MPS_XINFO, "%s code %x target %d lun %d\n", __func__,
-           ac_code, target_id, lun_id);
+       mps_dprint(sc, MPS_XINFO, "%s code %x target %d lun %jx\n", __func__,
+           ac_code, target_id, (uintmax_t)lun_id);
 
        if (xpt_create_path(&path, NULL, 
                path_id, target_id, lun_id) != CAM_REQ_CMP) {
@@ -1136,8 +1137,8 @@ mpssas_handle_reinit(struct mps_softc *s
        mpssas_complete_all_commands(sc);
 
        mps_dprint(sc, MPS_INIT,
-           "%s startup %u tm %u after command completion\n",
-           __func__, sc->sassc->startup_refcount, sc->sassc->tm_count);
+           "%s startup %u after command completion\n", __func__,
+           sc->sassc->startup_refcount);
 
        /* zero all the target handles, since they may change after the
         * reset, and we have to rediscover all the targets and use the new
@@ -1200,7 +1201,6 @@ mpssas_logical_unit_reset_complete(struc
                    "NULL reset reply for tm %p\n", tm);
                if ((sc->mps_flags & MPS_FLAGS_DIAGRESET) != 0) {
                        /* this completion was due to a reset, just cleanup */
-                       targ->flags &= ~MPSSAS_TARGET_INRESET;
                        targ->tm = NULL;
                        mpssas_free_tm(sc, tm);
                }
@@ -1289,7 +1289,6 @@ mpssas_target_reset_complete(struct mps_
                    "NULL reset reply for tm %p\n", tm);
                if ((sc->mps_flags & MPS_FLAGS_DIAGRESET) != 0) {
                        /* this completion was due to a reset, just cleanup */
-                       targ->flags &= ~MPSSAS_TARGET_INRESET;
                        targ->tm = NULL;
                        mpssas_free_tm(sc, tm);
                }
@@ -1305,8 +1304,6 @@ mpssas_target_reset_complete(struct mps_
            le16toh(reply->IOCStatus), le32toh(reply->ResponseCode),
            le32toh(reply->TerminationCount));
 
-       targ->flags &= ~MPSSAS_TARGET_INRESET;
-
        if (targ->outstanding == 0) {
                /* we've finished recovery for this target and all
                 * of its logical units.
@@ -1334,7 +1331,7 @@ mpssas_target_reset_complete(struct mps_
 
 #define MPS_RESET_TIMEOUT 30
 
-static int
+int
 mpssas_send_reset(struct mps_softc *sc, struct mps_command *tm, uint8_t type)
 {
        MPI2_SCSI_TASK_MANAGE_REQUEST *req;
@@ -1360,15 +1357,19 @@ mpssas_send_reset(struct mps_softc *sc, 
                mpssas_log_command(tm, MPS_RECOVERY|MPS_INFO,
                    "sending logical unit reset\n");
                tm->cm_complete = mpssas_logical_unit_reset_complete;
+               mpssas_prepare_for_tm(sc, tm, target, tm->cm_lun);
        }
        else if (type == MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET) {
-               /* Target reset method =  SAS Hard Link Reset / SATA Link Reset 
*/
+               /*
+                * Target reset method =
+                *      SAS Hard Link Reset / SATA Link Reset
+                */
                req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
                tm->cm_targ->target_resets++;
-               tm->cm_targ->flags |= MPSSAS_TARGET_INRESET;
                mpssas_log_command(tm, MPS_RECOVERY|MPS_INFO,
                    "sending target reset\n");
                tm->cm_complete = mpssas_target_reset_complete;
+               mpssas_prepare_for_tm(sc, tm, target, CAM_LUN_WILDCARD);
        }
        else {
                mps_dprint(sc, MPS_ERROR, "unexpected reset type 0x%x\n", type);
@@ -1515,6 +1516,10 @@ mpssas_send_abort(struct mps_softc *sc, 
 
        targ->aborts++;
 
+       mps_dprint(sc, MPS_INFO, "Sending reset from %s for target ID %d\n",
+           __func__, targ->tid);
+       mpssas_prepare_for_tm(sc, tm, targ, tm->cm_lun);
+
        err = mps_map_command(sc, tm);
        if (err)
                mpssas_log_command(tm, MPS_RECOVERY,
@@ -1523,7 +1528,6 @@ mpssas_send_abort(struct mps_softc *sc, 
        return err;
 }
 
-
 static void
 mpssas_scsiio_timeout(void *data)
 {
@@ -1669,6 +1673,19 @@ mpssas_action_scsiio(struct mpssas_softc
                return;
        }
 
+       /*
+        * If target has a reset in progress, freeze the devq and return.  The
+        * devq will be released when the TM reset is finished.
+        */
+       if (targ->flags & MPSSAS_TARGET_INRESET) {
+               ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN;
+               mps_dprint(sc, MPS_INFO, "%s: Freezing devq for target ID %d\n",
+                   __func__, targ->tid);
+               xpt_freeze_devq(ccb->ccb_h.path, 1);
+               xpt_done(ccb);
+               return;
+       }
+
        cm = mps_alloc_command(sc);
        if (cm == NULL || (sc->mps_flags & MPS_FLAGS_DIAGRESET)) {
                if (cm != NULL) {
@@ -2058,6 +2075,8 @@ mpssas_scsiio_complete(struct mps_softc 
        u8 *TLR_bits, TLR_on;
        int dir = 0, i;
        u16 alloc_len;
+       struct mpssas_target *target;
+       target_id_t target_id;
 
        MPS_FUNCTRACE(sc);
        mps_dprint(sc, MPS_TRACE,
@@ -2071,6 +2090,7 @@ mpssas_scsiio_complete(struct mps_softc 
        sassc = sc->sassc;
        ccb = cm->cm_complete_data;
        csio = &ccb->csio;
+       target_id = csio->ccb_h.target_id;
        rep = (MPI2_SCSI_IO_REPLY *)cm->cm_reply;
        /*
         * XXX KDM if the chain allocation fails, does it matter if we do
@@ -2252,9 +2272,10 @@ mpssas_scsiio_complete(struct mps_softc 
                 * TLR_bits for the target.
                 */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to