From: Xiang Chen <chenxiang66(a)hisilicon.com>
For ssp and stp commands, most fields of slot->cmd_hdr will be overwrote
by function prep_ssp_v3_hw() and prep_ata_v3_hw(), so it is not necessary
to memset them in front, and just write dw7 and sg_len to 0 for them
(dw5 is alway 0).
For smp and abort commands, they are not used frequently and most fields
of them are not overwrote, so memset slot->cmd_hdr separately for them.
Signed-off-by: Xiang Chen <chenxiang66(a)hisilicon.com>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 1 -
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 +++
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 6 ++++++
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 8 ++++++++
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index fe40e3ad68c0..9792b2628933 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -439,7 +439,6 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,
slot->is_internal = tmf;
task->lldd_task = slot;
- memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ);
memset(hisi_sas_status_buf_addr_mem(slot), 0,
sizeof(struct hisi_sas_err_record));
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 3059d19e4368..282d8b9d882e 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -922,6 +922,7 @@ static void prep_smp_v1_hw(struct hisi_hba *hisi_hba,
dma_addr_t req_dma_addr;
unsigned int req_len;
+ memset(hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
/* req */
sg_req = &task->smp_task.smp_req;
req_len = sg_dma_len(sg_req);
@@ -1007,6 +1008,8 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
dw2 |= (HISI_SAS_MAX_SSP_RESP_SZ/4) << CMD_HDR_MRFL_OFF;
hdr->transfer_tags = cpu_to_le32(slot->idx << CMD_HDR_IPTT_OFF);
+ hdr->dw7 = 0;
+ hdr->sg_len = 0;
if (has_data)
prep_prd_sge_v1_hw(hisi_hba, slot, hdr, task->scatter,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 64ed3e472e65..c7c892ac98e4 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1705,6 +1705,7 @@ static void prep_smp_v2_hw(struct hisi_hba *hisi_hba,
dma_addr_t req_dma_addr;
unsigned int req_len;
+ memset(hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
/* req */
sg_req = &task->smp_task.smp_req;
req_dma_addr = sg_dma_address(sg_req);
@@ -1784,6 +1785,8 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
hdr->dw2 = cpu_to_le32(dw2);
hdr->transfer_tags = cpu_to_le32(slot->idx);
+ hdr->dw7 = 0;
+ hdr->sg_len = 0;
if (has_data)
prep_prd_sge_v2_hw(hisi_hba, slot, hdr, task->scatter,
@@ -2551,6 +2554,8 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,
/* dw3 */
hdr->transfer_tags = cpu_to_le32(slot->idx);
+ hdr->dw7 = 0;
+ hdr->sg_len = 0;
if (has_data)
prep_prd_sge_v2_hw(hisi_hba, slot, hdr, task->scatter,
@@ -2617,6 +2622,7 @@ static void prep_abort_v2_hw(struct hisi_hba *hisi_hba,
/* Set the timeout to 10ms less than internal abort timeout */
mod_timer(timer, jiffies + msecs_to_jiffies(100));
+ memset(hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
/* dw0 */
hdr->dw0 = cpu_to_le32((5 << CMD_HDR_CMD_OFF) | /*abort*/
(port->id << CMD_HDR_PORT_OFF) |
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 699c49865b77..636ca7ccd1f6 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -1262,6 +1262,9 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
hdr->dw2 = cpu_to_le32(dw2);
hdr->transfer_tags = cpu_to_le32(slot->idx);
+ hdr->dw7 = 0;
+ hdr->sg_len = 0;
+
if (has_data) {
prep_prd_sge_v3_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem);
@@ -1343,6 +1346,7 @@ static void prep_smp_v3_hw(struct hisi_hba *hisi_hba,
dma_addr_t req_dma_addr;
unsigned int req_len;
+ memset(hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
/* req */
sg_req = &task->smp_task.smp_req;
req_len = sg_dma_len(sg_req);
@@ -1433,6 +1437,9 @@ static void prep_ata_v3_hw(struct hisi_hba *hisi_hba,
/* dw3 */
hdr->transfer_tags = cpu_to_le32(slot->idx);
+ hdr->dw7 = 0;
+ hdr->sg_len = 0;
+
if (has_data)
prep_prd_sge_v3_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem);
@@ -1458,6 +1465,7 @@ static void prep_abort_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;
struct hisi_sas_port *port = slot->port;
+ memset(hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
/* dw0 */
hdr->dw0 = cpu_to_le32((5U << CMD_HDR_CMD_OFF) | /*abort*/
(port->id << CMD_HDR_PORT_OFF) |
--
2.33.0