RDMA/hns: Modify prints for mailbox and command queue
authorWenpeng Liang <liangwenpeng@huawei.com>
Thu, 1 Apr 2021 07:32:21 +0000 (15:32 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 8 Apr 2021 19:05:04 +0000 (16:05 -0300)
Use ratelimited print in mbox and cmq. And print mailbox operation if
mailbox fails because it's useful information for the user.

Link: https://lore.kernel.org/r/1617262341-37571-4-git-send-email-liweihang@huawei.com
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hns/hns_roce_cmd.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c

index e524a14..8f68cc3 100644 (file)
@@ -54,14 +54,15 @@ static int __hns_roce_cmd_mbox_poll(struct hns_roce_dev *hr_dev, u64 in_param,
                                    u8 op_modifier, u16 op,
                                    unsigned int timeout)
 {
-       struct device *dev = hr_dev->dev;
        int ret;
 
        ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param,
                                        in_modifier, op_modifier, op,
                                        CMD_POLL_TOKEN, 0);
        if (ret) {
-               dev_err(dev, "[cmd_poll]hns_roce_cmd_mbox_post_hw failed\n");
+               dev_err_ratelimited(hr_dev->dev,
+                                   "failed to post mailbox %x in poll mode, ret = %d.\n",
+                                   op, ret);
                return ret;
        }
 
@@ -127,19 +128,25 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
        ret = hns_roce_cmd_mbox_post_hw(hr_dev, in_param, out_param,
                                        in_modifier, op_modifier, op,
                                        context->token, 1);
-       if (ret)
+       if (ret) {
+               dev_err_ratelimited(dev,
+                                   "failed to post mailbox %x in event mode, ret = %d.\n",
+                                   op, ret);
                goto out;
+       }
 
        if (!wait_for_completion_timeout(&context->done,
                                         msecs_to_jiffies(timeout))) {
-               dev_err(dev, "[cmd] token %x timeout, drop.\n", context->token);
+               dev_err_ratelimited(dev, "[cmd] token %x mailbox %x timeout.\n",
+                                   context->token, op);
                ret = -EBUSY;
                goto out;
        }
 
        ret = context->result;
        if (ret)
-               dev_err(dev, "[cmd] token %x error %d\n", context->token, ret);
+               dev_err_ratelimited(dev, "[cmd] token %x mailbox %x error %d\n",
+                                   context->token, op, ret);
 
 out:
        context->busy = 0;
@@ -182,12 +189,10 @@ int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,
 
 int hns_roce_cmd_init(struct hns_roce_dev *hr_dev)
 {
-       struct device *dev = hr_dev->dev;
-
        sema_init(&hr_dev->cmd.poll_sem, 1);
        hr_dev->cmd.use_events = 0;
        hr_dev->cmd.max_cmds = CMD_MAX_NUM;
-       hr_dev->cmd.pool = dma_pool_create("hns_roce_cmd", dev,
+       hr_dev->cmd.pool = dma_pool_create("hns_roce_cmd", hr_dev->dev,
                                           HNS_ROCE_MAILBOX_SIZE,
                                           HNS_ROCE_MAILBOX_SIZE, 0);
        if (!hr_dev->cmd.pool)
index 6eb8fbe..65f7a70 100644 (file)
@@ -1209,6 +1209,9 @@ static int hns_roce_alloc_cmq_desc(struct hns_roce_dev *hr_dev,
                ring->desc_dma_addr = 0;
                kfree(ring->desc);
                ring->desc = NULL;
+
+               dev_err_ratelimited(hr_dev->dev,
+                                   "failed to map cmq desc addr.\n");
                return -ENOMEM;
        }
 
@@ -1283,14 +1286,16 @@ static int hns_roce_v2_cmq_init(struct hns_roce_dev *hr_dev)
        /* Init CSQ */
        ret = hns_roce_init_cmq_ring(hr_dev, TYPE_CSQ);
        if (ret) {
-               dev_err(hr_dev->dev, "Init CSQ error, ret = %d.\n", ret);
+               dev_err_ratelimited(hr_dev->dev,
+                                   "failed to init CSQ, ret = %d.\n", ret);
                return ret;
        }
 
        /* Init CRQ */
        ret = hns_roce_init_cmq_ring(hr_dev, TYPE_CRQ);
        if (ret) {
-               dev_err(hr_dev->dev, "Init CRQ error, ret = %d.\n", ret);
+               dev_err_ratelimited(hr_dev->dev,
+                                   "failed to init CRQ, ret = %d.\n", ret);
                goto err_crq;
        }