From: Hu Chunzhi <huchunzhi(a)huawei.com>
driver inclusion
category: cleanup
bugzilla: NA
CVE: NA
----------------------------------
This patch modifies the code based on the review comments.
Reviewed-by: Zhao Weibo <zhaoweibo3(a)huawei.com>
Reviewed-by: Yang Shunfeng <yangshunfeng2(a)huawei.com>
Signed-off-by: Hu Chunzhi <huchunzhi(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_alloc.c | 3 +--
.../infiniband/hw/hns/hns_roce_hw_sysfs_v2.c | 1 -
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 22 +++++++++++--------
drivers/infiniband/hw/hns/hns_roce_mr.c | 5 -----
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
index ec8b30b24a3c..89547c8bb82d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
+++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
@@ -63,6 +63,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)
return ret;
}
EXPORT_SYMBOL_GPL(hns_roce_bitmap_alloc);
+
void hns_roce_bitmap_free(struct hns_roce_bitmap *bitmap, unsigned long obj,
int rr)
{
@@ -214,7 +215,6 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
buf->page_shift = page_shift;
buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list),
GFP_KERNEL);
-
if (!buf->page_list)
return -ENOMEM;
@@ -222,7 +222,6 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
buf->page_list[i].buf = dma_zalloc_coherent(dev,
page_size, &t,
GFP_KERNEL);
-
if (!buf->page_list[i].buf)
goto err_free;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c
index dfbdfb2192f1..a780a0e10386 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_sysfs_v2.c
@@ -612,7 +612,6 @@ int hns_roce_v2_modify_eq(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq,
roce_set_field(eqc_mask->byte_12,
HNS_ROCE_EQC_MAX_CNT_M,
HNS_ROCE_EQC_MAX_CNT_S, 0);
-
} else if (type == HNS_ROCE_EQ_PERIOD_MASK) {
roce_set_field(eqc->byte_12,
HNS_ROCE_EQC_PERIOD_M,
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index b77fef65ab1c..e7efd37b7734 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1366,23 +1366,26 @@ static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval,
}
}
-static void hns_roce_query_func_info(struct hns_roce_dev *hr_dev)
+static int hns_roce_query_func_info(struct hns_roce_dev *hr_dev)
{
struct hns_roce_cmq_desc desc;
struct hns_roce_pf_func_info *resp;
- int ret;
+ int ret = 0;
hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_QUERY_FUNC_INFO,
true);
ret = hns_roce_cmq_send(hr_dev, &desc, 1);
if (ret) {
- dev_err(hr_dev->dev, "Query vf count failed(%d).\n", ret);
- return;
+ dev_err(hr_dev->dev, "Query function info failed(%d).\n",
+ ret);
+ return ret;
}
resp = (struct hns_roce_pf_func_info *)desc.data;
hr_dev->func_num = le32_to_cpu(resp->pf_own_func_num);
hr_dev->mac_id = le32_to_cpu(resp->pf_own_mac_id);
+
+ return ret;
}
static void hns_roce_clear_func(struct hns_roce_dev *hr_dev, int vf_id)
@@ -1438,12 +1441,11 @@ static void hns_roce_clear_func(struct hns_roce_dev *hr_dev, int vf_id)
static void hns_roce_function_clear(struct hns_roce_dev *hr_dev)
{
- int i;
int vf_num = 0;/* should be (hr_dev->func_num-1) when enable ROCE VF */
/* Clear vf first, then clear pf */
- for (i = vf_num; i >= 0; i--)
- hns_roce_clear_func(hr_dev, i);
+ for (; vf_num >= 0; vf_num--)
+ hns_roce_clear_func(hr_dev, vf_num);
}
static void hns_roce_clear_extdb_list_info(struct hns_roce_dev *hr_dev)
@@ -2182,7 +2184,9 @@ static int hns_roce_v2_profile(struct hns_roce_dev *hr_dev)
return ret;
}
- hns_roce_query_func_info(hr_dev);
+ ret = hns_roce_query_func_info(hr_dev);
+ if (ret)
+ return ret;
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08_B) {
ret = hns_roce_query_pf_timer_resource(hr_dev);
@@ -5488,7 +5492,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,
kfree(hr_qp->sq.wrid);
kfree(hr_qp->rq.wrid);
hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf);
- if (hr_qp->rq.wqe_cnt)
+ if (hr_qp->rq.wqe_cnt && (hr_qp->rdb_en == 1))
hns_roce_free_db(hr_dev, &hr_qp->rdb);
}
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 0802454b2b96..ce5c0544fc1b 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -552,7 +552,6 @@ static int hns_roce_mhop_alloc(struct hns_roce_dev *hr_dev, int npages,
goto err_kcalloc_l2_dma;
}
-
mr->pbl_size = npages;
mr->pbl_ba = mr->pbl_l0_dma_addr;
mr->pbl_hop_num = hr_dev->caps.pbl_hop_num;
@@ -1289,7 +1288,6 @@ static int rereg_mr_trans(struct ib_mr *ibmr, int flags,
if (ret)
goto release_umem;
-
ret = hns_roce_ib_umem_write_mr(hr_dev, mr, mr->umem);
if (ret) {
if (mr->size != ~0ULL) {
@@ -1307,14 +1305,11 @@ static int rereg_mr_trans(struct ib_mr *ibmr, int flags,
}
return 0;
-
release_umem:
ib_umem_release(mr->umem);
return ret;
-
}
-
int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
u64 virt_addr, int mr_access_flags, struct ib_pd *pd,
struct ib_udata *udata)
--
2.25.1