Commit 5e9914c0 authored by Lang Cheng's avatar Lang Cheng Committed by Jason Gunthorpe

RDMA/hns: Refactor process of posting CMDQ

Simplify __hns_roce_cmq_send() then remove the redundant variables.

Link: https://lore.kernel.org/r/1612688143-28226-6-git-send-email-liweihang@huawei.comSigned-off-by: default avatarLang Cheng <chenglang@huawei.com>
Signed-off-by: default avatarWeihang Li <liweihang@huawei.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 292b3352
...@@ -1279,32 +1279,26 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev, ...@@ -1279,32 +1279,26 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
{ {
struct hns_roce_v2_priv *priv = hr_dev->priv; struct hns_roce_v2_priv *priv = hr_dev->priv;
struct hns_roce_v2_cmq_ring *csq = &priv->cmq.csq; struct hns_roce_v2_cmq_ring *csq = &priv->cmq.csq;
struct hns_roce_cmq_desc *desc_to_use;
u32 timeout = 0; u32 timeout = 0;
int handle = 0;
u16 desc_ret; u16 desc_ret;
u32 tail; u32 tail;
int ret; int ret;
int i;
spin_lock_bh(&csq->lock); spin_lock_bh(&csq->lock);
tail = csq->head; tail = csq->head;
while (handle < num) { for (i = 0; i < num; i++) {
desc_to_use = &csq->desc[csq->head]; csq->desc[csq->head++] = desc[i];
*desc_to_use = desc[handle];
dev_dbg(hr_dev->dev, "set cmq desc:\n");
csq->head++;
if (csq->head == csq->desc_num) if (csq->head == csq->desc_num)
csq->head = 0; csq->head = 0;
handle++;
} }
/* Write to hardware */ /* Write to hardware */
roce_write(hr_dev, ROCEE_TX_CMQ_HEAD_REG, csq->head); roce_write(hr_dev, ROCEE_TX_CMQ_HEAD_REG, csq->head);
/* /* If the command is sync, wait for the firmware to write back,
* If the command is sync, wait for the firmware to write back,
* if multi descriptors to be sent, use the first one to check * if multi descriptors to be sent, use the first one to check
*/ */
if (le16_to_cpu(desc->flag) & HNS_ROCE_CMD_FLAG_NO_INTR) { if (le16_to_cpu(desc->flag) & HNS_ROCE_CMD_FLAG_NO_INTR) {
...@@ -1312,26 +1306,24 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev, ...@@ -1312,26 +1306,24 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
if (hns_roce_cmq_csq_done(hr_dev)) if (hns_roce_cmq_csq_done(hr_dev))
break; break;
udelay(1); udelay(1);
timeout++; } while (++timeout < priv->cmq.tx_timeout);
} while (timeout < priv->cmq.tx_timeout);
} }
if (hns_roce_cmq_csq_done(hr_dev)) { if (hns_roce_cmq_csq_done(hr_dev)) {
handle = 0; for (ret = 0, i = 0; i < num; i++) {
ret = 0; /* check the result of hardware write back */
while (handle < num) { desc[i] = csq->desc[tail++];
/* get the result of hardware write back */
desc_to_use = &csq->desc[tail];
desc[handle] = *desc_to_use;
dev_dbg(hr_dev->dev, "Get cmq desc:\n");
desc_ret = le16_to_cpu(desc[handle].retval);
if (unlikely(desc_ret != CMD_EXEC_SUCCESS))
ret = -EIO;
tail++;
handle++;
if (tail == csq->desc_num) if (tail == csq->desc_num)
tail = 0; tail = 0;
desc_ret = le16_to_cpu(desc[i].retval);
if (likely(desc_ret == CMD_EXEC_SUCCESS))
continue;
dev_err_ratelimited(hr_dev->dev,
"Cmdq IO error, opcode = %x, return = %x\n",
desc->opcode, desc_ret);
ret = -EIO;
} }
} else { } else {
/* FW/HW reset or incorrect number of desc */ /* FW/HW reset or incorrect number of desc */
......
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