From: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
To: linux-scsi@vger.kernel.org,
James Bottomley <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>
Cc: Brian King <brking@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org, Ian Munsie <imunsie@au1.ibm.com>,
Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
Frederic Barrat <fbarrat@linux.vnet.ibm.com>,
Christophe Lombard <clombard@linux.vnet.ibm.com>
Subject: [PATCH v2 12/14] cxlflash: Cleanup queuecommand()
Date: Mon, 28 Nov 2016 18:43:01 -0600 [thread overview]
Message-ID: <1480380181-60607-1-git-send-email-ukrishn@linux.vnet.ibm.com> (raw)
In-Reply-To: <1480379984-60114-1-git-send-email-ukrishn@linux.vnet.ibm.com>
From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>
The queuecommand routine is disorganized where it populates the
private command and also contains some logic/statements that are
not needed given that cxlflash devices do not (and likely never
will) support scatter-gather.
Restructure the code to remove the unnecessary logic and create an
organized flow:
handle state -> DMA map -> populate command -> send command
Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
---
drivers/scsi/cxlflash/main.c | 50 ++++++++++++++++++--------------------------
1 file changed, 20 insertions(+), 30 deletions(-)
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index b763699..4e70c9a 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -388,11 +388,11 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
struct afu *afu = cfg->afu;
struct device *dev = &cfg->dev->dev;
struct afu_cmd *cmd = sc_to_afucz(scp);
+ struct scatterlist *sg = scsi_sglist(scp);
u32 port_sel = scp->device->channel + 1;
- int nseg, i, ncount;
- struct scatterlist *sg;
+ u16 req_flags = SISL_REQ_FLAGS_SUP_UNDERRUN;
ulong lock_flags;
- short lflag = 0;
+ int nseg = 0;
int rc = 0;
int kref_got = 0;
@@ -435,45 +435,35 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
kref_get(&cfg->afu->mapcount);
kref_got = 1;
- cmd->rcb.ctx_id = afu->ctx_hndl;
- cmd->rcb.msi = SISL_MSI_RRQ_UPDATED;
- cmd->rcb.port_sel = port_sel;
- cmd->rcb.lun_id = lun_to_lunid(scp->device->lun);
-
- if (scp->sc_data_direction == DMA_TO_DEVICE)
- lflag = SISL_REQ_FLAGS_HOST_WRITE;
- else
- lflag = SISL_REQ_FLAGS_HOST_READ;
+ if (likely(sg)) {
+ nseg = scsi_dma_map(scp);
+ if (unlikely(nseg < 0)) {
+ dev_err(dev, "%s: Fail DMA map!\n", __func__);
+ rc = SCSI_MLQUEUE_HOST_BUSY;
+ goto out;
+ }
- cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID |
- SISL_REQ_FLAGS_SUP_UNDERRUN | lflag);
+ cmd->rcb.data_len = sg_dma_len(sg);
+ cmd->rcb.data_ea = sg_dma_address(sg);
+ }
- /* Stash the scp in the reserved field, for reuse during interrupt */
cmd->rcb.scp = scp;
cmd->parent = afu;
- nseg = scsi_dma_map(scp);
- if (unlikely(nseg < 0)) {
- dev_err(dev, "%s: Fail DMA map! nseg=%d\n",
- __func__, nseg);
- rc = SCSI_MLQUEUE_HOST_BUSY;
- goto out;
- }
+ cmd->rcb.ctx_id = afu->ctx_hndl;
+ cmd->rcb.msi = SISL_MSI_RRQ_UPDATED;
+ cmd->rcb.port_sel = port_sel;
+ cmd->rcb.lun_id = lun_to_lunid(scp->device->lun);
- ncount = scsi_sg_count(scp);
- scsi_for_each_sg(scp, sg, ncount, i) {
- cmd->rcb.data_len = sg_dma_len(sg);
- cmd->rcb.data_ea = sg_dma_address(sg);
- }
+ if (scp->sc_data_direction == DMA_TO_DEVICE)
+ req_flags |= SISL_REQ_FLAGS_HOST_WRITE;
- /* Copy the CDB from the scsi_cmnd passed in */
+ cmd->rcb.req_flags = req_flags;
memcpy(cmd->rcb.cdb, scp->cmnd, sizeof(cmd->rcb.cdb));
- /* Send the command */
rc = send_cmd(afu, cmd);
if (unlikely(rc))
scsi_dma_unmap(scp);
-
out:
if (kref_got)
kref_put(&afu->mapcount, afu_unmap);
--
2.1.0
next prev parent reply other threads:[~2016-11-29 0:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 0:39 [PATCH v2 00/14] cxlflash: Fixes, enhancements, cleanup and staging Uma Krishnan
2016-11-29 0:41 ` [PATCH v2 01/14] cxlflash: Set sg_tablesize to 1 instead of SG_NONE Uma Krishnan
2016-11-29 0:41 ` [PATCH v2 02/14] cxlflash: Fix crash in cxlflash_restore_luntable() Uma Krishnan
2016-11-29 0:41 ` [PATCH v2 03/14] cxlflash: Improve context_reset() logic Uma Krishnan
2016-11-29 0:41 ` [PATCH v2 04/14] cxlflash: Avoid command room violation Uma Krishnan
2016-11-29 17:04 ` Matthew R. Ochs
2016-11-29 0:42 ` [PATCH v2 05/14] cxlflash: Remove unused buffer from AFU command Uma Krishnan
2016-11-30 22:03 ` Uma Krishnan
2016-11-29 0:42 ` [PATCH v2 06/14] cxlflash: Allocate memory instead of using command pool for AFU sync Uma Krishnan
2016-11-30 22:04 ` Uma Krishnan
2016-11-29 0:42 ` [PATCH v2 07/14] cxlflash: Use cmd_size for private commands Uma Krishnan
2016-11-30 22:05 ` Uma Krishnan
2016-11-29 0:42 ` [PATCH v2 08/14] cxlflash: Remove private command pool Uma Krishnan
2016-11-30 22:11 ` Uma Krishnan
2016-11-29 0:42 ` [PATCH v2 09/14] cxlflash: Wait for active AFU commands to timeout upon tear down Uma Krishnan
2016-11-30 22:11 ` Uma Krishnan
2016-11-29 0:42 ` [PATCH v2 10/14] cxlflash: Remove AFU command lock Uma Krishnan
2016-11-30 22:12 ` Uma Krishnan
2016-11-29 0:42 ` [PATCH v2 11/14] cxlflash: Cleanup send_tmf() Uma Krishnan
2016-11-30 22:12 ` Uma Krishnan
2016-11-29 0:43 ` Uma Krishnan [this message]
2016-11-30 22:13 ` [PATCH v2 12/14] cxlflash: Cleanup queuecommand() Uma Krishnan
2016-11-29 0:43 ` [PATCH v2 13/14] cxlflash: Migrate IOARRIN specific routines to function pointers Uma Krishnan
2016-11-30 22:13 ` Uma Krishnan
2016-11-29 0:43 ` [PATCH v2 14/14] cxlflash: Migrate scsi command pointer to AFU command Uma Krishnan
2016-11-30 22:14 ` Uma Krishnan
2016-11-30 16:42 ` [PATCH v2 00/14] cxlflash: Fixes, enhancements, cleanup and staging Martin K. Petersen
2016-12-01 0:55 ` Martin K. Petersen
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=1480380181-60607-1-git-send-email-ukrishn@linux.vnet.ibm.com \
--to=ukrishn@linux.vnet.ibm.com \
--cc=andrew.donnellan@au1.ibm.com \
--cc=brking@linux.vnet.ibm.com \
--cc=clombard@linux.vnet.ibm.com \
--cc=fbarrat@linux.vnet.ibm.com \
--cc=imunsie@au1.ibm.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=manoj@linux.vnet.ibm.com \
--cc=martin.petersen@oracle.com \
--cc=mrochs@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).