提交 350266f6 编写于 作者: H Hu Chunzhi 提交者: Xie XiuQi

RDMA/hns: Fix device initialization bugs

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

This patch changes some code format and fix device initialization bugs.
Reviewed-by: NHuang Dongdong <hdd.huang@huawei.com>
Signed-off-by: NHu Chunzhi <huchunzhi@huawei.com>
Acked-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 af324d95
......@@ -365,8 +365,8 @@ static int rdfx_v2_ceqc_store(const char *p_buf, struct rdfx_info *rdfx)
return PTR_ERR(mailbox);
eq_context = kzalloc(sizeof(*eq_context), GFP_KERNEL);
if (!eq_context) {
//pr_info("alloc mailbox mem for ceqc failed\n");
if (ZERO_OR_NULL_PTR(eq_context)) {
pr_info("alloc mailbox mem for ceqc failed\n");
ret = -ENOMEM;
goto err_context;
}
......@@ -383,8 +383,7 @@ static int rdfx_v2_ceqc_store(const char *p_buf, struct rdfx_info *rdfx)
pr_info("************** CEQC INFO ***************\n");
eqc = (int *)eq_context;
for (i = 0; i < (sizeof(*eq_context) >> 2); i += 8) {
pr_info(
"CEQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
pr_info("CEQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
ceqn, *eqc, *(eqc + 1), *(eqc + 2),
*(eqc + 3), *(eqc + 4), *(eqc + 5),
*(eqc + 6), *(eqc + 7));
......@@ -427,8 +426,8 @@ static int rdfx_v2_aeqc_store(const char *p_buf, struct rdfx_info *rdfx)
return PTR_ERR(mailbox);
eq_context = kzalloc(sizeof(*eq_context), GFP_KERNEL);
if (!eq_context) {
//pr_info("alloc mailbox mem for ceqc failed\n");
if (ZERO_OR_NULL_PTR(eq_context)) {
pr_info("alloc mailbox mem for aeqc failed\n");
ret = -ENOMEM;
goto err_context;
}
......@@ -445,8 +444,7 @@ static int rdfx_v2_aeqc_store(const char *p_buf, struct rdfx_info *rdfx)
pr_info("************** AEQC INFO ***************\n");
eqc = (int *)eq_context;
for (i = 0; i < (sizeof(*eq_context) >> 2); i += 8) {
pr_info(
"AEQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
pr_info("AEQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
aeqn, *eqc, *(eqc + 1), *(eqc + 2),
*(eqc + 3), *(eqc + 4), *(eqc + 5),
*(eqc + 6), *(eqc + 7));
......@@ -511,8 +509,8 @@ static int rdfx_v2_qpc_store(const char *p_buf, struct rdfx_info *rdfx)
}
qp_context = kzalloc(sizeof(*qp_context), GFP_KERNEL);
if (!qp_context) {
//pr_info("alloc mailbox mem for qpc failed\n");
if (ZERO_OR_NULL_PTR(qp_context)) {
pr_info("alloc mailbox mem for qpc failed\n");
ret = -ENOMEM;
goto err_cmd;
}
......@@ -532,8 +530,7 @@ static int rdfx_v2_qpc_store(const char *p_buf, struct rdfx_info *rdfx)
pr_info("QPC(0x%x) BT1: 0x%llx\n", qpn, bt1_ba);
qpc = (int *)qp_context;
for (i = 0; i < (sizeof(*qp_context) >> 2); i += 8) {
pr_info(
"QPC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
pr_info("QPC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
qpn, *qpc, *(qpc + 1), *(qpc + 2),
*(qpc + 3), *(qpc + 4), *(qpc + 5),
*(qpc + 6), *(qpc + 7));
......@@ -598,8 +595,8 @@ static int rdfx_v2_cqc_store(const char *p_buf, struct rdfx_info *rdfx)
}
cq_context = kzalloc(sizeof(*cq_context), GFP_KERNEL);
if (!cq_context) {
//pr_info("alloc mailbox mem for cqc failed\n");
if (ZERO_OR_NULL_PTR(cq_context)) {
pr_info("alloc mailbox mem for cqc failed\n");
ret = -ENOMEM;
goto err_cmd;
}
......@@ -619,8 +616,7 @@ static int rdfx_v2_cqc_store(const char *p_buf, struct rdfx_info *rdfx)
pr_info("CQC(0x%x) BT1: 0x%llx\n", cqn, bt1_ba);
cqc = (int *)cq_context;
for (i = 0; i < (sizeof(*cq_context) >> 2); i += 8) {
pr_info(
"CQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
pr_info("CQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
cqn, *cqc, *(cqc + 1), *(cqc + 2),
*(cqc + 3), *(cqc + 4), *(cqc + 5),
*(cqc + 6), *(cqc + 7));
......@@ -685,8 +681,8 @@ static int rdfx_v2_srqc_store(const char *p_buf, struct rdfx_info *rdfx)
}
srq_context = kzalloc(sizeof(*srq_context), GFP_KERNEL);
if (!srq_context) {
//pr_info("alloc mailbox mem for srqc failed\n");
if (ZERO_OR_NULL_PTR(srq_context)) {
pr_info("alloc mailbox mem for srqc failed\n");
ret = -ENOMEM;
goto err_cmd;
}
......@@ -706,8 +702,7 @@ static int rdfx_v2_srqc_store(const char *p_buf, struct rdfx_info *rdfx)
pr_info("SRQC(0x%x) BT1: 0x%llx\n", srqn, bt1_ba);
srqc = (int *)srq_context;
for (i = 0; i < (sizeof(*srq_context) >> 2); i += 8) {
pr_info(
"SRQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
pr_info("SRQC(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
srqn, *srqc, *(srqc + 1), *(srqc + 2),
*(srqc + 3), *(srqc + 4), *(srqc + 5),
*(srqc + 6), *(srqc + 7));
......@@ -772,8 +767,8 @@ static int rdfx_v2_mpt_store(const char *p_buf, struct rdfx_info *rdfx)
}
mpt_ctx = kzalloc(sizeof(*mpt_ctx), GFP_KERNEL);
if (!mpt_ctx) {
//pr_info("alloc mailbox mem for cqc failed\n");
if (ZERO_OR_NULL_PTR(mpt_ctx)) {
pr_info("alloc mailbox mem for mpt failed\n");
ret = -ENOMEM;
goto err_cmd;
}
......@@ -793,8 +788,7 @@ static int rdfx_v2_mpt_store(const char *p_buf, struct rdfx_info *rdfx)
pr_info("MPT(0x%x) BT1: 0x%llx\n", key, bt1_ba);
mpt = (int *)mpt_ctx;
for (i = 0; i < (sizeof(*mpt_ctx) >> 2); i += 8) {
pr_info(
"MPT(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
pr_info("MPT(0x%x): %08x %08x %08x %08x %08x %08x %08x %08x\n",
key, *mpt, *(mpt + 1), *(mpt + 2),
*(mpt + 3), *(mpt + 4), *(mpt + 5),
*(mpt + 6), *(mpt + 7));
......
......@@ -11,7 +11,7 @@
unsigned int hr_fc_print;
module_param(hr_fc_print, uint, 0644);
MODULE_PARM_DESC(hr_fc_print, "enable func call prin");
MODULE_PARM_DESC(hr_fc_print, "enable function call print");
static struct rdfx_qp_info *rdfx_find_rdfx_qp(struct rdfx_info *rdfx,
unsigned long qpn);
......@@ -85,7 +85,7 @@ void alloc_rdfx_info(struct hns_roce_dev *hr_dev)
struct rdfx_info *rdfx;
rdfx = kzalloc(sizeof(*rdfx), GFP_KERNEL);
if (!rdfx)
if (ZERO_OR_NULL_PTR(rdfx))
return;
hr_dev->dfx_priv = rdfx;
......@@ -621,7 +621,7 @@ void rdfx_alloc_rdfx_ceq(struct hns_roce_dev *hr_dev, unsigned long ceqn,
if (eq_cmd == HNS_ROCE_CMD_CREATE_CEQC) {
rdfx_ceq = kzalloc(sizeof(struct rdfx_ceq_info), GFP_KERNEL);
if (!rdfx_ceq)
if (ZERO_OR_NULL_PTR(rdfx_ceq))
return;
rdfx_ceq->ceqn = ceqn;
......@@ -647,7 +647,7 @@ void rdfx_alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
cq_entries = hr_cq->cq_depth;
dfx_cq_buf = kzalloc(sizeof(struct hns_roce_buf), GFP_KERNEL);
if (!dfx_cq_buf)
if (ZERO_OR_NULL_PTR(dfx_cq_buf))
return;
page_shift = PAGE_SHIFT + hr_dev->caps.cqe_buf_pg_sz;
......@@ -664,7 +664,7 @@ void rdfx_alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
#endif
rdfx_cq = kzalloc(sizeof(*rdfx_cq), GFP_KERNEL);
if (!rdfx_cq)
if (ZERO_OR_NULL_PTR(rdfx_cq))
goto err_buf;
rdfx_cq->buf = dfx_cq_buf;
......@@ -707,7 +707,7 @@ void rdfx_alloc_qp_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
unsigned long flags;
dfx_qp_buf = kzalloc(sizeof(struct hns_roce_buf), GFP_KERNEL);
if (!dfx_qp_buf)
if (ZERO_OR_NULL_PTR(dfx_qp_buf))
return;
page_shift = PAGE_SHIFT + hr_dev->caps.mtt_buf_pg_sz;
......@@ -721,7 +721,7 @@ void rdfx_alloc_qp_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
}
rdfx_qp = kzalloc(sizeof(*rdfx_qp), GFP_KERNEL);
if (!rdfx_qp) {
if (ZERO_OR_NULL_PTR(rdfx_qp)) {
hns_roce_buf_free(hr_dev, hr_qp->buff_size, dfx_qp_buf);
kfree(dfx_qp_buf);
return;
......@@ -788,7 +788,7 @@ void rdfx_alloc_rdfx_mr(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr)
unsigned long flags;
rdfx_mr = kzalloc(sizeof(*rdfx_mr), GFP_KERNEL);
if (!rdfx_mr)
if (ZERO_OR_NULL_PTR(rdfx_mr))
return;
rdfx_mr->pd = mr->pd;
......@@ -853,7 +853,7 @@ void rdfx_alloc_rdfx_pd(struct hns_roce_dev *hr_dev, struct hns_roce_pd *pd)
unsigned long flags;
rdfx_pd = kzalloc(sizeof(struct rdfx_pd_info), GFP_KERNEL);
if (!rdfx_pd)
if (ZERO_OR_NULL_PTR(rdfx_pd))
return;
rdfx_pd->pdn = pd->pdn;
......@@ -971,7 +971,7 @@ void rdfx_cp_sq_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *qp,
memcpy(dfx_qp_buf, dfx_hns_wqe_sge, (wr->num_sge - 2) *
sizeof(struct hns_roce_v2_wqe_data_seg));
if (wr->opcode <= IB_WR_MASKED_ATOMIC_FETCH_AND_ADD)
if (wr->opcode <= IB_WR_REG_SIG_MR)
atomic_inc(&(sq->sq_wqe_cnt[wr->opcode]));
else
dev_err(hr_dev->dev, "Error opcode - %d while post send.\n",
......
......@@ -36,7 +36,6 @@ const struct file_operations chr_ops = {
static const struct rdfx_dev_id rdfx_dev_tbl[] = {
{.name = "hisi_", .ops = NULL},
{.name = "hns", .ops = &rdfx_ops_hw_v2},
{},
};
/*
......@@ -55,7 +54,7 @@ int parg_getopt(char *input, char *optstring, char *parg)
if (input == NULL || optstring == NULL)
return -EINVAL;
_input = kmalloc(strlen(input) + 1, GFP_KERNEL);
if (!_input)
if (ZERO_OR_NULL_PTR(_input))
return -ENOMEM;
strcpy(_input, input);
_optstring[0] = '-';
......@@ -129,7 +128,7 @@ int str_to_ll(char *p_buf, unsigned long long *pll_val, unsigned int *num)
arr = kzalloc(sizeof(unsigned long long) *
SYSFS_MAX_PARA, GFP_KERNEL);
if (!arr)
if (ZERO_OR_NULL_PTR(arr))
return -ENOMEM;
p = strtok(p_buf, delim);
......@@ -231,10 +230,9 @@ static int rdfx_info_init(struct ib_device *ib_dev, int i)
for (j = 0; j < sizeof(rdfx_dev_tbl)/sizeof(struct rdfx_dev_id); j++) {
if (!memcmp(rdfx_dev_tbl[j].name, ib_dev->name,
strlen(rdfx_dev_tbl[j].name))) {
if (rdfx_dev_tbl[j].ops)
rdfx_top_info_list[i].rdfx =
rdfx_dev_tbl[j].ops->get_dfx(ib_dev);
strlen(rdfx_dev_tbl[j].name)) && rdfx_dev_tbl[j].ops) {
rdfx_top_info_list[i].rdfx =
rdfx_dev_tbl[j].ops->get_dfx(ib_dev);
(rdfx_top_info_list[i].rdfx)->ops = rdfx_dev_tbl[j].ops;
(rdfx_top_info_list[i].rdfx)->drv_dev = drv_device;
......@@ -269,11 +267,12 @@ static void rdfx_add_device(struct ib_device *ib_dev)
}
rdfx_top_info_list[i].dev = ib_dev;
pr_info("rdfx add ib device(%p), idx - %d, name - %s\n",
pr_info("rdfx add ib device(%pK), idx - %d, name - %s\n",
ib_dev, i, ib_dev->name);
ret = rdfx_info_init(ib_dev, i);
if (ret) {
pr_err("rdfx info init failed\n");
rdfx_top_info_list[i].dev = NULL;
return;
}
......@@ -291,7 +290,7 @@ static void rdfx_remove_device(struct ib_device *ib_dev, void *client_data)
for (i = 0; i < MAX_IB_DEV; i++) {
if (rdfx_top_info_list[i].dev &&
(rdfx_top_info_list[i].dev == ib_dev)) {
pr_info("rdfx rm ib device(%p), idx - %d, name - %s\n",
pr_info("rdfx rm ib device(%pK), idx - %d, name - %s\n",
ib_dev, i, ib_dev->name);
ops = (rdfx_top_info_list[i].rdfx)->ops;
ops->del_sysfs(rdfx_top_info_list[i].rdfx);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册