[PATCH 7/7] mpi3mr: task management for pass through command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Kashyap Desai <kashyap.desai@xxxxxxxxxxxx>

Cc: sathya.prakash@xxxxxxxxxxxx
---
 drivers/scsi/mpi3mr/mpi3mr.h     |  4 ++++
 drivers/scsi/mpi3mr/mpi3mr_app.c | 23 +++++++++++++++++++----
 drivers/scsi/mpi3mr/mpi3mr_os.c  |  2 +-
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
index 289aaaec7ee2..db3de78a979c 100644
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -953,6 +953,10 @@ void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc);
 
 int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
 			      u32 reset_reason, u8 snapdump);
+int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
+		    u16 handle, uint lun, u16 htag, ulong timeout,
+		    struct mpi3mr_drv_cmd *drv_cmd,
+		    u8 *resp_code, struct scmd_priv *cmd_priv);
 int mpi3mr_diagfault_reset_handler(struct mpi3mr_ioc *mrioc,
 				   u32 reset_reason);
 void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc);
diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
index 0ecdf02c10c5..c45d722a7f2a 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_app.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -931,7 +931,7 @@ static long mpi3mr_ioctl_process_mpt_cmds(struct file *file,
 	struct mpi3_status_reply_descriptor *status_desc;
 	struct mpi3mr_ioctl_reply_buf *ioctl_reply_buf = NULL;
 	u8 *mpi_req = NULL, *sense_buff_k = NULL;
-	u8 count, bufcnt, din_cnt = 0, dout_cnt = 0, nvme_fmt;
+	u8 count, bufcnt, din_cnt = 0, dout_cnt = 0, nvme_fmt, resp_code;
 	u8 erb_offset = 0xFF, reply_offset = 0xFF, sg_entries = 0;
 	bool invalid_be = false, is_rmcb = false, is_rmrb = false;
 	u32 tmplen;
@@ -1165,10 +1165,25 @@ static long mpi3mr_ioctl_process_mpt_cmds(struct file *file,
 				    (karg.timeout * HZ));
 	if (!(mrioc->ioctl_cmds.state & MPI3MR_CMD_COMPLETE)) {
 		mrioc->ioctl_cmds.is_waiting = 0;
-		dbgprint(mrioc, "%s command timed out\n", __func__);
+		if (mrioc->ioctl_cmds.state & MPI3MR_CMD_RESET) {
+			rval = -EAGAIN;
+			goto out_unlock;
+		}
 		rval = -EFAULT;
-		mpi3mr_soft_reset_handler(mrioc,
-				MPI3MR_RESET_FROM_IOCTL_TIMEOUT, 1);
+		dbgprint(mrioc,
+		    "%s: ioctl request timedout after %d seconds\n",
+		    __func__, karg.timeout);
+		if ((mpi_header->function == MPI3_FUNCTION_NVME_ENCAPSULATED) ||
+		    (mpi_header->function == MPI3_FUNCTION_SCSI_IO))
+			mpi3mr_issue_tm(mrioc,
+			    MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
+			    mpi_header->function_dependent, 0,
+			    MPI3MR_HOSTTAG_BLK_TMS, MPI3MR_RESETTM_TIMEOUT,
+			    &mrioc->host_tm_cmds, &resp_code, NULL);
+		if (!(mrioc->ioctl_cmds.state & MPI3MR_CMD_COMPLETE) &&
+		    !(mrioc->ioctl_cmds.state & MPI3MR_CMD_RESET))
+			mpi3mr_soft_reset_handler(mrioc,
+			    MPI3MR_RESET_FROM_IOCTL_TIMEOUT, 1);
 		goto out_unlock;
 	}
 
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 149ba3fdfceb..c82cb3c2fe4b 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -2606,7 +2606,7 @@ static void mpi3mr_print_response_code(struct mpi3mr_ioc *mrioc, u8 resp_code)
  *
  * Return: 0 on success, non-zero on errors
  */
-static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
+int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
 	u16 handle, uint lun, u16 htag, ulong timeout,
 	struct mpi3mr_drv_cmd *drv_cmd,
 	u8 *resp_code, struct scmd_priv *cmd_priv)
-- 
2.18.1

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux