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

scsi: hisi_sas: make return type of prep functions void

Since the task prep functions now should not fail, adjust the return
types to void.

In addition, some checks in the task prep functions are relocated to the
main module; this is specifically the check for the number of elements
in an sg list exceeded the HW SGE limit.
Signed-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 7eee4b92
...@@ -214,14 +214,14 @@ struct hisi_sas_hw { ...@@ -214,14 +214,14 @@ struct hisi_sas_hw {
void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no); void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no);
int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq);
void (*start_delivery)(struct hisi_sas_dq *dq); void (*start_delivery)(struct hisi_sas_dq *dq);
int (*prep_ssp)(struct hisi_hba *hisi_hba, void (*prep_ssp)(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot, int is_tmf,
struct hisi_sas_tmf_task *tmf); struct hisi_sas_tmf_task *tmf);
int (*prep_smp)(struct hisi_hba *hisi_hba, void (*prep_smp)(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot); struct hisi_sas_slot *slot);
int (*prep_stp)(struct hisi_hba *hisi_hba, void (*prep_stp)(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot); struct hisi_sas_slot *slot);
int (*prep_abort)(struct hisi_hba *hisi_hba, void (*prep_abort)(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
int device_id, int abort_flag, int tag_to_abort); int device_id, int abort_flag, int tag_to_abort);
int (*slot_complete)(struct hisi_hba *hisi_hba, int (*slot_complete)(struct hisi_hba *hisi_hba,
......
...@@ -243,30 +243,30 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, ...@@ -243,30 +243,30 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
} }
EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free); EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free);
static int hisi_sas_task_prep_smp(struct hisi_hba *hisi_hba, static void hisi_sas_task_prep_smp(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
return hisi_hba->hw->prep_smp(hisi_hba, slot); hisi_hba->hw->prep_smp(hisi_hba, slot);
} }
static int hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba, static void hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot, int is_tmf,
struct hisi_sas_tmf_task *tmf) struct hisi_sas_tmf_task *tmf)
{ {
return hisi_hba->hw->prep_ssp(hisi_hba, slot, is_tmf, tmf); hisi_hba->hw->prep_ssp(hisi_hba, slot, is_tmf, tmf);
} }
static int hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba, static void hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
return hisi_hba->hw->prep_stp(hisi_hba, slot); hisi_hba->hw->prep_stp(hisi_hba, slot);
} }
static int hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
int device_id, int abort_flag, int tag_to_abort) int device_id, int abort_flag, int tag_to_abort)
{ {
return hisi_hba->hw->prep_abort(hisi_hba, slot, hisi_hba->hw->prep_abort(hisi_hba, slot,
device_id, abort_flag, tag_to_abort); device_id, abort_flag, tag_to_abort);
} }
...@@ -395,6 +395,13 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq ...@@ -395,6 +395,13 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq
} else } else
n_elem = task->num_scatter; n_elem = task->num_scatter;
if (n_elem > HISI_SAS_SGE_PAGE_CNT) {
dev_err(dev, "task prep: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT",
n_elem);
rc = -EINVAL;
goto err_out_dma_unmap;
}
spin_lock_irqsave(&hisi_hba->lock, flags); spin_lock_irqsave(&hisi_hba->lock, flags);
if (hisi_hba->hw->slot_index_alloc) if (hisi_hba->hw->slot_index_alloc)
rc = hisi_hba->hw->slot_index_alloc(hisi_hba, &slot_idx, rc = hisi_hba->hw->slot_index_alloc(hisi_hba, &slot_idx,
...@@ -439,28 +446,22 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq ...@@ -439,28 +446,22 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq
switch (task->task_proto) { switch (task->task_proto) {
case SAS_PROTOCOL_SMP: case SAS_PROTOCOL_SMP:
rc = hisi_sas_task_prep_smp(hisi_hba, slot); hisi_sas_task_prep_smp(hisi_hba, slot);
break; break;
case SAS_PROTOCOL_SSP: case SAS_PROTOCOL_SSP:
rc = hisi_sas_task_prep_ssp(hisi_hba, slot, is_tmf, tmf); hisi_sas_task_prep_ssp(hisi_hba, slot, is_tmf, tmf);
break; break;
case SAS_PROTOCOL_SATA: case SAS_PROTOCOL_SATA:
case SAS_PROTOCOL_STP: case SAS_PROTOCOL_STP:
case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
rc = hisi_sas_task_prep_ata(hisi_hba, slot); hisi_sas_task_prep_ata(hisi_hba, slot);
break; break;
default: default:
dev_err(dev, "task prep: unknown/unsupported proto (0x%x)\n", dev_err(dev, "task prep: unknown/unsupported proto (0x%x)\n",
task->task_proto); task->task_proto);
rc = -EINVAL;
break; break;
} }
if (rc) {
dev_err(dev, "task prep: rc = 0x%x\n", rc);
goto err_out_buf;
}
spin_lock_irqsave(&hisi_hba->lock, flags); spin_lock_irqsave(&hisi_hba->lock, flags);
list_add_tail(&slot->entry, &sas_dev->list); list_add_tail(&slot->entry, &sas_dev->list);
spin_unlock_irqrestore(&hisi_hba->lock, flags); spin_unlock_irqrestore(&hisi_hba->lock, flags);
...@@ -473,9 +474,6 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq ...@@ -473,9 +474,6 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq
return 0; return 0;
err_out_buf:
dma_pool_free(hisi_hba->buffer_pool, slot->buf,
slot->buf_dma);
err_out_slot_buf: err_out_slot_buf:
/* Nothing to be done */ /* Nothing to be done */
err_out_tag: err_out_tag:
...@@ -1554,10 +1552,8 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, ...@@ -1554,10 +1552,8 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id,
memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ);
memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ); memset(hisi_sas_status_buf_addr_mem(slot), 0, HISI_SAS_STATUS_BUF_SZ);
rc = hisi_sas_task_prep_abort(hisi_hba, slot, device_id, hisi_sas_task_prep_abort(hisi_hba, slot, device_id,
abort_flag, task_tag); abort_flag, task_tag);
if (rc)
goto err_out_buf;
spin_lock_irqsave(&hisi_hba->lock, flags); spin_lock_irqsave(&hisi_hba->lock, flags);
list_add_tail(&slot->entry, &sas_dev->list); list_add_tail(&slot->entry, &sas_dev->list);
...@@ -1574,9 +1570,6 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, ...@@ -1574,9 +1570,6 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id,
return 0; return 0;
err_out_buf:
dma_pool_free(hisi_hba->buffer_pool, slot->buf,
slot->buf_dma);
err_out_tag: err_out_tag:
spin_lock_irqsave(&hisi_hba->lock, flags); spin_lock_irqsave(&hisi_hba->lock, flags);
hisi_sas_slot_index_free(hisi_hba, slot_idx); hisi_sas_slot_index_free(hisi_hba, slot_idx);
......
...@@ -935,23 +935,16 @@ static void start_delivery_v1_hw(struct hisi_sas_dq *dq) ...@@ -935,23 +935,16 @@ static void start_delivery_v1_hw(struct hisi_sas_dq *dq)
dq->wr_point); dq->wr_point);
} }
static int prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba, static void prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
struct hisi_sas_cmd_hdr *hdr, struct hisi_sas_cmd_hdr *hdr,
struct scatterlist *scatter, struct scatterlist *scatter,
int n_elem) int n_elem)
{ {
struct hisi_sas_sge_page *sge_page = hisi_sas_sge_addr_mem(slot); struct hisi_sas_sge_page *sge_page = hisi_sas_sge_addr_mem(slot);
struct device *dev = hisi_hba->dev;
struct scatterlist *sg; struct scatterlist *sg;
int i; int i;
if (n_elem > HISI_SAS_SGE_PAGE_CNT) {
dev_err(dev, "prd err: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT",
n_elem);
return -EINVAL;
}
for_each_sg(scatter, sg, n_elem, i) { for_each_sg(scatter, sg, n_elem, i) {
struct hisi_sas_sge *entry = &sge_page->sge[i]; struct hisi_sas_sge *entry = &sge_page->sge[i];
...@@ -964,11 +957,9 @@ static int prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba, ...@@ -964,11 +957,9 @@ static int prep_prd_sge_v1_hw(struct hisi_hba *hisi_hba,
hdr->prd_table_addr = cpu_to_le64(hisi_sas_sge_addr_dma(slot)); hdr->prd_table_addr = cpu_to_le64(hisi_sas_sge_addr_dma(slot));
hdr->sg_len = cpu_to_le32(n_elem << CMD_HDR_DATA_SGL_LEN_OFF); hdr->sg_len = cpu_to_le32(n_elem << CMD_HDR_DATA_SGL_LEN_OFF);
return 0;
} }
static int prep_smp_v1_hw(struct hisi_hba *hisi_hba, static void prep_smp_v1_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
...@@ -1004,11 +995,9 @@ static int prep_smp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1004,11 +995,9 @@ static int prep_smp_v1_hw(struct hisi_hba *hisi_hba,
hdr->cmd_table_addr = cpu_to_le64(req_dma_addr); hdr->cmd_table_addr = cpu_to_le64(req_dma_addr);
hdr->sts_buffer_addr = cpu_to_le64(hisi_sas_status_buf_addr_dma(slot)); hdr->sts_buffer_addr = cpu_to_le64(hisi_sas_status_buf_addr_dma(slot));
return 0;
} }
static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba, static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot, int is_tmf,
struct hisi_sas_tmf_task *tmf) struct hisi_sas_tmf_task *tmf)
{ {
...@@ -1019,7 +1008,7 @@ static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1019,7 +1008,7 @@ static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_port *port = slot->port; struct hisi_sas_port *port = slot->port;
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;
int has_data = 0, rc, priority = is_tmf; int has_data = 0, priority = is_tmf;
u8 *buf_cmd, fburst = 0; u8 *buf_cmd, fburst = 0;
u32 dw1, dw2; u32 dw1, dw2;
...@@ -1068,12 +1057,9 @@ static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1068,12 +1057,9 @@ static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
hdr->transfer_tags = cpu_to_le32(slot->idx << CMD_HDR_IPTT_OFF); hdr->transfer_tags = cpu_to_le32(slot->idx << CMD_HDR_IPTT_OFF);
if (has_data) { if (has_data)
rc = prep_prd_sge_v1_hw(hisi_hba, slot, hdr, task->scatter, prep_prd_sge_v1_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem); slot->n_elem);
if (rc)
return rc;
}
hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len); hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len);
hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot)); hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot));
...@@ -1107,8 +1093,6 @@ static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1107,8 +1093,6 @@ static int prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
break; break;
} }
} }
return 0;
} }
/* by default, task resp is complete */ /* by default, task resp is complete */
......
...@@ -1682,23 +1682,16 @@ static void start_delivery_v2_hw(struct hisi_sas_dq *dq) ...@@ -1682,23 +1682,16 @@ static void start_delivery_v2_hw(struct hisi_sas_dq *dq)
dq->wr_point); dq->wr_point);
} }
static int prep_prd_sge_v2_hw(struct hisi_hba *hisi_hba, static void prep_prd_sge_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
struct hisi_sas_cmd_hdr *hdr, struct hisi_sas_cmd_hdr *hdr,
struct scatterlist *scatter, struct scatterlist *scatter,
int n_elem) int n_elem)
{ {
struct hisi_sas_sge_page *sge_page = hisi_sas_sge_addr_mem(slot); struct hisi_sas_sge_page *sge_page = hisi_sas_sge_addr_mem(slot);
struct device *dev = hisi_hba->dev;
struct scatterlist *sg; struct scatterlist *sg;
int i; int i;
if (n_elem > HISI_SAS_SGE_PAGE_CNT) {
dev_err(dev, "prd err: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT",
n_elem);
return -EINVAL;
}
for_each_sg(scatter, sg, n_elem, i) { for_each_sg(scatter, sg, n_elem, i) {
struct hisi_sas_sge *entry = &sge_page->sge[i]; struct hisi_sas_sge *entry = &sge_page->sge[i];
...@@ -1711,11 +1704,9 @@ static int prep_prd_sge_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1711,11 +1704,9 @@ static int prep_prd_sge_v2_hw(struct hisi_hba *hisi_hba,
hdr->prd_table_addr = cpu_to_le64(hisi_sas_sge_addr_dma(slot)); hdr->prd_table_addr = cpu_to_le64(hisi_sas_sge_addr_dma(slot));
hdr->sg_len = cpu_to_le32(n_elem << CMD_HDR_DATA_SGL_LEN_OFF); hdr->sg_len = cpu_to_le32(n_elem << CMD_HDR_DATA_SGL_LEN_OFF);
return 0;
} }
static int prep_smp_v2_hw(struct hisi_hba *hisi_hba, static void prep_smp_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
...@@ -1752,11 +1743,9 @@ static int prep_smp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1752,11 +1743,9 @@ static int prep_smp_v2_hw(struct hisi_hba *hisi_hba,
hdr->cmd_table_addr = cpu_to_le64(req_dma_addr); hdr->cmd_table_addr = cpu_to_le64(req_dma_addr);
hdr->sts_buffer_addr = cpu_to_le64(hisi_sas_status_buf_addr_dma(slot)); hdr->sts_buffer_addr = cpu_to_le64(hisi_sas_status_buf_addr_dma(slot));
return 0;
} }
static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot, int is_tmf,
struct hisi_sas_tmf_task *tmf) struct hisi_sas_tmf_task *tmf)
{ {
...@@ -1767,7 +1756,7 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1767,7 +1756,7 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_port *port = slot->port; struct hisi_sas_port *port = slot->port;
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;
int has_data = 0, rc, priority = is_tmf; int has_data = 0, priority = is_tmf;
u8 *buf_cmd; u8 *buf_cmd;
u32 dw1 = 0, dw2 = 0; u32 dw1 = 0, dw2 = 0;
...@@ -1809,12 +1798,9 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1809,12 +1798,9 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
hdr->transfer_tags = cpu_to_le32(slot->idx); hdr->transfer_tags = cpu_to_le32(slot->idx);
if (has_data) { if (has_data)
rc = prep_prd_sge_v2_hw(hisi_hba, slot, hdr, task->scatter, prep_prd_sge_v2_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem); slot->n_elem);
if (rc)
return rc;
}
hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len); hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len);
hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot)); hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot));
...@@ -1843,8 +1829,6 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1843,8 +1829,6 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
break; break;
} }
} }
return 0;
} }
#define TRANS_TX_ERR 0 #define TRANS_TX_ERR 0
...@@ -2519,7 +2503,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot) ...@@ -2519,7 +2503,7 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot)
return sts; return sts;
} }
static int prep_ata_v2_hw(struct hisi_hba *hisi_hba, static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
...@@ -2530,7 +2514,7 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba, ...@@ -2530,7 +2514,7 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba,
struct asd_sas_port *sas_port = device->port; struct asd_sas_port *sas_port = device->port;
struct hisi_sas_port *port = to_hisi_sas_port(sas_port); struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
u8 *buf_cmd; u8 *buf_cmd;
int has_data = 0, rc = 0, hdr_tag = 0; int has_data = 0, hdr_tag = 0;
u32 dw1 = 0, dw2 = 0; u32 dw1 = 0, dw2 = 0;
/* create header */ /* create header */
...@@ -2578,12 +2562,9 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba, ...@@ -2578,12 +2562,9 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba,
/* dw3 */ /* dw3 */
hdr->transfer_tags = cpu_to_le32(slot->idx); hdr->transfer_tags = cpu_to_le32(slot->idx);
if (has_data) { if (has_data)
rc = prep_prd_sge_v2_hw(hisi_hba, slot, hdr, task->scatter, prep_prd_sge_v2_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem); slot->n_elem);
if (rc)
return rc;
}
hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len); hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len);
hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot)); hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot));
...@@ -2595,8 +2576,6 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba, ...@@ -2595,8 +2576,6 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba,
task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
/* fill in command FIS */ /* fill in command FIS */
memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis));
return 0;
} }
static void hisi_sas_internal_abort_quirk_timeout(struct timer_list *t) static void hisi_sas_internal_abort_quirk_timeout(struct timer_list *t)
...@@ -2633,7 +2612,7 @@ static void hisi_sas_internal_abort_quirk_timeout(struct timer_list *t) ...@@ -2633,7 +2612,7 @@ static void hisi_sas_internal_abort_quirk_timeout(struct timer_list *t)
} }
} }
static int prep_abort_v2_hw(struct hisi_hba *hisi_hba, static void prep_abort_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
int device_id, int abort_flag, int tag_to_abort) int device_id, int abort_flag, int tag_to_abort)
{ {
...@@ -2661,8 +2640,6 @@ static int prep_abort_v2_hw(struct hisi_hba *hisi_hba, ...@@ -2661,8 +2640,6 @@ static int prep_abort_v2_hw(struct hisi_hba *hisi_hba,
/* dw7 */ /* dw7 */
hdr->dw7 = cpu_to_le32(tag_to_abort << CMD_HDR_ABORT_IPTT_OFF); hdr->dw7 = cpu_to_le32(tag_to_abort << CMD_HDR_ABORT_IPTT_OFF);
hdr->transfer_tags = cpu_to_le32(slot->idx); hdr->transfer_tags = cpu_to_le32(slot->idx);
return 0;
} }
static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba) static int phy_up_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
......
...@@ -859,23 +859,16 @@ static void start_delivery_v3_hw(struct hisi_sas_dq *dq) ...@@ -859,23 +859,16 @@ static void start_delivery_v3_hw(struct hisi_sas_dq *dq)
dq->wr_point); dq->wr_point);
} }
static int prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba, static void prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
struct hisi_sas_cmd_hdr *hdr, struct hisi_sas_cmd_hdr *hdr,
struct scatterlist *scatter, struct scatterlist *scatter,
int n_elem) int n_elem)
{ {
struct hisi_sas_sge_page *sge_page = hisi_sas_sge_addr_mem(slot); struct hisi_sas_sge_page *sge_page = hisi_sas_sge_addr_mem(slot);
struct device *dev = hisi_hba->dev;
struct scatterlist *sg; struct scatterlist *sg;
int i; int i;
if (n_elem > HISI_SAS_SGE_PAGE_CNT) {
dev_err(dev, "prd err: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT",
n_elem);
return -EINVAL;
}
for_each_sg(scatter, sg, n_elem, i) { for_each_sg(scatter, sg, n_elem, i) {
struct hisi_sas_sge *entry = &sge_page->sge[i]; struct hisi_sas_sge *entry = &sge_page->sge[i];
...@@ -888,11 +881,9 @@ static int prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba, ...@@ -888,11 +881,9 @@ static int prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba,
hdr->prd_table_addr = cpu_to_le64(hisi_sas_sge_addr_dma(slot)); hdr->prd_table_addr = cpu_to_le64(hisi_sas_sge_addr_dma(slot));
hdr->sg_len = cpu_to_le32(n_elem << CMD_HDR_DATA_SGL_LEN_OFF); hdr->sg_len = cpu_to_le32(n_elem << CMD_HDR_DATA_SGL_LEN_OFF);
return 0;
} }
static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba, static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot, int is_tmf,
struct hisi_sas_tmf_task *tmf) struct hisi_sas_tmf_task *tmf)
{ {
...@@ -903,7 +894,7 @@ static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -903,7 +894,7 @@ static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_port *port = slot->port; struct hisi_sas_port *port = slot->port;
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;
int has_data = 0, rc, priority = is_tmf; int has_data = 0, priority = is_tmf;
u8 *buf_cmd; u8 *buf_cmd;
u32 dw1 = 0, dw2 = 0; u32 dw1 = 0, dw2 = 0;
...@@ -944,12 +935,9 @@ static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -944,12 +935,9 @@ static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
hdr->dw2 = cpu_to_le32(dw2); hdr->dw2 = cpu_to_le32(dw2);
hdr->transfer_tags = cpu_to_le32(slot->idx); hdr->transfer_tags = cpu_to_le32(slot->idx);
if (has_data) { if (has_data)
rc = prep_prd_sge_v3_hw(hisi_hba, slot, hdr, task->scatter, prep_prd_sge_v3_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem); slot->n_elem);
if (rc)
return rc;
}
hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len); hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len);
hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot)); hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot));
...@@ -976,11 +964,9 @@ static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -976,11 +964,9 @@ static int prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
break; break;
} }
} }
return 0;
} }
static int prep_smp_v3_hw(struct hisi_hba *hisi_hba, static void prep_smp_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
...@@ -1018,10 +1004,9 @@ static int prep_smp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -1018,10 +1004,9 @@ static int prep_smp_v3_hw(struct hisi_hba *hisi_hba,
hdr->cmd_table_addr = cpu_to_le64(req_dma_addr); hdr->cmd_table_addr = cpu_to_le64(req_dma_addr);
hdr->sts_buffer_addr = cpu_to_le64(hisi_sas_status_buf_addr_dma(slot)); hdr->sts_buffer_addr = cpu_to_le64(hisi_sas_status_buf_addr_dma(slot));
return 0;
} }
static int prep_ata_v3_hw(struct hisi_hba *hisi_hba, static void prep_ata_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot) struct hisi_sas_slot *slot)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
...@@ -1032,7 +1017,7 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba, ...@@ -1032,7 +1017,7 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba,
struct asd_sas_port *sas_port = device->port; struct asd_sas_port *sas_port = device->port;
struct hisi_sas_port *port = to_hisi_sas_port(sas_port); struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
u8 *buf_cmd; u8 *buf_cmd;
int has_data = 0, rc = 0, hdr_tag = 0; int has_data = 0, hdr_tag = 0;
u32 dw1 = 0, dw2 = 0; u32 dw1 = 0, dw2 = 0;
hdr->dw0 = cpu_to_le32(port->id << CMD_HDR_PORT_OFF); hdr->dw0 = cpu_to_le32(port->id << CMD_HDR_PORT_OFF);
...@@ -1081,12 +1066,9 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba, ...@@ -1081,12 +1066,9 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba,
/* dw3 */ /* dw3 */
hdr->transfer_tags = cpu_to_le32(slot->idx); hdr->transfer_tags = cpu_to_le32(slot->idx);
if (has_data) { if (has_data)
rc = prep_prd_sge_v3_hw(hisi_hba, slot, hdr, task->scatter, prep_prd_sge_v3_hw(hisi_hba, slot, hdr, task->scatter,
slot->n_elem); slot->n_elem);
if (rc)
return rc;
}
hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len); hdr->data_transfer_len = cpu_to_le32(task->total_xfer_len);
hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot)); hdr->cmd_table_addr = cpu_to_le64(hisi_sas_cmd_hdr_addr_dma(slot));
...@@ -1098,11 +1080,9 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba, ...@@ -1098,11 +1080,9 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba,
task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
/* fill in command FIS */ /* fill in command FIS */
memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis));
return 0;
} }
static int prep_abort_v3_hw(struct hisi_hba *hisi_hba, static void prep_abort_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, struct hisi_sas_slot *slot,
int device_id, int abort_flag, int tag_to_abort) int device_id, int abort_flag, int tag_to_abort)
{ {
...@@ -1127,7 +1107,6 @@ static int prep_abort_v3_hw(struct hisi_hba *hisi_hba, ...@@ -1127,7 +1107,6 @@ static int prep_abort_v3_hw(struct hisi_hba *hisi_hba,
hdr->dw7 = cpu_to_le32(tag_to_abort << CMD_HDR_ABORT_IPTT_OFF); hdr->dw7 = cpu_to_le32(tag_to_abort << CMD_HDR_ABORT_IPTT_OFF);
hdr->transfer_tags = cpu_to_le32(slot->idx); hdr->transfer_tags = cpu_to_le32(slot->idx);
return 0;
} }
static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
......
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