Skip to contentSkip to conversation

RDMA/hns: Cleanups for hip08

PATCH In review Weihang Li 3 participants 16 messages Nov 5, 2019 – Nov 9, 2019

Subsystems (2)
lore
Share & tools
lore

Weihang Li

author
#0 lore raw

v2 cover RDMA/hns: Cleanups for hip08

These series just make cleanups without changing code logic.

[patch 1/9 ~ 3/9] remove unused variables and structures. [patch 4/9 ~ 5/9] modify field and function names.
[patch 6/9 ~ 7/9] remove dead codes to simplify functions. [patch 8/9] replaces non-standard return value with linux error codes. [patch 9/9] does some fixes on printings.

Changelog
v1->v2: Remove "{topost}" in titles.

Lang Cheng (3):
RDMA/hns: Remove unnecessary structure hns_roce_sqp RDMA/hns: Simplify doorbell initialization code RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code

Wenpeng Liang (1):
RDMA/hns: Modify appropriate printings

Yixian Liu (4):
RDMA/hns: Delete unnecessary variable max_post RDMA/hns: Delete unnecessary uar from hns_roce_cq RDMA/hns: Modify fields of struct hns_roce_srq RDMA/hns: Fix non-standard error codes

Yixing Liu (1):
RDMA/hns: Replace not intuitive function/macro names

 drivers/infiniband/hw/hns/hns_roce_alloc.c  |  4 +-
 drivers/infiniband/hw/hns/hns_roce_cmd.h    | 14 +++----
 drivers/infiniband/hw/hns/hns_roce_cq.c     | 51 +++++++++++-----------
 drivers/infiniband/hw/hns/hns_roce_device.h | 22 +++-------
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  | 12 +++---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 37 ++++++----------
 drivers/infiniband/hw/hns/hns_roce_main.c   |  4 +-
 drivers/infiniband/hw/hns/hns_roce_mr.c     | 65 +++++++++++++++--------------
 drivers/infiniband/hw/hns/hns_roce_pd.c     |  2 +-
 drivers/infiniband/hw/hns/hns_roce_qp.c     | 18 ++++----
 drivers/infiniband/hw/hns/hns_roce_srq.c    | 58 ++++++++++++-------------
 11 files changed, 132 insertions(+), 155 deletions(-)
Signature · 1 line
2.8.1
author
#1 lore raw

PATCH v2 1/9 RDMA/hns: Delete unnecessary variable max_post

From: Yixian Liu <[email protected]>

There is no need to define max_post in hns_roce_wq, as it does same thing as wqe_cnt.

---
 drivers/infiniband/hw/hns/hns_roce_device.h | 1 -
 drivers/infiniband/hw/hns/hns_roce_qp.c     | 8 ++++----
 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +0 -1
index cbd75e4..3ed6b9e 100644
@@ -426,7 +426,6 @@ struct hns_roce_wq {
 	u64		*wrid;     /* Work request ID */
 	spinlock_t	lock;
 	int		wqe_cnt;  /* WQE num */
-	u32		max_post;
 	int		max_gs;
 	int		offset;
 	int		wqe_shift;	/* WQE size */
drivers/infiniband/hw/hns/hns_roce_qp.c +4 -4
index bec48f2..071e9bc 100644
@@ -318,7 +318,7 @@ static int hns_roce_set_rq_size(struct hns_roce_dev *hr_dev,
 					      * hr_qp->rq.max_gs);
 	}
 
-	cap->max_recv_wr = hr_qp->rq.max_post = hr_qp->rq.wqe_cnt;
+	cap->max_recv_wr = hr_qp->rq.wqe_cnt;
 	cap->max_recv_sge = hr_qp->rq.max_gs;
 
 	return 0;
@@ -608,7 +608,7 @@ static int hns_roce_set_kernel_sq_size(struct hns_roce_dev *hr_dev,
 	hr_qp->buff_size = size;
 
 	/* Get wr and sge number which send */
-	cap->max_send_wr = hr_qp->sq.max_post = hr_qp->sq.wqe_cnt;
+	cap->max_send_wr = hr_qp->sq.wqe_cnt;
 	cap->max_send_sge = hr_qp->sq.max_gs;
 
 	/* We don't support inline sends for kernel QPs (yet) */
@@ -1289,7 +1289,7 @@ bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, int nreq,
 	u32 cur;
 
 	cur = hr_wq->head - hr_wq->tail;
-	if (likely(cur + nreq < hr_wq->max_post))
+	if (likely(cur + nreq < hr_wq->wqe_cnt))
 		return false;
 
 	hr_cq = to_hr_cq(ib_cq);
@@ -1297,7 +1297,7 @@ bool hns_roce_wq_overflow(struct hns_roce_wq *hr_wq, int nreq,
 	cur = hr_wq->head - hr_wq->tail;
 	spin_unlock(&hr_cq->lock);
 
-	return cur + nreq >= hr_wq->max_post;
+	return cur + nreq >= hr_wq->wqe_cnt;
 }
 
 int hns_roce_init_qp_table(struct hns_roce_dev *hr_dev)
Signature · 1 line
2.8.1
author
#2 lore raw

PATCH v2 2/9 RDMA/hns: Remove unnecessary structure hns_roce_sqp

In reply to Weihang Li

From: Lang Cheng <[email protected]>

Special QP have no differences with normal qp in data structure, so definition of struct hns_roce_sqp should be removed and replaced by struct hns_roce_qp.

---
 drivers/infiniband/hw/hns/hns_roce_device.h | 9 ---------
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  | 5 +----
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 5 +----
 drivers/infiniband/hw/hns/hns_roce_qp.c     | 8 +++-----
 4 files changed, 5 insertions(+), 22 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +0 -9
index 3ed6b9e..3529e27 100644
@@ -694,10 +694,6 @@ struct hns_roce_qp {
 	struct hns_roce_rinl_buf rq_inl_buf;
 };
 
-struct hns_roce_sqp {
-	struct hns_roce_qp	hr_qp;
-};
-
 struct hns_roce_ib_iboe {
 	spinlock_t		lock;
 	struct net_device      *netdevs[HNS_ROCE_MAX_PORTS];
@@ -1091,11 +1087,6 @@ static inline struct hns_roce_srq *to_hr_srq(struct ib_srq *ibsrq)
 	return container_of(ibsrq, struct hns_roce_srq, ibsrq);
 }
 
-static inline struct hns_roce_sqp *hr_to_hr_sqp(struct hns_roce_qp *hr_qp)
-{
-	return container_of(hr_qp, struct hns_roce_sqp, hr_qp);
-}
-
 static inline void hns_roce_write64_k(__le32 val[2], void __iomem *dest)
 {
 	__raw_writeq(*(u64 *) val, dest);
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +1 -4
index 5f74bf5..bfe9cee 100644
@@ -3644,10 +3644,7 @@ int hns_roce_v1_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 		hns_roce_buf_free(hr_dev, hr_qp->buff_size, &hr_qp->hr_buf);
 	}
 
-	if (hr_qp->ibqp.qp_type == IB_QPT_RC)
-		kfree(hr_qp);
-	else
-		kfree(hr_to_hr_sqp(hr_qp));
+	kfree(hr_qp);
 	return 0;
 }
 
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -4
index 14e24b4..9b6b046 100644
@@ -4727,10 +4727,7 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
 		ibdev_err(&hr_dev->ib_dev, "Destroy qp 0x%06lx failed(%d)\n",
 			  hr_qp->qpn, ret);
 
-	if (hr_qp->ibqp.qp_type == IB_QPT_GSI)
-		kfree(hr_to_hr_sqp(hr_qp));
-	else
-		kfree(hr_qp);
+	kfree(hr_qp);
 
 	return 0;
 }
drivers/infiniband/hw/hns/hns_roce_qp.c +3 -5
index 071e9bc..ecfa875 100644
@@ -1017,7 +1017,6 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
 	struct ib_device *ibdev = &hr_dev->ib_dev;
-	struct hns_roce_sqp *hr_sqp;
 	struct hns_roce_qp *hr_qp;
 	int ret;
 
@@ -1047,11 +1046,10 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
 			return ERR_PTR(-EINVAL);
 		}
 
-		hr_sqp = kzalloc(sizeof(*hr_sqp), GFP_KERNEL);
-		if (!hr_sqp)
+		hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL);
+		if (!hr_qp)
 			return ERR_PTR(-ENOMEM);
 
-		hr_qp = &hr_sqp->hr_qp;
 		hr_qp->port = init_attr->port_num - 1;
 		hr_qp->phy_port = hr_dev->iboe.phy_port[hr_qp->port];
 
@@ -1066,7 +1064,7 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
 						hr_qp->ibqp.qp_num, hr_qp);
 		if (ret) {
 			ibdev_err(ibdev, "Create GSI QP failed!\n");
-			kfree(hr_sqp);
+			kfree(hr_qp);
 			return ERR_PTR(ret);
 		}
 
Signature · 1 line
2.8.1
author
#3 lore raw

PATCH v2 3/9 RDMA/hns: Delete unnecessary uar from hns_roce_cq

In reply to Weihang Li

From: Yixian Liu <[email protected]>

The uar information is already recorded in priv_uar of hns_roce_dev, there is no need to record it in hns_roce_cq again.

---
 drivers/infiniband/hw/hns/hns_roce_cq.c     | 4 +---
 drivers/infiniband/hw/hns/hns_roce_device.h | 1 -
 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_cq.c +1 -3
index 22541d1..d1d7739 100644
@@ -347,7 +347,6 @@ static int create_kernel_cq(struct hns_roce_dev *hr_dev,
 			    struct hns_roce_cq *hr_cq, int cq_entries)
 {
 	struct device *dev = hr_dev->dev;
-	struct hns_roce_uar *uar;
 	int ret;
 
 	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) {
@@ -367,9 +366,8 @@ static int create_kernel_cq(struct hns_roce_dev *hr_dev,
 		goto err_db;
 	}
 
-	uar = &hr_dev->priv_uar;
 	hr_cq->cq_db_l = hr_dev->reg_base + hr_dev->odb_offset +
-			 DB_REG_OFFSET * uar->index;
+			 DB_REG_OFFSET * hr_dev->priv_uar.index;
 
 	return 0;
 
drivers/infiniband/hw/hns/hns_roce_device.h +0 -1
index 3529e27..3800fea 100644
@@ -496,7 +496,6 @@ struct hns_roce_cq {
 	void (*comp)(struct hns_roce_cq *cq);
 	void (*event)(struct hns_roce_cq *cq, enum hns_roce_event event_type);
 
-	struct hns_roce_uar		*uar;
 	u32				cq_depth;
 	u32				cons_index;
 	u32				*set_ci_db;
Signature · 1 line
2.8.1
author
#4 lore raw

PATCH v2 4/9 RDMA/hns: Modify fields of struct hns_roce_srq

In reply to Weihang Li

From: Yixian Liu <[email protected]>

Use wqe_cnt instead of max which means the queue size of srq, and remove wqe_ctr which is not used.

---
 drivers/infiniband/hw/hns/hns_roce_device.h |  5 ++---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 12 ++++++------
 drivers/infiniband/hw/hns/hns_roce_srq.c    | 26 +++++++++++++-------------
 3 files changed, 21 insertions(+), 22 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +2 -3
index 3800fea..5b499a9 100644
@@ -519,9 +519,8 @@ struct hns_roce_idx_que {
 
 struct hns_roce_srq {
 	struct ib_srq		ibsrq;
-	void (*event)(struct hns_roce_srq *srq, enum hns_roce_event event);
 	unsigned long		srqn;
-	int			max;
+	u32			wqe_cnt;
 	int			max_gs;
 	int			wqe_shift;
 	void __iomem		*db_reg_l;
@@ -537,8 +536,8 @@ struct hns_roce_srq {
 	spinlock_t		lock;
 	int			head;
 	int			tail;
-	u16			wqe_ctr;
 	struct mutex		mutex;
+	void (*event)(struct hns_roce_srq *srq, enum hns_roce_event event);
 };
 
 struct hns_roce_uar_table {
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +6 -6
index 9b6b046..266d746d 100644
@@ -6040,7 +6040,7 @@ static void hns_roce_v2_write_srqc(struct hns_roce_dev *hr_dev,
 		       hr_dev->caps.srqwqe_hop_num));
 	roce_set_field(srq_context->byte_4_srqn_srqst,
 		       SRQC_BYTE_4_SRQ_SHIFT_M, SRQC_BYTE_4_SRQ_SHIFT_S,
-		       ilog2(srq->max));
+		       ilog2(srq->wqe_cnt));
 
 	roce_set_field(srq_context->byte_4_srqn_srqst, SRQC_BYTE_4_SRQN_M,
 		       SRQC_BYTE_4_SRQN_S, srq->srqn);
@@ -6126,7 +6126,7 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq,
 	int ret;
 
 	if (srq_attr_mask & IB_SRQ_LIMIT) {
-		if (srq_attr->srq_limit >= srq->max)
+		if (srq_attr->srq_limit >= srq->wqe_cnt)
 			return -EINVAL;
 
 		mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
@@ -6186,7 +6186,7 @@ static int hns_roce_v2_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr)
 				  SRQC_BYTE_8_SRQ_LIMIT_WL_S);
 
 	attr->srq_limit = limit_wl;
-	attr->max_wr    = srq->max - 1;
+	attr->max_wr    = srq->wqe_cnt - 1;
 	attr->max_sge   = srq->max_gs;
 
 	memcpy(srq_context, mailbox->buf, sizeof(*srq_context));
@@ -6239,7 +6239,7 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
 
 	spin_lock_irqsave(&srq->lock, flags);
 
-	ind = srq->head & (srq->max - 1);
+	ind = srq->head & (srq->wqe_cnt - 1);
 
 	for (nreq = 0; wr; ++nreq, wr = wr->next) {
 		if (unlikely(wr->num_sge > srq->max_gs)) {
@@ -6254,7 +6254,7 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
 			break;
 		}
 
-		wqe_idx = find_empty_entry(&srq->idx_que, srq->max);
+		wqe_idx = find_empty_entry(&srq->idx_que, srq->wqe_cnt);
 		if (wqe_idx < 0) {
 			ret = -ENOMEM;
 			*bad_wr = wr;
@@ -6278,7 +6278,7 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
 		}
 
 		srq->wrid[wqe_idx] = wr->wr_id;
-		ind = (ind + 1) & (srq->max - 1);
+		ind = (ind + 1) & (srq->wqe_cnt - 1);
 	}
 
 	if (likely(nreq)) {
drivers/infiniband/hw/hns/hns_roce_srq.c +13 -13
index d96041d..6f9d1d2 100644
@@ -255,7 +255,7 @@ static int hns_roce_create_idx_que(struct ib_pd *pd, struct hns_roce_srq *srq,
 	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
 	struct hns_roce_idx_que *idx_que = &srq->idx_que;
 
-	idx_que->bitmap = bitmap_zalloc(srq->max, GFP_KERNEL);
+	idx_que->bitmap = bitmap_zalloc(srq->wqe_cnt, GFP_KERNEL);
 	if (!idx_que->bitmap)
 		return -ENOMEM;
 
@@ -281,7 +281,7 @@ static int create_kernel_srq(struct hns_roce_srq *srq, int srq_buf_size)
 		return -ENOMEM;
 
 	srq->head = 0;
-	srq->tail = srq->max - 1;
+	srq->tail = srq->wqe_cnt - 1;
 
 	ret = hns_roce_mtt_init(hr_dev, srq->buf.npages, srq->buf.page_shift,
 				&srq->mtt);
@@ -312,7 +312,7 @@ static int create_kernel_srq(struct hns_roce_srq *srq, int srq_buf_size)
 	if (ret)
 		goto err_kernel_idx_buf;
 
-	srq->wrid = kvmalloc_array(srq->max, sizeof(u64), GFP_KERNEL);
+	srq->wrid = kvmalloc_array(srq->wqe_cnt, sizeof(u64), GFP_KERNEL);
 	if (!srq->wrid) {
 		ret = -ENOMEM;
 		goto err_kernel_idx_buf;
@@ -358,7 +358,7 @@ static void destroy_kernel_srq(struct hns_roce_dev *hr_dev,
 }
 
 int hns_roce_create_srq(struct ib_srq *ib_srq,
-			struct ib_srq_init_attr *srq_init_attr,
+			struct ib_srq_init_attr *init_attr,
 			struct ib_udata *udata)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(ib_srq->device);
@@ -370,24 +370,24 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
 	u32 cqn;
 
 	/* Check the actual SRQ wqe and SRQ sge num */
-	if (srq_init_attr->attr.max_wr >= hr_dev->caps.max_srq_wrs ||
-	    srq_init_attr->attr.max_sge > hr_dev->caps.max_srq_sges)
+	if (init_attr->attr.max_wr >= hr_dev->caps.max_srq_wrs ||
+	    init_attr->attr.max_sge > hr_dev->caps.max_srq_sges)
 		return -EINVAL;
 
 	mutex_init(&srq->mutex);
 	spin_lock_init(&srq->lock);
 
-	srq->max = roundup_pow_of_two(srq_init_attr->attr.max_wr + 1);
-	srq->max_gs = srq_init_attr->attr.max_sge;
+	srq->wqe_cnt = roundup_pow_of_two(init_attr->attr.max_wr + 1);
+	srq->max_gs = init_attr->attr.max_sge;
 
 	srq_desc_size = max(16, 16 * srq->max_gs);
 
 	srq->wqe_shift = ilog2(srq_desc_size);
 
-	srq_buf_size = srq->max * srq_desc_size;
+	srq_buf_size = srq->wqe_cnt * srq_desc_size;
 
 	srq->idx_que.entry_sz = HNS_ROCE_IDX_QUE_ENTRY_SZ;
-	srq->idx_que.buf_size = srq->max * srq->idx_que.entry_sz;
+	srq->idx_que.buf_size = srq->wqe_cnt * srq->idx_que.entry_sz;
 	srq->mtt.mtt_type = MTT_TYPE_SRQWQE;
 	srq->idx_que.mtt.mtt_type = MTT_TYPE_IDX;
 
@@ -405,8 +405,8 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
 		}
 	}
 
-	cqn = ib_srq_has_cq(srq_init_attr->srq_type) ?
-	      to_hr_cq(srq_init_attr->ext.cq)->cqn : 0;
+	cqn = ib_srq_has_cq(init_attr->srq_type) ?
+	      to_hr_cq(init_attr->ext.cq)->cqn : 0;
 
 	srq->db_reg_l = hr_dev->reg_base + SRQ_DB_REG;
 
@@ -453,7 +453,7 @@ void hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
 		hns_roce_mtt_cleanup(hr_dev, &srq->idx_que.mtt);
 	} else {
 		kvfree(srq->wrid);
-		hns_roce_buf_free(hr_dev, srq->max << srq->wqe_shift,
+		hns_roce_buf_free(hr_dev, srq->wqe_cnt << srq->wqe_shift,
 				  &srq->buf);
 	}
 	ib_umem_release(srq->idx_que.umem);
Signature · 1 line
2.8.1
author
#5 lore raw

PATCH v2 5/9 RDMA/hns: Replace not intuitive function/macro names

In reply to Weihang Li

From: Yixing Liu <[email protected]>

Replace "sw2hw" and "hw2sw" which is hard to understand with "create" and "destroy".

---
 drivers/infiniband/hw/hns/hns_roce_cmd.h    | 14 ++++----
 drivers/infiniband/hw/hns/hns_roce_cq.c     | 23 ++++++-------
 drivers/infiniband/hw/hns/hns_roce_device.h |  6 ++--
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  |  7 ++--
 drivers/infiniband/hw/hns/hns_roce_mr.c     | 50 +++++++++++++++--------------
 drivers/infiniband/hw/hns/hns_roce_srq.c    | 22 ++++++-------
 6 files changed, 63 insertions(+), 59 deletions(-)
drivers/infiniband/hw/hns/hns_roce_cmd.h +7 -7
index 2b6ac64..cd3ed2b 100644
@@ -115,12 +115,12 @@ enum {
 
 enum {
 	/* TPT commands */
-	HNS_ROCE_CMD_SW2HW_MPT		= 0xd,
-	HNS_ROCE_CMD_HW2SW_MPT		= 0xf,
+	HNS_ROCE_CMD_CREATE_MPT		= 0xd,
+	HNS_ROCE_CMD_DESTROY_MPT	= 0xf,
 
 	/* CQ commands */
-	HNS_ROCE_CMD_SW2HW_CQ		= 0x16,
-	HNS_ROCE_CMD_HW2SW_CQ		= 0x17,
+	HNS_ROCE_CMD_CREATE_CQ		= 0x16,
+	HNS_ROCE_CMD_DESTROY_CQ		= 0x17,
 
 	/* QP/EE commands */
 	HNS_ROCE_CMD_RST2INIT_QP	= 0x19,
@@ -129,14 +129,14 @@ enum {
 	HNS_ROCE_CMD_RTS2RTS_QP		= 0x1c,
 	HNS_ROCE_CMD_2ERR_QP		= 0x1e,
 	HNS_ROCE_CMD_RTS2SQD_QP		= 0x1f,
-	HNS_ROCE_CMD_SQD2SQD_QP		= 0x38,
 	HNS_ROCE_CMD_SQD2RTS_QP		= 0x20,
 	HNS_ROCE_CMD_2RST_QP		= 0x21,
 	HNS_ROCE_CMD_QUERY_QP		= 0x22,
-	HNS_ROCE_CMD_SW2HW_SRQ		= 0x70,
+	HNS_ROCE_CMD_SQD2SQD_QP		= 0x38,
+	HNS_ROCE_CMD_CREATE_SRQ		= 0x70,
 	HNS_ROCE_CMD_MODIFY_SRQC	= 0x72,
 	HNS_ROCE_CMD_QUERY_SRQC		= 0x73,
-	HNS_ROCE_CMD_HW2SW_SRQ		= 0x74,
+	HNS_ROCE_CMD_DESTROY_SRQ	= 0x74,
 };
 
 int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,
drivers/infiniband/hw/hns/hns_roce_cq.c +12 -11
index d1d7739..713df1f 100644
@@ -73,12 +73,13 @@ static void hns_roce_ib_cq_event(struct hns_roce_cq *hr_cq,
 	}
 }
 
-static int hns_roce_sw2hw_cq(struct hns_roce_dev *dev,
-			     struct hns_roce_cmd_mailbox *mailbox,
-			     unsigned long cq_num)
+static int hns_roce_hw_create_cq(struct hns_roce_dev *dev,
+				 struct hns_roce_cmd_mailbox *mailbox,
+				 unsigned long cq_num)
 {
 	return hns_roce_cmd_mbox(dev, mailbox->dma, 0, cq_num, 0,
-			    HNS_ROCE_CMD_SW2HW_CQ, HNS_ROCE_CMD_TIMEOUT_MSECS);
+				 HNS_ROCE_CMD_CREATE_CQ,
+				 HNS_ROCE_CMD_TIMEOUT_MSECS);
 }
 
 static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
@@ -144,7 +145,7 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
 			      nent, vector);
 
 	/* Send mailbox to hw */
-	ret = hns_roce_sw2hw_cq(hr_dev, mailbox, hr_cq->cqn);
+	ret = hns_roce_hw_create_cq(hr_dev, mailbox, hr_cq->cqn);
 	hns_roce_free_cmd_mailbox(hr_dev, mailbox);
 	if (ret) {
 		dev_err(dev, "CQ alloc.Failed to cmd mailbox.\n");
@@ -170,12 +171,12 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
 	return ret;
 }
 
-static int hns_roce_hw2sw_cq(struct hns_roce_dev *dev,
-			     struct hns_roce_cmd_mailbox *mailbox,
-			     unsigned long cq_num)
+static int hns_roce_hw_destroy_cq(struct hns_roce_dev *dev,
+				  struct hns_roce_cmd_mailbox *mailbox,
+				  unsigned long cq_num)
 {
 	return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, cq_num,
-				 mailbox ? 0 : 1, HNS_ROCE_CMD_HW2SW_CQ,
+				 mailbox ? 0 : 1, HNS_ROCE_CMD_DESTROY_CQ,
 				 HNS_ROCE_CMD_TIMEOUT_MSECS);
 }
 
@@ -185,9 +186,9 @@ void hns_roce_free_cq(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq)
 	struct device *dev = hr_dev->dev;
 	int ret;
 
-	ret = hns_roce_hw2sw_cq(hr_dev, NULL, hr_cq->cqn);
+	ret = hns_roce_hw_destroy_cq(hr_dev, NULL, hr_cq->cqn);
 	if (ret)
-		dev_err(dev, "HW2SW_CQ failed (%d) for CQN %06lx\n", ret,
+		dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret,
 			hr_cq->cqn);
 
 	xa_erase(&cq_table->array, hr_cq->cqn);
drivers/infiniband/hw/hns/hns_roce_device.h +3 -3
index 5b499a9..d5d9521 100644
@@ -1186,9 +1186,9 @@ struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
 int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
 		       unsigned int *sg_offset);
 int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
-int hns_roce_hw2sw_mpt(struct hns_roce_dev *hr_dev,
-		       struct hns_roce_cmd_mailbox *mailbox,
-		       unsigned long mpt_index);
+int hns_roce_hw_destroy_mpt(struct hns_roce_dev *hr_dev,
+			    struct hns_roce_cmd_mailbox *mailbox,
+			    unsigned long mpt_index);
 unsigned long key_to_hw_index(u32 key);
 
 struct ib_mw *hns_roce_alloc_mw(struct ib_pd *pd, enum ib_mw_type,
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +4 -3
index bfe9cee..89a4c3a 100644
@@ -1114,9 +1114,10 @@ static int hns_roce_v1_dereg_mr(struct hns_roce_dev *hr_dev,
 	free_mr = &priv->free_mr;
 
 	if (mr->enabled) {
-		if (hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mr->key)
-				       & (hr_dev->caps.num_mtpts - 1)))
-			dev_warn(dev, "HW2SW_MPT failed!\n");
+		if (hns_roce_hw_destroy_mpt(hr_dev, NULL,
+					    key_to_hw_index(mr->key) &
+					    (hr_dev->caps.num_mtpts - 1)))
+			dev_warn(dev, "DESTROY_MPT failed!\n");
 	}
 
 	mr_work = kzalloc(sizeof(*mr_work), GFP_KERNEL);
drivers/infiniband/hw/hns/hns_roce_mr.c +26 -24

105 lines not on this page · raw message

drivers/infiniband/hw/hns/hns_roce_srq.c +11 -11
index 6f9d1d2..d275818 100644
@@ -59,21 +59,21 @@ static void hns_roce_ib_srq_event(struct hns_roce_srq *srq,
 	}
 }
 
-static int hns_roce_sw2hw_srq(struct hns_roce_dev *dev,
-			      struct hns_roce_cmd_mailbox *mailbox,
-			      unsigned long srq_num)
+static int hns_roce_hw_create_srq(struct hns_roce_dev *dev,
+				  struct hns_roce_cmd_mailbox *mailbox,
+				  unsigned long srq_num)
 {
 	return hns_roce_cmd_mbox(dev, mailbox->dma, 0, srq_num, 0,
-				 HNS_ROCE_CMD_SW2HW_SRQ,
+				 HNS_ROCE_CMD_CREATE_SRQ,
 				 HNS_ROCE_CMD_TIMEOUT_MSECS);
 }
 
-static int hns_roce_hw2sw_srq(struct hns_roce_dev *dev,
-			     struct hns_roce_cmd_mailbox *mailbox,
-			     unsigned long srq_num)
+static int hns_roce_hw_destroy_srq(struct hns_roce_dev *dev,
+				   struct hns_roce_cmd_mailbox *mailbox,
+				   unsigned long srq_num)
 {
 	return hns_roce_cmd_mbox(dev, 0, mailbox ? mailbox->dma : 0, srq_num,
-				 mailbox ? 0 : 1, HNS_ROCE_CMD_HW2SW_SRQ,
+				 mailbox ? 0 : 1, HNS_ROCE_CMD_DESTROY_SRQ,
 				 HNS_ROCE_CMD_TIMEOUT_MSECS);
 }
 
@@ -134,7 +134,7 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn,
 			       mtts_wqe, mtts_idx, dma_handle_wqe,
 			       dma_handle_idx);
 
-	ret = hns_roce_sw2hw_srq(hr_dev, mailbox, srq->srqn);
+	ret = hns_roce_hw_create_srq(hr_dev, mailbox, srq->srqn);
 	hns_roce_free_cmd_mailbox(hr_dev, mailbox);
 	if (ret)
 		goto err_xa;
@@ -160,9 +160,9 @@ static void hns_roce_srq_free(struct hns_roce_dev *hr_dev,
 	struct hns_roce_srq_table *srq_table = &hr_dev->srq_table;
 	int ret;
 
-	ret = hns_roce_hw2sw_srq(hr_dev, NULL, srq->srqn);
+	ret = hns_roce_hw_destroy_srq(hr_dev, NULL, srq->srqn);
 	if (ret)
-		dev_err(hr_dev->dev, "HW2SW_SRQ failed (%d) for CQN %06lx\n",
+		dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n",
 			ret, srq->srqn);
 
 	xa_erase(&srq_table->xa, srq->srqn);
Signature · 1 line
2.8.1
author
#6 lore raw

PATCH v2 6/9 RDMA/hns: Simplify doorbell initialization code

In reply to Weihang Li

From: Lang Cheng <[email protected]>

If a variable needs to be set to 0 before use, it can be directly initialized to 0.

---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -4
index 266d746d..f65bd7a 100644
@@ -4944,10 +4944,7 @@ static void hns_roce_v2_init_irq_work(struct hns_roce_dev *hr_dev,
 static void set_eq_cons_index_v2(struct hns_roce_eq *eq)
 {
 	struct hns_roce_dev *hr_dev = eq->hr_dev;
-	__le32 doorbell[2];
-
-	doorbell[0] = 0;
-	doorbell[1] = 0;
+	__le32 doorbell[2] = {};
 
 	if (eq->type_flag == HNS_ROCE_AEQ) {
 		roce_set_field(doorbell[0], HNS_ROCE_V2_EQ_DB_CMD_M,
Signature · 1 line
2.8.1
author
#7 lore raw

PATCH v2 7/9 RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code

In reply to Weihang Li

From: Lang Cheng <[email protected]>

Merge base configuration of hr_dev into hns_roce_hw_v2_get_cfg(). In addition, there is no need to return 0 at last, so we change return type of it to void.

---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +4 -11
index f65bd7a..fdc0cd6 100644
@@ -6370,12 +6370,14 @@ static const struct pci_device_id hns_roce_hw_v2_pci_tbl[] = {
 
 MODULE_DEVICE_TABLE(pci, hns_roce_hw_v2_pci_tbl);
 
-static int hns_roce_hw_v2_get_cfg(struct hns_roce_dev *hr_dev,
+static void hns_roce_hw_v2_get_cfg(struct hns_roce_dev *hr_dev,
 				  struct hnae3_handle *handle)
 {
 	struct hns_roce_v2_priv *priv = hr_dev->priv;
 	int i;
 
+	hr_dev->pci_dev = handle->pdev;
+	hr_dev->dev = &handle->pdev->dev;
 	hr_dev->hw = &hns_roce_hw_v2;
 	hr_dev->dfx = &hns_roce_dfx_hw_v2;
 	hr_dev->sdb_offset = ROCEE_DB_SQ_L_0_REG;
@@ -6400,8 +6402,6 @@ static int hns_roce_hw_v2_get_cfg(struct hns_roce_dev *hr_dev,
 
 	hr_dev->reset_cnt = handle->ae_algo->ops->ae_dev_reset_cnt(handle);
 	priv->handle = handle;
-
-	return 0;
 }
 
 static int __hns_roce_hw_v2_init_instance(struct hnae3_handle *handle)
@@ -6419,14 +6419,7 @@ static int __hns_roce_hw_v2_init_instance(struct hnae3_handle *handle)
 		goto error_failed_kzalloc;
 	}
 
-	hr_dev->pci_dev = handle->pdev;
-	hr_dev->dev = &handle->pdev->dev;
-
-	ret = hns_roce_hw_v2_get_cfg(hr_dev, handle);
-	if (ret) {
-		dev_err(hr_dev->dev, "Get Configuration failed!\n");
-		goto error_failed_get_cfg;
-	}
+	hns_roce_hw_v2_get_cfg(hr_dev, handle);
 
 	ret = hns_roce_init(hr_dev);
 	if (ret) {
Signature · 1 line
2.8.1
author
#8 lore raw

PATCH v2 8/9 RDMA/hns: Fix non-standard error codes

In reply to Weihang Li

From: Yixian Liu <[email protected]>

It is better to return a linux error code than define a private constant.

---
 drivers/infiniband/hw/hns/hns_roce_alloc.c |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_cq.c    |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_mr.c    | 15 ++++++++-------
 drivers/infiniband/hw/hns/hns_roce_pd.c    |  2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c   |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_alloc.c +2 -2
index 8c063c5..da574c2 100644
@@ -55,7 +55,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)
 			bitmap->last = 0;
 		*obj |= bitmap->top;
 	} else {
-		ret = -1;
+		ret = -EINVAL;
 	}
 
 	spin_unlock(&bitmap->lock);
@@ -100,7 +100,7 @@ int hns_roce_bitmap_alloc_range(struct hns_roce_bitmap *bitmap, int cnt,
 		}
 		*obj |= bitmap->top;
 	} else {
-		ret = -1;
+		ret = -EINVAL;
 	}
 
 	spin_unlock(&bitmap->lock);
drivers/infiniband/hw/hns/hns_roce_cq.c +2 -2
index 713df1f..699c987 100644
@@ -116,9 +116,9 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
 	hr_cq->vector = vector;
 
 	ret = hns_roce_bitmap_alloc(&cq_table->bitmap, &hr_cq->cqn);
-	if (ret == -1) {
+	if (ret) {
 		dev_err(dev, "CQ alloc.Failed to alloc index.\n");
-		return -ENOMEM;
+		return ret;
 	}
 
 	/* Get CQC memory HEM(Hardware Entry Memory) table */
drivers/infiniband/hw/hns/hns_roce_mr.c +8 -7
index 577946b..6589e28 100644
@@ -83,7 +83,7 @@ static int hns_roce_buddy_alloc(struct hns_roce_buddy *buddy, int order,
 		}
 	}
 	spin_unlock(&buddy->lock);
-	return -1;
+	return -EINVAL;
 
  found:
 	clear_bit(*seg, buddy->bits[o]);
@@ -206,13 +206,14 @@ static int hns_roce_alloc_mtt_range(struct hns_roce_dev *hr_dev, int order,
 	}
 
 	ret = hns_roce_buddy_alloc(buddy, order, seg);
-	if (ret == -1)
-		return -1;
+	if (ret)
+		return ret;
 
-	if (hns_roce_table_get_range(hr_dev, table, *seg,
-				     *seg + (1 << order) - 1)) {
+	ret = hns_roce_table_get_range(hr_dev, table, *seg,
+				       *seg + (1 << order) - 1);
+	if (ret) {
 		hns_roce_buddy_free(buddy, *seg, order);
-		return -1;
+		return ret;
 	}
 
 	return 0;
@@ -578,7 +579,7 @@ static int hns_roce_mr_alloc(struct hns_roce_dev *hr_dev, u32 pd, u64 iova,
 
 	/* Allocate a key for mr from mr_table */
 	ret = hns_roce_bitmap_alloc(&hr_dev->mr_table.mtpt_bitmap, &index);
-	if (ret == -1)
+	if (ret)
 		return -ENOMEM;
 
 	mr->iova = iova;			/* MR va starting addr */
drivers/infiniband/hw/hns/hns_roce_pd.c +1 -1
index 912b89b4..780c780 100644
@@ -96,7 +96,7 @@ int hns_roce_uar_alloc(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar)
 
 	/* Using bitmap to manager UAR index */
 	ret = hns_roce_bitmap_alloc(&hr_dev->uar_table.bitmap, &uar->logic_idx);
-	if (ret == -1)
+	if (ret)
 		return -ENOMEM;
 
 	if (uar->logic_idx > 0 && hr_dev->caps.phy_num_uars > 1)
drivers/infiniband/hw/hns/hns_roce_srq.c +1 -1
index d275818..96ff782 100644
@@ -111,7 +111,7 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn,
 	}
 
 	ret = hns_roce_bitmap_alloc(&srq_table->bitmap, &srq->srqn);
-	if (ret == -1) {
+	if (ret) {
 		dev_err(hr_dev->dev, "SRQ alloc.Failed to alloc index.\n");
 		return -ENOMEM;
 	}
Signature · 1 line
2.8.1
#9 lore raw

Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes

drivers/infiniband/hw/hns/hns_roce_alloc.c int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Quoted 20 lines · Weihang Li

From: Yixian Liu <[email protected]>

It is better to return a linux error code than define a private constant.

---
 drivers/infiniband/hw/hns/hns_roce_alloc.c |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_cq.c    |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_mr.c    | 15 ++++++++-------
 drivers/infiniband/hw/hns/hns_roce_pd.c    |  2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c   |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_alloc.c +0 -0
index 8c063c5..da574c2 100644
@@ -55,7 +55,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Why do HNS driver have custom bitmap functions instead of include/linux/bitmap.h?

Thanks

author
#10 lore raw

Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes

Quoted 24 lines · Leon Romanovsky

drivers/infiniband/hw/hns/hns_roce_alloc.c int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Quoted 20 lines · Weihang Li

From: Yixian Liu <[email protected]>

It is better to return a linux error code than define a private constant.

---
 drivers/infiniband/hw/hns/hns_roce_alloc.c |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_cq.c    |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_mr.c    | 15 ++++++++-------
 drivers/infiniband/hw/hns/hns_roce_pd.c    |  2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c   |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_alloc.c +0 -0
index 8c063c5..da574c2 100644
@@ -55,7 +55,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Why do HNS driver have custom bitmap functions instead of include/linux/bitmap.h?

Quoted 4 lines

Thanks

.

Hi Leon,

These custom functions achieved the bitmap working in round-robin fashion. When using CM to establish connections, if we allocate a new QP after destroying one, we will get the same QP number which will be rejected by IB core.

I found related patches about this issue:
https://git.congatec.com/android/qmx6_kernel/commit/f4ec9e9531ac79ee2521faf7ad3d98978f747e42
https://patchwork.kernel.org/patch/3306941/
https://patchwork.kernel.org/patch/9444173/

Thanks,
Weihang

#11 lore raw

Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes

Quoted 29 lines · Weihang Li
Quoted 26 lines · Leon Romanovsky

drivers/infiniband/hw/hns/hns_roce_alloc.c int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Quoted 20 lines · Weihang Li

From: Yixian Liu <[email protected]>

It is better to return a linux error code than define a private constant.

---
 drivers/infiniband/hw/hns/hns_roce_alloc.c |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_cq.c    |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_mr.c    | 15 ++++++++-------
 drivers/infiniband/hw/hns/hns_roce_pd.c    |  2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c   |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_alloc.c +0 -0
index 8c063c5..da574c2 100644
@@ -55,7 +55,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Why do HNS driver have custom bitmap functions instead of include/linux/bitmap.h?

Thanks

Quoted 8 lines
Quoted 2 lines

.

Hi Leon,

These custom functions achieved the bitmap working in round-robin fashion. When using CM to establish connections, if we allocate a new QP after destroying one, we will get the same QP number which will be rejected by IB core.

QP number is controlled by HW (or at least should) and not by this bitmap.

Quoted 5 lines

I found related patches about this issue:
https://git.congatec.com/android/qmx6_kernel/commit/f4ec9e9531ac79ee2521faf7ad3d98978f747e42
https://patchwork.kernel.org/patch/3306941/
https://patchwork.kernel.org/patch/9444173/

Irrelevant, those patches try to create and manage object numbers in SW.

Thanks

Quoted 4 lines

Thanks,
Weihang

author
#12 lore raw

Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes

Quoted 33 lines · Leon Romanovsky
Quoted 32 lines · Weihang Li
Quoted 28 lines · Leon Romanovsky

drivers/infiniband/hw/hns/hns_roce_alloc.c int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Quoted 20 lines · Weihang Li

From: Yixian Liu <[email protected]>

It is better to return a linux error code than define a private constant.

---
 drivers/infiniband/hw/hns/hns_roce_alloc.c |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_cq.c    |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_mr.c    | 15 ++++++++-------
 drivers/infiniband/hw/hns/hns_roce_pd.c    |  2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c   |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_alloc.c +0 -0
index 8c063c5..da574c2 100644
@@ -55,7 +55,7 @@ int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj)

Why do HNS driver have custom bitmap functions instead of include/linux/bitmap.h?

Thanks

.

Quoted 7 lines
Quoted 5 lines

Hi Leon,

These custom functions achieved the bitmap working in round-robin fashion. When using CM to establish connections, if we allocate a new QP after destroying one, we will get the same QP number which will be rejected by IB core.

QP number is controlled by HW (or at least should) and not by this bitmap.

Hi Leon,

Sorry for the late reply. QP number is allocated by SW in hip08, so we have to use this round-robin bitmap.

Quoted 18 lines
Quoted 6 lines

I found related patches about this issue:
https://git.congatec.com/android/qmx6_kernel/commit/f4ec9e9531ac79ee2521faf7ad3d98978f747e42
https://patchwork.kernel.org/patch/3306941/
https://patchwork.kernel.org/patch/9444173/

Irrelevant, those patches try to create and manage object numbers in SW.

Thanks

Quoted 4 lines

Thanks,
Weihang

.

author
#13 lore raw

PATCH v2 9/9 RDMA/hns: Modify appropriate printings

In reply to Weihang Li

From: Wenpeng Liang <[email protected]>

Modify some printings that is not in uniformed style, non-standard or with spelling errors.

---
 drivers/infiniband/hw/hns/hns_roce_cq.c   | 20 ++++++++++++--------
 drivers/infiniband/hw/hns/hns_roce_main.c |  4 ++--
 drivers/infiniband/hw/hns/hns_roce_qp.c   |  2 +-
 drivers/infiniband/hw/hns/hns_roce_srq.c  |  8 ++++----
 4 files changed, 19 insertions(+), 15 deletions(-)
drivers/infiniband/hw/hns/hns_roce_cq.c +12 -8
index 699c987..e25fa19 100644
@@ -105,32 +105,34 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
 	mtts = hns_roce_table_find(hr_dev, mtt_table,
 				   hr_mtt->first_seg, &dma_handle);
 	if (!mtts) {
-		dev_err(dev, "CQ alloc.Failed to find cq buf addr.\n");
+		dev_err(dev, "Failed to find mtt for CQ buf.\n");
 		return -EINVAL;
 	}
 
 	if (vector >= hr_dev->caps.num_comp_vectors) {
-		dev_err(dev, "CQ alloc.Invalid vector.\n");
+		dev_err(dev, "Invalid vector(0x%x) for CQ alloc.\n", vector);
 		return -EINVAL;
 	}
 	hr_cq->vector = vector;
 
 	ret = hns_roce_bitmap_alloc(&cq_table->bitmap, &hr_cq->cqn);
 	if (ret) {
-		dev_err(dev, "CQ alloc.Failed to alloc index.\n");
+		dev_err(dev, "Num of CQ out of range.\n");
 		return ret;
 	}
 
 	/* Get CQC memory HEM(Hardware Entry Memory) table */
 	ret = hns_roce_table_get(hr_dev, &cq_table->table, hr_cq->cqn);
 	if (ret) {
-		dev_err(dev, "CQ alloc.Failed to get context mem.\n");
+		dev_err(dev,
+			"Get context mem failed(%d) when CQ(0x%lx) alloc.\n",
+			ret, hr_cq->cqn);
 		goto err_out;
 	}
 
 	ret = xa_err(xa_store(&cq_table->array, hr_cq->cqn, hr_cq, GFP_KERNEL));
 	if (ret) {
-		dev_err(dev, "CQ alloc failed xa_store.\n");
+		dev_err(dev, "Failed to xa_store CQ.\n");
 		goto err_put;
 	}
 
@@ -148,7 +150,9 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
 	ret = hns_roce_hw_create_cq(hr_dev, mailbox, hr_cq->cqn);
 	hns_roce_free_cmd_mailbox(hr_dev, mailbox);
 	if (ret) {
-		dev_err(dev, "CQ alloc.Failed to cmd mailbox.\n");
+		dev_err(dev,
+			"Send cmd mailbox failed(%d) when CQ(0x%lx) alloc.\n",
+			ret, hr_cq->cqn);
 		goto err_xa;
 	}
 
@@ -418,7 +422,7 @@ int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
 	int ret;
 
 	if (cq_entries < 1 || cq_entries > hr_dev->caps.max_cqes) {
-		dev_err(dev, "Creat CQ failed. entries=%d, max=%d\n",
+		dev_err(dev, "Create CQ failed. entries=%d, max=%d\n",
 			cq_entries, hr_dev->caps.max_cqes);
 		return -EINVAL;
 	}
@@ -448,7 +452,7 @@ int hns_roce_ib_create_cq(struct ib_cq *ib_cq,
 	ret = hns_roce_cq_alloc(hr_dev, cq_entries, &hr_cq->hr_buf.hr_mtt,
 				hr_cq, vector);
 	if (ret) {
-		dev_err(dev, "Creat CQ .Failed to cq_alloc.\n");
+		dev_err(dev, "Alloc CQ failed(%d).\n", ret);
 		goto err_dbmap;
 	}
 
drivers/infiniband/hw/hns/hns_roce_main.c +2 -2
index b5d196c..b9200d53 100644
@@ -111,7 +111,7 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
 
 	netdev = hr_dev->iboe.netdevs[port];
 	if (!netdev) {
-		dev_err(dev, "port(%d) can't find netdev\n", port);
+		dev_err(dev, "Can't find netdev on port(%u)!\n", port);
 		return -ENODEV;
 	}
 
@@ -253,7 +253,7 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num,
 	net_dev = hr_dev->iboe.netdevs[port];
 	if (!net_dev) {
 		spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
-		dev_err(dev, "find netdev %d failed!\r\n", port);
+		dev_err(dev, "Find netdev %u failed!\n", port);
 		return -EINVAL;
 	}
 
drivers/infiniband/hw/hns/hns_roce_qp.c +1 -1
index ecfa875..b0e5e8b 100644
@@ -1029,7 +1029,7 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
 		ret = hns_roce_create_qp_common(hr_dev, pd, init_attr, udata, 0,
 						hr_qp);
 		if (ret) {
-			ibdev_err(ibdev, "Create RC QP 0x%06lx failed(%d)\n",
+			ibdev_err(ibdev, "Create QP 0x%06lx failed(%d)\n",
 				  hr_qp->qpn, ret);
 			kfree(hr_qp);
 			return ERR_PTR(ret);
drivers/infiniband/hw/hns/hns_roce_srq.c +4 -4
index 96ff782..a1bfa51 100644
@@ -95,8 +95,7 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn,
 				       srq->mtt.first_seg,
 				       &dma_handle_wqe);
 	if (!mtts_wqe) {
-		dev_err(hr_dev->dev,
-			"SRQ alloc.Failed to find srq buf addr.\n");
+		dev_err(hr_dev->dev, "Failed to find mtt for srq buf.\n");
 		return -EINVAL;
 	}
 
@@ -106,13 +105,14 @@ static int hns_roce_srq_alloc(struct hns_roce_dev *hr_dev, u32 pdn, u32 cqn,
 				       &dma_handle_idx);
 	if (!mtts_idx) {
 		dev_err(hr_dev->dev,
-			"SRQ alloc.Failed to find idx que buf addr.\n");
+			"Failed to find mtt for srq idx queue buf.\n");
 		return -EINVAL;
 	}
 
 	ret = hns_roce_bitmap_alloc(&srq_table->bitmap, &srq->srqn);
 	if (ret) {
-		dev_err(hr_dev->dev, "SRQ alloc.Failed to alloc index.\n");
+		dev_err(hr_dev->dev,
+			"Failed to alloc a bit from srq bitmap.\n");
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.8.1
#14 lore raw
In reply to Weihang Li
Quoted 19 lines · Weihang Li

These series just make cleanups without changing code logic.

[patch 1/9 ~ 3/9] remove unused variables and structures. [patch 4/9 ~ 5/9] modify field and function names.
[patch 6/9 ~ 7/9] remove dead codes to simplify functions. [patch 8/9] replaces non-standard return value with linux error codes. [patch 9/9] does some fixes on printings.

Changelog
v1->v2: Remove "{topost}" in titles.

Lang Cheng (3):
RDMA/hns: Remove unnecessary structure hns_roce_sqp RDMA/hns: Simplify doorbell initialization code RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code

Wenpeng Liang (1):
RDMA/hns: Modify appropriate printings

Quoted 8 lines

Yixian Liu (4):
RDMA/hns: Delete unnecessary variable max_post RDMA/hns: Delete unnecessary uar from hns_roce_cq RDMA/hns: Modify fields of struct hns_roce_srq RDMA/hns: Fix non-standard error codes

Yixing Liu (1):
RDMA/hns: Replace not intuitive function/macro names

Something should probably be done about that custom bitmap stuff Leon noted, but that isn't related to these patches, so applied to for-next

Thanks,
Jason

author
#15 lore raw
Quoted 26 lines · Jason Gunthorpe
Quoted 25 lines · Weihang Li

These series just make cleanups without changing code logic.

[patch 1/9 ~ 3/9] remove unused variables and structures. [patch 4/9 ~ 5/9] modify field and function names.
[patch 6/9 ~ 7/9] remove dead codes to simplify functions. [patch 8/9] replaces non-standard return value with linux error codes. [patch 9/9] does some fixes on printings.

Changelog
v1->v2: Remove "{topost}" in titles.

Lang Cheng (3):
RDMA/hns: Remove unnecessary structure hns_roce_sqp RDMA/hns: Simplify doorbell initialization code RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code

Wenpeng Liang (1):
RDMA/hns: Modify appropriate printings

Yixian Liu (4):
RDMA/hns: Delete unnecessary variable max_post RDMA/hns: Delete unnecessary uar from hns_roce_cq RDMA/hns: Modify fields of struct hns_roce_srq RDMA/hns: Fix non-standard error codes

Quoted 6 lines
Quoted 2 lines

Yixing Liu (1):
RDMA/hns: Replace not intuitive function/macro names

Something should probably be done about that custom bitmap stuff Leon noted, but that isn't related to these patches, so applied to for-next

Thank you, Jason. We will continue to pay attention to this bitmap stuff and discuss further with Leon.

Weihang

Quoted 4 lines

Thanks,
Jason