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 16/18] qla2xxx: Ensure there's enough request-queue space for passthru IOCBs.
Date: Fri, 18 Nov 2011 09:03:20 -0800	[thread overview]
Message-ID: <1321635802-16491-17-git-send-email-chad.dupuis@qlogic.com> (raw)
In-Reply-To: <1321635802-16491-1-git-send-email-chad.dupuis@qlogic.com>

From: Andrew Vasquez <andrew.vasquez@qlogic.com>

The driver should ensure there's a sufficient number of IOCBs
to satisfy the number of scatter-gather entries specified in the
command.  Add a 'count' to the control structure, srb_ctx, to use
in qla2x00_alloc_iocbs().

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_bsg.c  |   16 ++++++++++++++++
 drivers/scsi/qla2xxx/qla_def.h  |    1 +
 drivers/scsi/qla2xxx/qla_init.c |    1 +
 drivers/scsi/qla2xxx/qla_iocb.c |   11 +++++++++--
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index c0bc0c6..b1d0f93 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -31,6 +31,7 @@ qla2x00_get_ctx_bsg_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size)
 	memset(sp, 0, sizeof(*sp));
 	sp->fcport = fcport;
 	sp->ctx = ctx;
+	ctx->iocbs = 1;
 done:
 	return sp;
 }
@@ -389,6 +390,20 @@ done:
 	return rval;
 }
 
+inline uint16_t
+qla24xx_calc_ct_iocbs(uint16_t dsds)
+{
+	uint16_t iocbs;
+
+	iocbs = 1;
+	if (dsds > 2) {
+		iocbs += (dsds - 2) / 5;
+		if ((dsds - 2) % 5)
+			iocbs++;
+	}
+	return iocbs;
+}
+
 static int
 qla2x00_process_ct(struct fc_bsg_job *bsg_job)
 {
@@ -489,6 +504,7 @@ qla2x00_process_ct(struct fc_bsg_job *bsg_job)
 	ct = sp->ctx;
 	ct->type = SRB_CT_CMD;
 	ct->name = "bsg_ct";
+	ct->iocbs = qla24xx_calc_ct_iocbs(req_sg_cnt + rsp_sg_cnt);
 	ct->u.bsg_job = bsg_job;
 
 	ql_dbg(ql_dbg_user, vha, 0x7016,
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index d046db1..a6a4eeb 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -271,6 +271,7 @@ struct srb_iocb {
 struct srb_ctx {
 	uint16_t type;
 	char *name;
+	int iocbs;
 	union {
 		struct srb_iocb *iocb_cmd;
 		struct fc_bsg_job *bsg_job;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 05931e6..1fa067e 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -111,6 +111,7 @@ qla2x00_get_ctx_sp(scsi_qla_host_t *vha, fc_port_t *fcport, size_t size,
 	memset(sp, 0, sizeof(*sp));
 	sp->fcport = fcport;
 	sp->ctx = ctx;
+	ctx->iocbs = 1;
 	ctx->u.iocb_cmd = iocb;
 	iocb->free = qla2x00_ctx_sp_free;
 
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 841ffb3..55a9676 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -1818,6 +1818,7 @@ qla2x00_alloc_iocbs(scsi_qla_host_t *vha, srb_t *sp)
 	uint32_t index, handle;
 	request_t *pkt;
 	uint16_t cnt, req_cnt;
+	struct srb_ctx *ctx;
 
 	pkt = NULL;
 	req_cnt = 1;
@@ -1846,6 +1847,12 @@ qla2x00_alloc_iocbs(scsi_qla_host_t *vha, srb_t *sp)
 	req->outstanding_cmds[handle] = sp;
 	sp->handle = handle;
 
+	/* Adjust entry-counts as needed. */
+	if (sp->ctx) {
+		ctx = sp->ctx;
+		req_cnt = ctx->iocbs;
+	}
+
 skip_cmd_array:
 	/* Check for room on request queue. */
 	if (req->cnt < req_cnt) {
@@ -2622,8 +2629,8 @@ qla2x00_start_sp(srb_t *sp)
 		break;
 	case SRB_CT_CMD:
 		IS_FWI2_CAPABLE(ha) ?
-		qla24xx_ct_iocb(sp, pkt) :
-		qla2x00_ct_iocb(sp, pkt);
+		    qla24xx_ct_iocb(sp, pkt) :
+		    qla2x00_ct_iocb(sp, pkt);
 		break;
 	case SRB_ADISC_CMD:
 		IS_FWI2_CAPABLE(ha) ?
-- 
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 ` [PATCH 04/18] qla2xxx: Proper cleanup of pass through commands when firmware returns error Chad Dupuis
2011-12-14 11:55   ` 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 ` Chad Dupuis [this message]
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-17-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).