Commit bc22f9c0 authored by Xiang Chen's avatar Xiang Chen Committed by Martin K. Petersen

scsi: hisi_sas: Remove unnecessary variable to hold DMA map elements

Use slot->n_elem to store the return value of dma_map_sg() for SSP and SMP
IOs, and remove unnecessary variable n_elem_req.

Link: https://lore.kernel.org/r/1657823002-139010-3-git-send-email-john.garry@huawei.comSigned-off-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent eed9f513
...@@ -220,9 +220,10 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, ...@@ -220,9 +220,10 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
if (!sas_protocol_ata(task->task_proto)) { if (!sas_protocol_ata(task->task_proto)) {
if (slot->n_elem) if (slot->n_elem)
dma_unmap_sg(dev, task->scatter, if (task->task_proto & SAS_PROTOCOL_SSP)
task->num_scatter, dma_unmap_sg(dev, task->scatter,
task->data_dir); task->num_scatter,
task->data_dir);
if (slot->n_elem_dif) { if (slot->n_elem_dif) {
struct sas_ssp_task *ssp_task = &task->ssp_task; struct sas_ssp_task *ssp_task = &task->ssp_task;
struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
...@@ -269,28 +270,23 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, ...@@ -269,28 +270,23 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba,
} }
static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba, static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba,
struct sas_task *task, int n_elem, struct sas_task *task, int n_elem)
int n_elem_req)
{ {
struct device *dev = hisi_hba->dev; struct device *dev = hisi_hba->dev;
if (!sas_protocol_ata(task->task_proto)) { if (!sas_protocol_ata(task->task_proto) && n_elem) {
if (task->num_scatter) { if (task->num_scatter) {
if (n_elem) dma_unmap_sg(dev, task->scatter, task->num_scatter,
dma_unmap_sg(dev, task->scatter, task->data_dir);
task->num_scatter,
task->data_dir);
} else if (task->task_proto & SAS_PROTOCOL_SMP) { } else if (task->task_proto & SAS_PROTOCOL_SMP) {
if (n_elem_req) dma_unmap_sg(dev, &task->smp_task.smp_req,
dma_unmap_sg(dev, &task->smp_task.smp_req, 1, DMA_TO_DEVICE);
1, DMA_TO_DEVICE);
} }
} }
} }
static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
struct sas_task *task, int *n_elem, struct sas_task *task, int *n_elem)
int *n_elem_req)
{ {
struct device *dev = hisi_hba->dev; struct device *dev = hisi_hba->dev;
int rc; int rc;
...@@ -308,9 +304,9 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, ...@@ -308,9 +304,9 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
goto prep_out; goto prep_out;
} }
} else if (task->task_proto & SAS_PROTOCOL_SMP) { } else if (task->task_proto & SAS_PROTOCOL_SMP) {
*n_elem_req = dma_map_sg(dev, &task->smp_task.smp_req, *n_elem = dma_map_sg(dev, &task->smp_task.smp_req,
1, DMA_TO_DEVICE); 1, DMA_TO_DEVICE);
if (!*n_elem_req) { if (!*n_elem) {
rc = -ENOMEM; rc = -ENOMEM;
goto prep_out; goto prep_out;
} }
...@@ -332,8 +328,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba, ...@@ -332,8 +328,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
err_out_dma_unmap: err_out_dma_unmap:
/* It would be better to call dma_unmap_sg() here, but it's messy */ /* It would be better to call dma_unmap_sg() here, but it's messy */
hisi_sas_dma_unmap(hisi_hba, task, *n_elem, hisi_sas_dma_unmap(hisi_hba, task, *n_elem);
*n_elem_req);
prep_out: prep_out:
return rc; return rc;
} }
...@@ -457,7 +452,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, ...@@ -457,7 +452,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,
static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
{ {
int n_elem = 0, n_elem_dif = 0, n_elem_req = 0; int n_elem = 0, n_elem_dif = 0;
struct domain_device *device = task->dev; struct domain_device *device = task->dev;
struct asd_sas_port *sas_port = device->port; struct asd_sas_port *sas_port = device->port;
struct hisi_sas_device *sas_dev = device->lldd_dev; struct hisi_sas_device *sas_dev = device->lldd_dev;
...@@ -568,8 +563,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) ...@@ -568,8 +563,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
return -EINVAL; return -EINVAL;
} }
rc = hisi_sas_dma_map(hisi_hba, task, &n_elem, rc = hisi_sas_dma_map(hisi_hba, task, &n_elem);
&n_elem_req);
if (rc < 0) if (rc < 0)
goto prep_out; goto prep_out;
...@@ -605,8 +599,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) ...@@ -605,8 +599,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
if (!sas_protocol_ata(task->task_proto)) if (!sas_protocol_ata(task->task_proto))
hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif); hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif);
err_out_dma_unmap: err_out_dma_unmap:
hisi_sas_dma_unmap(hisi_hba, task, n_elem, hisi_sas_dma_unmap(hisi_hba, task, n_elem);
n_elem_req);
prep_out: prep_out:
dev_err(dev, "task exec: failed[%d]!\n", rc); dev_err(dev, "task exec: failed[%d]!\n", rc);
return rc; return rc;
......
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