]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/hns: Fix mbx timing out before CMD execution is completed
authorChengchang Tang <tangchengchang@huawei.com>
Wed, 10 Jul 2024 13:37:05 +0000 (21:37 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 11 Jul 2024 10:25:12 +0000 (13:25 +0300)
When a large number of tasks are issued, the speed of HW processing
mbx will slow down. The standard for judging mbx timeout in the current
firmware is 30ms, and the current timeout standard for the driver is also
30ms.

Considering that firmware scheduling in multi-function scenarios takes a
certain amount of time, this will cause the driver to time out too early
and report a failure before mbx execution times out.

This patch introduces a new mechanism that can set different timeouts for
different cmds and extends the timeout of mbx to 35ms.

Fixes: a04ff739f2a9 ("RDMA/hns: Add command queue support for hip08 RoCE driver")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://lore.kernel.org/r/20240710133705.896445-9-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.h

index aecd137c1e6052a07ebf7f9b640afded6a396548..621b057fb9daa61fd36507a8f682bc691571ee25 100644 (file)
@@ -1275,12 +1275,38 @@ static int hns_roce_cmd_err_convert_errno(u16 desc_ret)
        return -EIO;
 }
 
+static u32 hns_roce_cmdq_tx_timeout(u16 opcode, u32 tx_timeout)
+{
+       static const struct hns_roce_cmdq_tx_timeout_map cmdq_tx_timeout[] = {
+               {HNS_ROCE_OPC_POST_MB, HNS_ROCE_OPC_POST_MB_TIMEOUT},
+       };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(cmdq_tx_timeout); i++)
+               if (cmdq_tx_timeout[i].opcode == opcode)
+                       return cmdq_tx_timeout[i].tx_timeout;
+
+       return tx_timeout;
+}
+
+static void hns_roce_wait_csq_done(struct hns_roce_dev *hr_dev, u16 opcode)
+{
+       struct hns_roce_v2_priv *priv = hr_dev->priv;
+       u32 tx_timeout = hns_roce_cmdq_tx_timeout(opcode, priv->cmq.tx_timeout);
+       u32 timeout = 0;
+
+       do {
+               if (hns_roce_cmq_csq_done(hr_dev))
+                       break;
+               udelay(1);
+       } while (++timeout < tx_timeout);
+}
+
 static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
                               struct hns_roce_cmq_desc *desc, int num)
 {
        struct hns_roce_v2_priv *priv = hr_dev->priv;
        struct hns_roce_v2_cmq_ring *csq = &priv->cmq.csq;
-       u32 timeout = 0;
        u16 desc_ret;
        u32 tail;
        int ret;
@@ -1301,12 +1327,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
 
        atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_CMDS_CNT]);
 
-       do {
-               if (hns_roce_cmq_csq_done(hr_dev))
-                       break;
-               udelay(1);
-       } while (++timeout < priv->cmq.tx_timeout);
-
+       hns_roce_wait_csq_done(hr_dev, le16_to_cpu(desc->opcode));
        if (hns_roce_cmq_csq_done(hr_dev)) {
                ret = 0;
                for (i = 0; i < num; i++) {
index def1d15a03c7ea159bcf835b8cc0043b58d1c1c9..c65f68a14a2608198de8caca12c62f805385bf7d 100644 (file)
@@ -224,6 +224,12 @@ enum hns_roce_opcode_type {
        HNS_SWITCH_PARAMETER_CFG                        = 0x1033,
 };
 
+#define HNS_ROCE_OPC_POST_MB_TIMEOUT 35000
+struct hns_roce_cmdq_tx_timeout_map {
+       u16 opcode;
+       u32 tx_timeout;
+};
+
 enum {
        TYPE_CRQ,
        TYPE_CSQ,