linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chad Dupuis <chad.dupuis@qlogic.com>
To: jbottomley@parallels.com
Cc: giridhar.malavali@qlogic.com, chad.dupuis@qlogic.com,
	andrew.vasquez@qlogic.com, linux-scsi@vger.kernel.org
Subject: [PATCH 04/18] qla2xxx: Proper cleanup of pass through commands when firmware returns error.
Date: Fri, 18 Nov 2011 09:03:08 -0800	[thread overview]
Message-ID: <1321635802-16491-5-git-send-email-chad.dupuis@qlogic.com> (raw)
In-Reply-To: <1321635802-16491-1-git-send-email-chad.dupuis@qlogic.com>

From: Giridhar Malavali <giridhar.malavali@qlogic.com>

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_isr.c |   73 ++++++++++++++++++++++++++++-----------
 drivers/scsi/qla2xxx/qla_os.c  |   19 +++++-----
 2 files changed, 61 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index b6023e9..c5d6cd1 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1895,6 +1895,45 @@ qla2x00_status_cont_entry(struct rsp_que *rsp, sts_cont_entry_t *pkt)
 	}
 }
 
+static int
+qla2x00_free_sp_ctx(scsi_qla_host_t *vha, srb_t *sp)
+{
+	struct qla_hw_data *ha = vha->hw;
+	struct srb_ctx *ctx;
+
+	if (!sp->ctx)
+		return 1;
+
+	ctx = sp->ctx;
+
+	if (ctx->type == SRB_LOGIN_CMD ||
+	    ctx->type == SRB_LOGOUT_CMD ||
+	    ctx->type == SRB_TM_CMD) {
+		((struct srb_iocb*)ctx->u.iocb_cmd)->done(sp);
+		return 0;
+	} else if (ctx->type == SRB_ADISC_CMD) {
+		((struct srb_iocb*)ctx->u.iocb_cmd)->free(sp);
+		return 0;
+	} else {
+		struct fc_bsg_job *bsg_job;
+
+		bsg_job = ctx->u.bsg_job;
+		if (ctx->type == SRB_ELS_CMD_HST ||
+		    ctx->type == SRB_CT_CMD)
+			kfree(sp->fcport);
+
+		bsg_job->reply->reply_data.ctels_reply.status =
+		    FC_CTELS_STATUS_OK;
+		bsg_job->reply->result = DID_ERROR << 16;
+		bsg_job->reply->reply_payload_rcv_len = 0;
+		kfree(sp->ctx);
+		mempool_free(sp, ha->srb_mempool);
+		bsg_job->job_done(bsg_job);
+		return 0;
+	}
+	return 1;
+}
+
 /**
  * qla2x00_error_entry() - Process an error entry.
  * @ha: SCSI driver HA context
@@ -1905,7 +1944,7 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
 {
 	srb_t *sp;
 	struct qla_hw_data *ha = vha->hw;
-	uint32_t handle = LSW(pkt->handle);
+	const char func[] = "ERROR-IOCB";
 	uint16_t que = MSW(pkt->handle);
 	struct req_que *req = ha->req_q_map[que];
 
@@ -1928,28 +1967,20 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
 		ql_dbg(ql_dbg_async, vha, 0x502f,
 		    "UNKNOWN flag error.\n");
 
-	/* Validate handle. */
-	if (handle < MAX_OUTSTANDING_COMMANDS)
-		sp = req->outstanding_cmds[handle];
-	else
-		sp = NULL;
-
+	sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
 	if (sp) {
-		/* Free outstanding command slot. */
-		req->outstanding_cmds[handle] = NULL;
-
-		/* Bad payload or header */
-		if (pkt->entry_status &
-		    (RF_INV_E_ORDER | RF_INV_E_COUNT |
-		     RF_INV_E_PARAM | RF_INV_E_TYPE)) {
-			sp->cmd->result = DID_ERROR << 16;
-		} else if (pkt->entry_status & RF_BUSY) {
-			sp->cmd->result = DID_BUS_BUSY << 16;
-		} else {
-			sp->cmd->result = DID_ERROR << 16;
+		if (qla2x00_free_sp_ctx (vha, sp)) {
+			if (pkt->entry_status &
+			    (RF_INV_E_ORDER | RF_INV_E_COUNT |
+			     RF_INV_E_PARAM | RF_INV_E_TYPE)) {
+				sp->cmd->result = DID_ERROR << 16;
+			} else if (pkt->entry_status & RF_BUSY) {
+				sp->cmd->result = DID_BUS_BUSY << 16;
+			} else {
+				sp->cmd->result = DID_ERROR << 16;
+			}
+			qla2x00_sp_compl(ha, sp);
 		}
-		qla2x00_sp_compl(ha, sp);
-
 	} else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type ==
 		COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7
 		|| pkt->entry_type == COMMAND_TYPE_6) {
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index ae1699f..c9a7452 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3690,16 +3690,6 @@ qla2x00_sp_free_dma(srb_t *sp)
 		sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
 	}
 
-	CMD_SP(cmd) = NULL;
-}
-
-static void
-qla2x00_sp_final_compl(struct qla_hw_data *ha, srb_t *sp)
-{
-	struct scsi_cmnd *cmd = sp->cmd;
-
-	qla2x00_sp_free_dma(sp);
-
 	if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
 		struct ct6_dsd *ctx = sp->ctx;
 		dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd,
@@ -3711,6 +3701,15 @@ qla2x00_sp_final_compl(struct qla_hw_data *ha, srb_t *sp)
 		sp->ctx = NULL;
 	}
 
+	CMD_SP(cmd) = NULL;
+}
+
+static void
+qla2x00_sp_final_compl(struct qla_hw_data *ha, srb_t *sp)
+{
+	struct scsi_cmnd *cmd = sp->cmd;
+
+	qla2x00_sp_free_dma(sp);
 	mempool_free(sp, ha->srb_mempool);
 	cmd->scsi_done(cmd);
 }
-- 
1.6.0.2



  parent reply	other threads:[~2011-11-18 17:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 17:03 [PATCH 00/18] qla2xxx: Patches for scsi-misc Chad Dupuis
2011-11-18 17:03 ` [PATCH 01/18] qla2xxx: Use less stack to emit logging messages Chad Dupuis
2011-11-18 17:03 ` [PATCH 02/18] qla2xxx: Make the logging functions verify their arguments and fixed the current broken uses as appropriate Chad Dupuis
2011-11-18 17:03 ` [PATCH 03/18] qla2xxx: Update to dynamic logging Chad Dupuis
2011-11-18 17:03 ` Chad Dupuis [this message]
2011-12-14 11:55   ` [PATCH 04/18] qla2xxx: Proper cleanup of pass through commands when firmware returns error James Bottomley
2011-12-16 15:32     ` Chad Dupuis
2011-11-18 17:03 ` [PATCH 05/18] qla2xxx: Only read requested mailbox registers Chad Dupuis
2011-11-18 17:03 ` [PATCH 06/18] qla2xxx: Limit excessive DPC cycles Chad Dupuis
2011-11-18 17:03 ` [PATCH 07/18] qla2xxx: Fix to include FCE data as part of dump Chad Dupuis
2011-12-14 12:03   ` James Bottomley
2011-12-14 12:26     ` Rolf Eike Beer
2011-12-16 15:34     ` Chad Dupuis
2011-11-18 17:03 ` [PATCH 08/18] qla2xxx: Correct report-id acquisition check Chad Dupuis
2011-11-18 17:03 ` [PATCH 09/18] qla2xxx: Corrections to returned sysfs error codes Chad Dupuis
2011-11-18 17:03 ` [PATCH 10/18] qla2xxx: Corrected the default setting of the help text of Minidump capture mask Chad Dupuis
2011-11-18 17:03 ` [PATCH 11/18] qla2xxx: Corrected the display of firmware dump availability for ISP82xx Chad Dupuis
2011-11-18 17:03 ` [PATCH 12/18] qla2xxx: Added a new entry to ISP specific function pointers structure Chad Dupuis
2011-11-18 17:03 ` [PATCH 13/18] qla2xxx: Process marker IOCB request on request queue 0 Chad Dupuis
2011-11-18 17:03 ` [PATCH 14/18] qla2xxx: Consolidated IOCB processing routines Chad Dupuis
2011-11-18 17:03 ` [PATCH 15/18] qla2xxx: Implement FCP priority tagging for 82xx adapters Chad Dupuis
2011-11-18 17:03 ` [PATCH 16/18] qla2xxx: Ensure there's enough request-queue space for passthru IOCBs Chad Dupuis
2011-11-18 17:03 ` [PATCH 17/18] qla2xxx: Move initialization of some variables before iospace_config Chad Dupuis
2011-11-18 17:03 ` [PATCH 18/18] qla2xxx: Do not check for minidump when device state is QLA82XX_DEV_READY Chad Dupuis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321635802-16491-5-git-send-email-chad.dupuis@qlogic.com \
    --to=chad.dupuis@qlogic.com \
    --cc=andrew.vasquez@qlogic.com \
    --cc=giridhar.malavali@qlogic.com \
    --cc=jbottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).