Commit 9d89326c authored by Matthew R. Ochs's avatar Matthew R. Ochs Committed by Martin K. Petersen

scsi: cxlflash: Cleanup queuecommand()

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: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: default avatarUma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d4ace351
...@@ -388,11 +388,11 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) ...@@ -388,11 +388,11 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
struct afu *afu = cfg->afu; struct afu *afu = cfg->afu;
struct device *dev = &cfg->dev->dev; struct device *dev = &cfg->dev->dev;
struct afu_cmd *cmd = sc_to_afucz(scp); struct afu_cmd *cmd = sc_to_afucz(scp);
struct scatterlist *sg = scsi_sglist(scp);
u32 port_sel = scp->device->channel + 1; u32 port_sel = scp->device->channel + 1;
int nseg, i, ncount; u16 req_flags = SISL_REQ_FLAGS_SUP_UNDERRUN;
struct scatterlist *sg;
ulong lock_flags; ulong lock_flags;
short lflag = 0; int nseg = 0;
int rc = 0; int rc = 0;
int kref_got = 0; int kref_got = 0;
...@@ -435,45 +435,35 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp) ...@@ -435,45 +435,35 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
kref_get(&cfg->afu->mapcount); kref_get(&cfg->afu->mapcount);
kref_got = 1; kref_got = 1;
cmd->rcb.ctx_id = afu->ctx_hndl; if (likely(sg)) {
cmd->rcb.msi = SISL_MSI_RRQ_UPDATED; nseg = scsi_dma_map(scp);
cmd->rcb.port_sel = port_sel; if (unlikely(nseg < 0)) {
cmd->rcb.lun_id = lun_to_lunid(scp->device->lun); dev_err(dev, "%s: Fail DMA map!\n", __func__);
rc = SCSI_MLQUEUE_HOST_BUSY;
if (scp->sc_data_direction == DMA_TO_DEVICE) goto out;
lflag = SISL_REQ_FLAGS_HOST_WRITE; }
else
lflag = SISL_REQ_FLAGS_HOST_READ;
cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID | cmd->rcb.data_len = sg_dma_len(sg);
SISL_REQ_FLAGS_SUP_UNDERRUN | lflag); cmd->rcb.data_ea = sg_dma_address(sg);
}
/* Stash the scp in the reserved field, for reuse during interrupt */
cmd->rcb.scp = scp; cmd->rcb.scp = scp;
cmd->parent = afu; cmd->parent = afu;
nseg = scsi_dma_map(scp); cmd->rcb.ctx_id = afu->ctx_hndl;
if (unlikely(nseg < 0)) { cmd->rcb.msi = SISL_MSI_RRQ_UPDATED;
dev_err(dev, "%s: Fail DMA map! nseg=%d\n", cmd->rcb.port_sel = port_sel;
__func__, nseg); cmd->rcb.lun_id = lun_to_lunid(scp->device->lun);
rc = SCSI_MLQUEUE_HOST_BUSY;
goto out;
}
ncount = scsi_sg_count(scp); if (scp->sc_data_direction == DMA_TO_DEVICE)
scsi_for_each_sg(scp, sg, ncount, i) { req_flags |= SISL_REQ_FLAGS_HOST_WRITE;
cmd->rcb.data_len = sg_dma_len(sg);
cmd->rcb.data_ea = sg_dma_address(sg);
}
/* 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)); memcpy(cmd->rcb.cdb, scp->cmnd, sizeof(cmd->rcb.cdb));
/* Send the command */
rc = send_cmd(afu, cmd); rc = send_cmd(afu, cmd);
if (unlikely(rc)) if (unlikely(rc))
scsi_dma_unmap(scp); scsi_dma_unmap(scp);
out: out:
if (kref_got) if (kref_got)
kref_put(&afu->mapcount, afu_unmap); kref_put(&afu->mapcount, afu_unmap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment