public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Don Brace <don.brace@pmcs.com>
To: scott.teel@pmcs.com, Kevin.Barnett@pmcs.com,
	james.bottomley@parallels.com, hch@infradead.org,
	Justin.Lindley@pmcs.com, brace@pmcs.com
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH 26/48] hpsa: factor out hpsa_ciss_submit function
Date: Wed, 14 Jan 2015 16:01:55 -0600	[thread overview]
Message-ID: <20150114220155.21325.28266.stgit@brunhilda> (raw)
In-Reply-To: <20150114215756.21325.41198.stgit@brunhilda>

From: Stephen Cameron <stephenmcameron@gmail.com>

Factor out the bottom part of the queuecommand function
which is the part that builds commands for submitting down
the "normal' RAID stack path of a Smart Array.

Need to factor this out to improve how commands that
were initially sent down one of the "ioaccellerated"
paths but which have some sort of error condition are
retried down the "normal" path.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
---
 drivers/scsi/hpsa.c |  126 +++++++++++++++++++++++++++------------------------
 1 file changed, 67 insertions(+), 59 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 94a82e3..cc3128f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2034,7 +2034,7 @@ static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,
 
 	c = cmd_alloc(h);
 
-	if (c == NULL) {			/* trouble... */
+	if (c == NULL) {
 		dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
 		return -ENOMEM;
 	}
@@ -3807,68 +3807,14 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
 						dev->scsi3addr);
 }
 
-/* Running in struct Scsi_Host->host_lock less mode */
-static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
+/* Submit commands down the "normal" RAID stack path */
+static int hpsa_ciss_submit(struct ctlr_info *h,
+	struct CommandList *c, struct scsi_cmnd *cmd,
+	unsigned char scsi3addr[])
 {
-	struct ctlr_info *h;
-	struct hpsa_scsi_dev_t *dev;
-	unsigned char scsi3addr[8];
-	struct CommandList *c;
-	int rc = 0;
-
-	/* Get the ptr to our adapter structure out of cmd->host. */
-	h = sdev_to_hba(cmd->device);
-	dev = cmd->device->hostdata;
-	if (!dev) {
-		cmd->result = DID_NO_CONNECT << 16;
-		cmd->scsi_done(cmd);
-		return 0;
-	}
-	memcpy(scsi3addr, dev->scsi3addr, sizeof(scsi3addr));
-
-	if (unlikely(lockup_detected(h))) {
-		cmd->result = DID_ERROR << 16;
-		cmd->scsi_done(cmd);
-		return 0;
-	}
-	c = cmd_alloc(h);
-	if (c == NULL) {			/* trouble... */
-		dev_err(&h->pdev->dev, "cmd_alloc returned NULL!\n");
-		return SCSI_MLQUEUE_HOST_BUSY;
-	}
-
-	/* Fill in the command list header */
-	/* save c in case we have to abort it  */
 	cmd->host_scribble = (unsigned char *) c;
-
 	c->cmd_type = CMD_SCSI;
 	c->scsi_cmd = cmd;
-
-	/* Call alternate submit routine for I/O accelerated commands.
-	 * Retries always go down the normal I/O path.
-	 */
-	if (likely(cmd->retries == 0 &&
-		cmd->request->cmd_type == REQ_TYPE_FS &&
-		h->acciopath_status)) {
-		if (dev->offload_enabled) {
-			rc = hpsa_scsi_ioaccel_raid_map(h, c);
-			if (rc == 0)
-				return 0; /* Sent on ioaccel path */
-			if (rc < 0) {   /* scsi_dma_map failed. */
-				cmd_free(h, c);
-				return SCSI_MLQUEUE_HOST_BUSY;
-			}
-		} else if (dev->ioaccel_handle) {
-			rc = hpsa_scsi_ioaccel_direct_map(h, c);
-			if (rc == 0)
-				return 0; /* Sent on direct map path */
-			if (rc < 0) {   /* scsi_dma_map failed. */
-				cmd_free(h, c);
-				return SCSI_MLQUEUE_HOST_BUSY;
-			}
-		}
-	}
-
 	c->Header.ReplyQueue = 0;  /* unused in simple mode */
 	memcpy(&c->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8);
 	c->Header.tag = cpu_to_le64((c->cmdindex << DIRECT_LOOKUP_SHIFT));
@@ -3927,6 +3873,68 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 	return 0;
 }
 
+/* Running in struct Scsi_Host->host_lock less mode */
+static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
+{
+	struct ctlr_info *h;
+	struct hpsa_scsi_dev_t *dev;
+	unsigned char scsi3addr[8];
+	struct CommandList *c;
+	int rc = 0;
+
+	/* Get the ptr to our adapter structure out of cmd->host. */
+	h = sdev_to_hba(cmd->device);
+	dev = cmd->device->hostdata;
+	if (!dev) {
+		cmd->result = DID_NO_CONNECT << 16;
+		cmd->scsi_done(cmd);
+		return 0;
+	}
+	memcpy(scsi3addr, dev->scsi3addr, sizeof(scsi3addr));
+
+	if (unlikely(lockup_detected(h))) {
+		cmd->result = DID_ERROR << 16;
+		cmd->scsi_done(cmd);
+		return 0;
+	}
+	c = cmd_alloc(h);
+	if (c == NULL) {			/* trouble... */
+		dev_err(&h->pdev->dev, "cmd_alloc returned NULL!\n");
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+
+	/* Call alternate submit routine for I/O accelerated commands.
+	 * Retries always go down the normal I/O path.
+	 */
+	if (likely(cmd->retries == 0 &&
+		cmd->request->cmd_type == REQ_TYPE_FS &&
+		h->acciopath_status)) {
+
+		cmd->host_scribble = (unsigned char *) c;
+		c->cmd_type = CMD_SCSI;
+		c->scsi_cmd = cmd;
+
+		if (dev->offload_enabled) {
+			rc = hpsa_scsi_ioaccel_raid_map(h, c);
+			if (rc == 0)
+				return 0; /* Sent on ioaccel path */
+			if (rc < 0) {   /* scsi_dma_map failed. */
+				cmd_free(h, c);
+				return SCSI_MLQUEUE_HOST_BUSY;
+			}
+		} else if (dev->ioaccel_handle) {
+			rc = hpsa_scsi_ioaccel_direct_map(h, c);
+			if (rc == 0)
+				return 0; /* Sent on direct map path */
+			if (rc < 0) {   /* scsi_dma_map failed. */
+				cmd_free(h, c);
+				return SCSI_MLQUEUE_HOST_BUSY;
+			}
+		}
+	}
+	return hpsa_ciss_submit(h, c, cmd, scsi3addr);
+}
+
 static int do_not_scan_if_controller_locked_up(struct ctlr_info *h)
 {
 	unsigned long flags;


  parent reply	other threads:[~2015-01-14 22:02 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 21:59 [PATCH 00/48] hpsa driver updates Don Brace
2015-01-14 21:59 ` [PATCH 01/48] hpsa: correct endian sparse warnings Don Brace
2015-01-14 21:59 ` [PATCH 02/48] hpsa: fix memory leak in kdump hard reset Don Brace
2015-01-14 21:59 ` [PATCH 03/48] hpsa: turn off interrupts when kdump starts Don Brace
2015-01-14 21:59 ` [PATCH 04/48] hpsa: change how SA controllers are reset Don Brace
2015-01-14 22:00 ` [PATCH 05/48] hpsa: correct change_queue_depth Don Brace
2015-01-15  9:50   ` Christoph Hellwig
2015-01-14 22:00 ` [PATCH 06/48] hpsa: adjust RAID-1, RAID-1ADM, and RAID-6 names Don Brace
2015-01-14 22:00 ` [PATCH 07/48] hpsa: rename free_irqs to hpsa_free_irqs Don Brace
2015-01-14 22:00 ` [PATCH 08/48] hpsa: Fix -Wunused-but-set-variable warning Don Brace
2015-01-14 22:00 ` [PATCH 09/48] hpsa: notice all request_irq errors Don Brace
2015-01-14 22:00 ` [PATCH 10/48] hpsa: remove 0x from queue depth print which is in decimal Don Brace
2015-01-14 22:00 ` [PATCH 11/48] hpsa: propagate hard_reset failures in reset_devices mode Don Brace
2015-01-14 22:00 ` [PATCH 12/48] hpsa: propagate return value from board ID lookup Don Brace
2015-01-14 22:00 ` [PATCH 13/48] hpsa: downgrade the Waiting for no-op print to dev_info Don Brace
2015-01-14 22:00 ` [PATCH 14/48] hpsa: refactor hpsa_find_board_params() to encapsulate legacy test Don Brace
2015-01-14 22:00 ` [PATCH 15/48] hpsa: trivial message and comment clean ups Don Brace
2015-01-14 22:01 ` [PATCH 16/48] hpsa: report failure to ioremap config table Don Brace
2015-01-14 22:01 ` [PATCH 17/48] hpsa: rename hpsa_request_irq to hpsa_request_irqs Don Brace
2015-01-14 22:01 ` [PATCH 18/48] hpsa: pass error from pci_set_consistent_dma_mask from hpsa_message Don Brace
2015-01-14 22:01 ` [PATCH 19/48] hpsa: report allocation failures while allocating SG chain blocks Don Brace
2015-01-14 22:01 ` [PATCH 20/48] hpsa: fix memory leak in hpsa_alloc_cmd_pool Don Brace
2015-01-14 22:01 ` [PATCH 21/48] hpsa: avoid unneccesary calls to resource freeing functions Don Brace
2015-01-14 22:01 ` [PATCH 22/48] hpsa: reserve some commands for use by driver Don Brace
2015-01-14 22:01 ` [PATCH 23/48] hpsa: get rid of cmd_special_alloc and cmd_special_free Don Brace
2015-01-14 22:01 ` [PATCH 24/48] hpsa: do not queue commands internally in driver Don Brace
2015-01-14 22:01 ` [PATCH 25/48] hpsa: do not request device rescan on every ioaccel path error Don Brace
2015-01-14 22:01 ` Don Brace [this message]
2015-01-14 22:02 ` [PATCH 27/48] hpsa: use workqueue to resubmit failed ioaccel commands Don Brace
2015-01-14 22:02 ` [PATCH 28/48] hpsa: use per-controller work queue Don Brace
2015-01-15 11:32   ` Christoph Hellwig
2015-01-14 22:02 ` [PATCH 29/48] hpsa: honor queue depth of physical devices Don Brace
2015-01-14 22:02 ` [PATCH 30/48] hpsa: fix race between abort handler and main i/o path Don Brace
2015-01-14 22:02 ` [PATCH 31/48] hpsa: optimize cmd_alloc function by remembering last allocation Don Brace
2015-01-14 22:02 ` [PATCH 32/48] hpsa: count passthru cmds with atomics, not a spin locked int Don Brace
2015-01-14 22:02 ` [PATCH 33/48] hpsa: slightly optimize SA5_performant_completed Don Brace
2015-01-16 14:16   ` Tomas Henzl
2015-01-14 22:02 ` [PATCH 34/48] hpsa: do not check for msi(x) in interrupt_pending Don Brace
2015-01-14 22:02 ` [PATCH 35/48] hpsa: remove incorrect BUG_ONs checking for raid offload enable Don Brace
2015-01-14 22:02 ` [PATCH 36/48] hpsa: do not ack controller events on controllers that do not support it Don Brace
2015-01-14 22:02 ` [PATCH 37/48] hpsa: guard against overflowing raid map array Don Brace
2015-01-14 22:02 ` [PATCH 38/48] hpsa: check for ctlr lockup after command allocation in main io path Don Brace
2015-01-14 22:03 ` [PATCH 39/48] hpsa: return failed from device reset/abort handlers Don Brace
2015-01-14 22:03 ` [PATCH 40/48] hpsa: do not use a void pointer for scsi_cmd field of struct CommandList Don Brace
2015-01-14 22:03 ` [PATCH 41/48] hpsa: print CDBs instead of kernel virtual addresses for uncommon errors Don Brace
2015-01-14 22:03 ` [PATCH 42/48] hpsa: do not use function pointers in fast path command submission Don Brace
2015-01-14 22:03 ` [PATCH 43/48] hpsa: move SG descriptor set-up out of hpsa_scatter_gather() Don Brace
2015-01-14 22:03 ` [PATCH 44/48] hpsa: refactor duplicated scan completion code into a new routine Don Brace
2015-01-14 22:03 ` [PATCH 45/48] hpsa: shorten the wait for the CISS doorbell mode change ack Don Brace
2015-01-16 14:08   ` Tomas Henzl
2015-01-14 22:03 ` [PATCH 46/48] hpsa: detect and report failures changing controller transport modes Don Brace
2015-01-14 22:03 ` [PATCH 47/48] hpsa: add in gen9 controller model names Don Brace
2015-01-14 22:03 ` [PATCH 48/48] hpsa: add in P840ar controller model name Don Brace
2015-01-23 13:21 ` [PATCH 00/48] hpsa driver updates Christoph Hellwig
2015-01-23 16:58   ` brace
2015-01-23 17:01     ` Christoph Hellwig
2015-01-23 18:15       ` Tomas Henzl

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=20150114220155.21325.28266.stgit@brunhilda \
    --to=don.brace@pmcs.com \
    --cc=Justin.Lindley@pmcs.com \
    --cc=Kevin.Barnett@pmcs.com \
    --cc=brace@pmcs.com \
    --cc=hch@infradead.org \
    --cc=james.bottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=scott.teel@pmcs.com \
    /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