aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorKashyap, Desai <kashyap.desai@lsi.com>2010-03-17 06:55:59 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 10:24:00 -0400
commit8ed9a03ad4c1b6c5ae163e5e9f140852be0273a1 (patch)
tree67b6a1e7f59ad5eab7fd75ae025c845544d8b360 /drivers/scsi
parente94f67472106e5a0e97c79090211c551e69e889b (diff)
[SCSI] mpt2sas: removed use of tm_cmds.mutex in IOCTL branch.
Removed all the mutex's for ioc->tm_cmds.mutex, then created one single mutex inside the function mpt2sas_scsih_issue_tm. This is the single function used when sending task management. Also the sanity checks required for scsi mid layer escalation were moved to inside the same function because these checks need to be done while the mutex is held. The ioc->tm_cmds.mutex inside the IOCTL branch is really not required since there is another mutex in this code called for ctl_cmds handling this sync. Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.h5
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c13
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c173
3 files changed, 108 insertions, 83 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
index cdedfcbb8ca7..9973efd200a5 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -803,8 +803,9 @@ void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
803/* scsih shared API */ 803/* scsih shared API */
804u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, 804u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
805 u32 reply); 805 u32 reply);
806void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, 806int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle,
807 u8 type, u16 smid_task, ulong timeout); 807 uint channel, uint id, uint lun, u8 type, u16 smid_task,
808 ulong timeout, struct scsi_cmnd *scmd);
808void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle); 809void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
809void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle); 810void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
810struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc, 811struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index ae55a912baf4..9860e7edd442 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -753,6 +753,10 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
753 Mpi2SCSITaskManagementRequest_t *tm_request = 753 Mpi2SCSITaskManagementRequest_t *tm_request =
754 (Mpi2SCSITaskManagementRequest_t *)mpi_request; 754 (Mpi2SCSITaskManagementRequest_t *)mpi_request;
755 755
756 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "TASK_MGMT: "
757 "handle(0x%04x), task_type(0x%02x)\n", ioc->name,
758 le16_to_cpu(tm_request->DevHandle), tm_request->TaskType));
759
756 if (tm_request->TaskType == 760 if (tm_request->TaskType ==
757 MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK || 761 MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK ||
758 tm_request->TaskType == 762 tm_request->TaskType ==
@@ -763,7 +767,6 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
763 } 767 }
764 } 768 }
765 769
766 mutex_lock(&ioc->tm_cmds.mutex);
767 mpt2sas_scsih_set_tm_flag(ioc, le16_to_cpu( 770 mpt2sas_scsih_set_tm_flag(ioc, le16_to_cpu(
768 tm_request->DevHandle)); 771 tm_request->DevHandle));
769 mpt2sas_base_put_smid_hi_priority(ioc, smid); 772 mpt2sas_base_put_smid_hi_priority(ioc, smid);
@@ -819,7 +822,6 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
819 if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) { 822 if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) {
820 Mpi2SCSITaskManagementRequest_t *tm_request = 823 Mpi2SCSITaskManagementRequest_t *tm_request =
821 (Mpi2SCSITaskManagementRequest_t *)mpi_request; 824 (Mpi2SCSITaskManagementRequest_t *)mpi_request;
822 mutex_unlock(&ioc->tm_cmds.mutex);
823 mpt2sas_scsih_clear_tm_flag(ioc, le16_to_cpu( 825 mpt2sas_scsih_clear_tm_flag(ioc, le16_to_cpu(
824 tm_request->DevHandle)); 826 tm_request->DevHandle));
825 } else if ((mpi_request->Function == MPI2_FUNCTION_SMP_PASSTHROUGH || 827 } else if ((mpi_request->Function == MPI2_FUNCTION_SMP_PASSTHROUGH ||
@@ -900,12 +902,11 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
900 "= (0x%04x)\n", ioc->name, 902 "= (0x%04x)\n", ioc->name,
901 le16_to_cpu(mpi_request->FunctionDependent1)); 903 le16_to_cpu(mpi_request->FunctionDependent1));
902 mpt2sas_halt_firmware(ioc); 904 mpt2sas_halt_firmware(ioc);
903 mutex_lock(&ioc->tm_cmds.mutex);
904 mpt2sas_scsih_issue_tm(ioc, 905 mpt2sas_scsih_issue_tm(ioc,
905 le16_to_cpu(mpi_request->FunctionDependent1), 0, 906 le16_to_cpu(mpi_request->FunctionDependent1), 0, 0,
906 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 10); 907 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 10,
908 NULL);
907 ioc->tm_cmds.status = MPT2_CMD_NOT_USED; 909 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
908 mutex_unlock(&ioc->tm_cmds.mutex);
909 } else 910 } else
910 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, 911 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
911 FORCE_BIG_HAMMER); 912 FORCE_BIG_HAMMER);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 3d1be440ed7b..cfaefd10515d 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -1944,65 +1944,78 @@ mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle)
1944 } 1944 }
1945} 1945}
1946 1946
1947
1947/** 1948/**
1948 * mpt2sas_scsih_issue_tm - main routine for sending tm requests 1949 * mpt2sas_scsih_issue_tm - main routine for sending tm requests
1949 * @ioc: per adapter struct 1950 * @ioc: per adapter struct
1950 * @device_handle: device handle 1951 * @device_handle: device handle
1952 * @channel: the channel assigned by the OS
1953 * @id: the id assigned by the OS
1951 * @lun: lun number 1954 * @lun: lun number
1952 * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in mpi2_init.h) 1955 * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in mpi2_init.h)
1953 * @smid_task: smid assigned to the task 1956 * @smid_task: smid assigned to the task
1954 * @timeout: timeout in seconds 1957 * @timeout: timeout in seconds
1955 * Context: The calling function needs to acquire the tm_cmds.mutex 1958 * Context: user
1956 * 1959 *
1957 * A generic API for sending task management requests to firmware. 1960 * A generic API for sending task management requests to firmware.
1958 * 1961 *
1959 * The ioc->tm_cmds.status flag should be MPT2_CMD_NOT_USED before calling
1960 * this API.
1961 *
1962 * The callback index is set inside `ioc->tm_cb_idx`. 1962 * The callback index is set inside `ioc->tm_cb_idx`.
1963 * 1963 *
1964 * Return nothing. 1964 * Return SUCCESS or FAILED.
1965 */ 1965 */
1966void 1966int
1967mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, 1967mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint channel,
1968 u8 type, u16 smid_task, ulong timeout) 1968 uint id, uint lun, u8 type, u16 smid_task, ulong timeout,
1969 struct scsi_cmnd *scmd)
1969{ 1970{
1970 Mpi2SCSITaskManagementRequest_t *mpi_request; 1971 Mpi2SCSITaskManagementRequest_t *mpi_request;
1971 Mpi2SCSITaskManagementReply_t *mpi_reply; 1972 Mpi2SCSITaskManagementReply_t *mpi_reply;
1972 u16 smid = 0; 1973 u16 smid = 0;
1973 u32 ioc_state; 1974 u32 ioc_state;
1974 unsigned long timeleft; 1975 unsigned long timeleft;
1976 struct scsi_cmnd *scmd_lookup;
1977 int rc;
1975 1978
1979 mutex_lock(&ioc->tm_cmds.mutex);
1976 if (ioc->tm_cmds.status != MPT2_CMD_NOT_USED) { 1980 if (ioc->tm_cmds.status != MPT2_CMD_NOT_USED) {
1977 printk(MPT2SAS_INFO_FMT "%s: tm_cmd busy!!!\n", 1981 printk(MPT2SAS_INFO_FMT "%s: tm_cmd busy!!!\n",
1978 __func__, ioc->name); 1982 __func__, ioc->name);
1979 return; 1983 rc = FAILED;
1984 goto err_out;
1980 } 1985 }
1981 1986
1982 if (ioc->shost_recovery || ioc->remove_host) { 1987 if (ioc->shost_recovery || ioc->remove_host) {
1983 printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n", 1988 printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n",
1984 __func__, ioc->name); 1989 __func__, ioc->name);
1985 return; 1990 rc = FAILED;
1991 goto err_out;
1986 } 1992 }
1987 1993
1988 ioc_state = mpt2sas_base_get_iocstate(ioc, 0); 1994 ioc_state = mpt2sas_base_get_iocstate(ioc, 0);
1989 if (ioc_state & MPI2_DOORBELL_USED) { 1995 if (ioc_state & MPI2_DOORBELL_USED) {
1990 dhsprintk(ioc, printk(MPT2SAS_DEBUG_FMT "unexpected doorbell " 1996 dhsprintk(ioc, printk(MPT2SAS_DEBUG_FMT "unexpected doorbell "
1991 "active!\n", ioc->name)); 1997 "active!\n", ioc->name));
1992 goto issue_host_reset; 1998 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
1999 FORCE_BIG_HAMMER);
2000 rc = SUCCESS;
2001 goto err_out;
1993 } 2002 }
1994 2003
1995 if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) { 2004 if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
1996 mpt2sas_base_fault_info(ioc, ioc_state & 2005 mpt2sas_base_fault_info(ioc, ioc_state &
1997 MPI2_DOORBELL_DATA_MASK); 2006 MPI2_DOORBELL_DATA_MASK);
1998 goto issue_host_reset; 2007 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
2008 FORCE_BIG_HAMMER);
2009 rc = SUCCESS;
2010 goto err_out;
1999 } 2011 }
2000 2012
2001 smid = mpt2sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx); 2013 smid = mpt2sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx);
2002 if (!smid) { 2014 if (!smid) {
2003 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 2015 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
2004 ioc->name, __func__); 2016 ioc->name, __func__);
2005 return; 2017 rc = FAILED;
2018 goto err_out;
2006 } 2019 }
2007 2020
2008 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x)," 2021 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x),"
@@ -2016,21 +2029,24 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
2016 mpi_request->DevHandle = cpu_to_le16(handle); 2029 mpi_request->DevHandle = cpu_to_le16(handle);
2017 mpi_request->TaskType = type; 2030 mpi_request->TaskType = type;
2018 mpi_request->TaskMID = cpu_to_le16(smid_task); 2031 mpi_request->TaskMID = cpu_to_le16(smid_task);
2019 mpi_request->VP_ID = 0; /* TODO */
2020 mpi_request->VF_ID = 0;
2021 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); 2032 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN);
2022 mpt2sas_scsih_set_tm_flag(ioc, handle); 2033 mpt2sas_scsih_set_tm_flag(ioc, handle);
2023 init_completion(&ioc->tm_cmds.done); 2034 init_completion(&ioc->tm_cmds.done);
2024 mpt2sas_base_put_smid_hi_priority(ioc, smid); 2035 mpt2sas_base_put_smid_hi_priority(ioc, smid);
2025 timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); 2036 timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ);
2026 mpt2sas_scsih_clear_tm_flag(ioc, handle);
2027 if (!(ioc->tm_cmds.status & MPT2_CMD_COMPLETE)) { 2037 if (!(ioc->tm_cmds.status & MPT2_CMD_COMPLETE)) {
2028 printk(MPT2SAS_ERR_FMT "%s: timeout\n", 2038 printk(MPT2SAS_ERR_FMT "%s: timeout\n",
2029 ioc->name, __func__); 2039 ioc->name, __func__);
2030 _debug_dump_mf(mpi_request, 2040 _debug_dump_mf(mpi_request,
2031 sizeof(Mpi2SCSITaskManagementRequest_t)/4); 2041 sizeof(Mpi2SCSITaskManagementRequest_t)/4);
2032 if (!(ioc->tm_cmds.status & MPT2_CMD_RESET)) 2042 if (!(ioc->tm_cmds.status & MPT2_CMD_RESET)) {
2033 goto issue_host_reset; 2043 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
2044 FORCE_BIG_HAMMER);
2045 rc = SUCCESS;
2046 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
2047 mpt2sas_scsih_clear_tm_flag(ioc, handle);
2048 goto err_out;
2049 }
2034 } 2050 }
2035 2051
2036 if (ioc->tm_cmds.status & MPT2_CMD_REPLY_VALID) { 2052 if (ioc->tm_cmds.status & MPT2_CMD_REPLY_VALID) {
@@ -2040,12 +2056,57 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
2040 ioc->name, le16_to_cpu(mpi_reply->IOCStatus), 2056 ioc->name, le16_to_cpu(mpi_reply->IOCStatus),
2041 le32_to_cpu(mpi_reply->IOCLogInfo), 2057 le32_to_cpu(mpi_reply->IOCLogInfo),
2042 le32_to_cpu(mpi_reply->TerminationCount))); 2058 le32_to_cpu(mpi_reply->TerminationCount)));
2043 if (ioc->logging_level & MPT_DEBUG_TM) 2059 if (ioc->logging_level & MPT_DEBUG_TM) {
2044 _scsih_response_code(ioc, mpi_reply->ResponseCode); 2060 _scsih_response_code(ioc, mpi_reply->ResponseCode);
2061 if (mpi_reply->IOCStatus)
2062 _debug_dump_mf(mpi_request,
2063 sizeof(Mpi2SCSITaskManagementRequest_t)/4);
2064 }
2045 } 2065 }
2046 return; 2066
2047 issue_host_reset: 2067 /* sanity check:
2048 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, FORCE_BIG_HAMMER); 2068 * Check to see the commands were terminated.
2069 * This is only needed for eh callbacks, hence the scmd check.
2070 */
2071 rc = FAILED;
2072 if (scmd == NULL)
2073 goto bypass_sanity_checks;
2074 switch (type) {
2075 case MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK:
2076 scmd_lookup = _scsih_scsi_lookup_get(ioc, smid_task);
2077 if (scmd_lookup && (scmd_lookup->serial_number ==
2078 scmd->serial_number))
2079 rc = FAILED;
2080 else
2081 rc = SUCCESS;
2082 break;
2083
2084 case MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
2085 if (_scsih_scsi_lookup_find_by_target(ioc, id, channel))
2086 rc = FAILED;
2087 else
2088 rc = SUCCESS;
2089 break;
2090
2091 case MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET:
2092 if (_scsih_scsi_lookup_find_by_lun(ioc, id, lun, channel))
2093 rc = FAILED;
2094 else
2095 rc = SUCCESS;
2096 break;
2097 }
2098
2099 bypass_sanity_checks:
2100
2101 mpt2sas_scsih_clear_tm_flag(ioc, handle);
2102 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
2103 mutex_unlock(&ioc->tm_cmds.mutex);
2104
2105 return rc;
2106
2107 err_out:
2108 mutex_unlock(&ioc->tm_cmds.mutex);
2109 return rc;
2049} 2110}
2050 2111
2051/** 2112/**
@@ -2062,7 +2123,6 @@ _scsih_abort(struct scsi_cmnd *scmd)
2062 u16 smid; 2123 u16 smid;
2063 u16 handle; 2124 u16 handle;
2064 int r; 2125 int r;
2065 struct scsi_cmnd *scmd_lookup;
2066 2126
2067 printk(MPT2SAS_INFO_FMT "attempting task abort! scmd(%p)\n", 2127 printk(MPT2SAS_INFO_FMT "attempting task abort! scmd(%p)\n",
2068 ioc->name, scmd); 2128 ioc->name, scmd);
@@ -2097,19 +2157,10 @@ _scsih_abort(struct scsi_cmnd *scmd)
2097 2157
2098 mpt2sas_halt_firmware(ioc); 2158 mpt2sas_halt_firmware(ioc);
2099 2159
2100 mutex_lock(&ioc->tm_cmds.mutex);
2101 handle = sas_device_priv_data->sas_target->handle; 2160 handle = sas_device_priv_data->sas_target->handle;
2102 mpt2sas_scsih_issue_tm(ioc, handle, sas_device_priv_data->lun, 2161 r = mpt2sas_scsih_issue_tm(ioc, handle, scmd->device->channel,
2103 MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, smid, 30); 2162 scmd->device->id, scmd->device->lun,
2104 2163 MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, smid, 30, scmd);
2105 /* sanity check - see whether command actually completed */
2106 scmd_lookup = _scsih_scsi_lookup_get(ioc, smid);
2107 if (scmd_lookup && (scmd_lookup->serial_number == scmd->serial_number))
2108 r = FAILED;
2109 else
2110 r = SUCCESS;
2111 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
2112 mutex_unlock(&ioc->tm_cmds.mutex);
2113 2164
2114 out: 2165 out:
2115 printk(MPT2SAS_INFO_FMT "task abort: %s scmd(%p)\n", 2166 printk(MPT2SAS_INFO_FMT "task abort: %s scmd(%p)\n",
@@ -2166,22 +2217,9 @@ _scsih_dev_reset(struct scsi_cmnd *scmd)
2166 goto out; 2217 goto out;
2167 } 2218 }
2168 2219
2169 mutex_lock(&ioc->tm_cmds.mutex); 2220 r = mpt2sas_scsih_issue_tm(ioc, handle, scmd->device->channel,
2170 mpt2sas_scsih_issue_tm(ioc, handle, 0, 2221 scmd->device->id, scmd->device->lun,
2171 MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, scmd->device->lun, 2222 MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 30, scmd);
2172 30);
2173
2174 /*
2175 * sanity check see whether all commands to this device been
2176 * completed
2177 */
2178 if (_scsih_scsi_lookup_find_by_lun(ioc, scmd->device->id,
2179 scmd->device->lun, scmd->device->channel))
2180 r = FAILED;
2181 else
2182 r = SUCCESS;
2183 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
2184 mutex_unlock(&ioc->tm_cmds.mutex);
2185 2223
2186 out: 2224 out:
2187 printk(MPT2SAS_INFO_FMT "device reset: %s scmd(%p)\n", 2225 printk(MPT2SAS_INFO_FMT "device reset: %s scmd(%p)\n",
@@ -2238,21 +2276,9 @@ _scsih_target_reset(struct scsi_cmnd *scmd)
2238 goto out; 2276 goto out;
2239 } 2277 }
2240 2278
2241 mutex_lock(&ioc->tm_cmds.mutex); 2279 r = mpt2sas_scsih_issue_tm(ioc, handle, scmd->device->channel,
2242 mpt2sas_scsih_issue_tm(ioc, handle, 0, 2280 scmd->device->id, 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0,
2243 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 30); 2281 30, scmd);
2244
2245 /*
2246 * sanity check see whether all commands to this target been
2247 * completed
2248 */
2249 if (_scsih_scsi_lookup_find_by_target(ioc, scmd->device->id,
2250 scmd->device->channel))
2251 r = FAILED;
2252 else
2253 r = SUCCESS;
2254 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
2255 mutex_unlock(&ioc->tm_cmds.mutex);
2256 2282
2257 out: 2283 out:
2258 printk(MPT2SAS_INFO_FMT "target reset: %s scmd(%p)\n", 2284 printk(MPT2SAS_INFO_FMT "target reset: %s scmd(%p)\n",
@@ -4183,8 +4209,8 @@ _scsih_remove_pd_device(struct MPT2SAS_ADAPTER *ioc, struct _sas_device
4183 return; 4209 return;
4184 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "issue target reset: " 4210 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "issue target reset: "
4185 "handle(0x%04x)\n", ioc->name, vol_handle)); 4211 "handle(0x%04x)\n", ioc->name, vol_handle));
4186 mpt2sas_scsih_issue_tm(ioc, vol_handle, 0, 4212 mpt2sas_scsih_issue_tm(ioc, vol_handle, 0, 0, 0,
4187 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 30); 4213 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 30, NULL);
4188 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "issue target reset " 4214 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "issue target reset "
4189 "done: handle(0x%04x)\n", ioc->name, vol_handle)); 4215 "done: handle(0x%04x)\n", ioc->name, vol_handle));
4190 if (ioc->shost_recovery) 4216 if (ioc->shost_recovery)
@@ -4668,7 +4694,6 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
4668 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name, 4694 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name,
4669 __func__)); 4695 __func__));
4670 4696
4671 mutex_lock(&ioc->tm_cmds.mutex);
4672 termination_count = 0; 4697 termination_count = 0;
4673 query_count = 0; 4698 query_count = 0;
4674 mpi_reply = ioc->tm_cmds.reply; 4699 mpi_reply = ioc->tm_cmds.reply;
@@ -4692,8 +4717,8 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
4692 lun = sas_device_priv_data->lun; 4717 lun = sas_device_priv_data->lun;
4693 query_count++; 4718 query_count++;
4694 4719
4695 mpt2sas_scsih_issue_tm(ioc, handle, lun, 4720 mpt2sas_scsih_issue_tm(ioc, handle, 0, 0, lun,
4696 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, smid, 30); 4721 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, smid, 30, NULL);
4697 ioc->tm_cmds.status = MPT2_CMD_NOT_USED; 4722 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
4698 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) 4723 ioc_status = le16_to_cpu(mpi_reply->IOCStatus)
4699 & MPI2_IOCSTATUS_MASK; 4724 & MPI2_IOCSTATUS_MASK;
@@ -4704,13 +4729,11 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
4704 MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC)) 4729 MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC))
4705 continue; 4730 continue;
4706 4731
4707 mpt2sas_scsih_issue_tm(ioc, handle, lun, 4732 mpt2sas_scsih_issue_tm(ioc, handle, 0, 0, lun,
4708 MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, 0, 30); 4733 MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, 0, 30, NULL);
4709 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
4710 termination_count += le32_to_cpu(mpi_reply->TerminationCount); 4734 termination_count += le32_to_cpu(mpi_reply->TerminationCount);
4711 } 4735 }
4712 ioc->broadcast_aen_busy = 0; 4736 ioc->broadcast_aen_busy = 0;
4713 mutex_unlock(&ioc->tm_cmds.mutex);
4714 4737
4715 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT 4738 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT
4716 "%s - exit, query_count = %d termination_count = %d\n", 4739 "%s - exit, query_count = %d termination_count = %d\n",