Skip to content

Commit 563aeb2

Browse files
larrchjgunthorpe
authored andcommitted
RDMA/hns: Remove redundant operations on CMDQ
CMDQ works serially, after each successful transmission, the head and tail pointers will be equal, so there is no need to check whether the queue is full. At the same time, since the descriptor of each transmission is new, there is no need to perform a cleanup operation. Then, the field named next_to_clean in structure hns_roce_v2_cmq_ring is redundant. Fixes: a04ff73 ("RDMA/hns: Add command queue support for hip08 RoCE driver") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lang Cheng <[email protected]> Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 8f86e2e commit 563aeb2

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,15 +1130,6 @@ static int hns_roce_v2_rst_process_cmd(struct hns_roce_dev *hr_dev)
11301130
return 0;
11311131
}
11321132

1133-
static int hns_roce_cmq_space(struct hns_roce_v2_cmq_ring *ring)
1134-
{
1135-
int ntu = ring->next_to_use;
1136-
int ntc = ring->next_to_clean;
1137-
int used = (ntu - ntc + ring->desc_num) % ring->desc_num;
1138-
1139-
return ring->desc_num - used - 1;
1140-
}
1141-
11421133
static int hns_roce_alloc_cmq_desc(struct hns_roce_dev *hr_dev,
11431134
struct hns_roce_v2_cmq_ring *ring)
11441135
{
@@ -1178,7 +1169,6 @@ static int hns_roce_init_cmq_ring(struct hns_roce_dev *hr_dev, bool ring_type)
11781169
&priv->cmq.csq : &priv->cmq.crq;
11791170

11801171
ring->flag = ring_type;
1181-
ring->next_to_clean = 0;
11821172
ring->next_to_use = 0;
11831173

11841174
return hns_roce_alloc_cmq_desc(hr_dev, ring);
@@ -1284,30 +1274,6 @@ static int hns_roce_cmq_csq_done(struct hns_roce_dev *hr_dev)
12841274
return head == priv->cmq.csq.next_to_use;
12851275
}
12861276

1287-
static int hns_roce_cmq_csq_clean(struct hns_roce_dev *hr_dev)
1288-
{
1289-
struct hns_roce_v2_priv *priv = hr_dev->priv;
1290-
struct hns_roce_v2_cmq_ring *csq = &priv->cmq.csq;
1291-
struct hns_roce_cmq_desc *desc;
1292-
u16 ntc = csq->next_to_clean;
1293-
u32 head;
1294-
int clean = 0;
1295-
1296-
desc = &csq->desc[ntc];
1297-
head = roce_read(hr_dev, ROCEE_TX_CMQ_HEAD_REG);
1298-
while (head != ntc) {
1299-
memset(desc, 0, sizeof(*desc));
1300-
ntc++;
1301-
if (ntc == csq->desc_num)
1302-
ntc = 0;
1303-
desc = &csq->desc[ntc];
1304-
clean++;
1305-
}
1306-
csq->next_to_clean = ntc;
1307-
1308-
return clean;
1309-
}
1310-
13111277
static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
13121278
struct hns_roce_cmq_desc *desc, int num)
13131279
{
@@ -1322,15 +1288,6 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
13221288

13231289
spin_lock_bh(&csq->lock);
13241290

1325-
if (num > hns_roce_cmq_space(csq)) {
1326-
spin_unlock_bh(&csq->lock);
1327-
return -EBUSY;
1328-
}
1329-
1330-
/*
1331-
* Record the location of desc in the cmq for this time
1332-
* which will be use for hardware to write back
1333-
*/
13341291
ntc = csq->next_to_use;
13351292

13361293
while (handle < num) {
@@ -1377,15 +1334,14 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
13771334
ntc = 0;
13781335
}
13791336
} else {
1337+
/* FW/HW reset or incorrect number of desc */
1338+
ntc = roce_read(hr_dev, ROCEE_TX_CMQ_HEAD_REG);
1339+
dev_warn(hr_dev->dev, "CMDQ move head from %d to %d\n",
1340+
csq->next_to_use, ntc);
1341+
csq->next_to_use = ntc;
13801342
ret = -EAGAIN;
13811343
}
13821344

1383-
/* clean the command send queue */
1384-
handle = hns_roce_cmq_csq_clean(hr_dev);
1385-
if (handle != num)
1386-
dev_warn(hr_dev->dev, "Cleaned %d, need to clean %d\n",
1387-
handle, num);
1388-
13891345
spin_unlock_bh(&csq->lock);
13901346

13911347
return ret;

drivers/infiniband/hw/hns/hns_roce_hw_v2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,6 @@ struct hns_roce_v2_cmq_ring {
18811881
u16 buf_size;
18821882
u16 desc_num;
18831883
int next_to_use;
1884-
int next_to_clean;
18851884
u8 flag;
18861885
spinlock_t lock; /* command queue lock */
18871886
};

0 commit comments

Comments
 (0)