Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08
@ 2019-11-05 11:07 Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 1/9] RDMA/hns: Delete unnecessary variable max_post Weihang Li
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

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(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 1/9] RDMA/hns: Delete unnecessary variable max_post
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
@ 2019-11-05 11:07 ` Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 2/9] RDMA/hns: Remove unnecessary structure hns_roce_sqp Weihang Li
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Yixian Liu <liuyixian@huawei.com>

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

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index cbd75e4..3ed6b9e 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -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 */
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index bec48f2..071e9bc 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -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)
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 2/9] RDMA/hns: Remove unnecessary structure hns_roce_sqp
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 1/9] RDMA/hns: Delete unnecessary variable max_post Weihang Li
@ 2019-11-05 11:07 ` Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 3/9] RDMA/hns: Delete unnecessary uar from hns_roce_cq Weihang Li
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Lang Cheng <chenglang@huawei.com>

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.

Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 3ed6b9e..3529e27 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -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);
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 5f74bf5..bfe9cee 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -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;
 }
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 14e24b4..9b6b046 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -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;
 }
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index 071e9bc..ecfa875 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -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);
 		}
 
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 3/9] RDMA/hns: Delete unnecessary uar from hns_roce_cq
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 1/9] RDMA/hns: Delete unnecessary variable max_post Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 2/9] RDMA/hns: Remove unnecessary structure hns_roce_sqp Weihang Li
@ 2019-11-05 11:07 ` Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 4/9] RDMA/hns: Modify fields of struct hns_roce_srq Weihang Li
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Yixian Liu <liuyixian@huawei.com>

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.

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index 22541d1..d1d7739 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -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;
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 3529e27..3800fea 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -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;
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 4/9] RDMA/hns: Modify fields of struct hns_roce_srq
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (2 preceding siblings ...)
  2019-11-05 11:07 ` [PATCH v2 for-next 3/9] RDMA/hns: Delete unnecessary uar from hns_roce_cq Weihang Li
@ 2019-11-05 11:07 ` Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 5/9] RDMA/hns: Replace not intuitive function/macro names Weihang Li
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Yixian Liu <liuyixian@huawei.com>

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

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 3800fea..5b499a9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -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 {
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 9b6b046..266d746d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -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)) {
diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index d96041d..6f9d1d2 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -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);
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 5/9] RDMA/hns: Replace not intuitive function/macro names
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (3 preceding siblings ...)
  2019-11-05 11:07 ` [PATCH v2 for-next 4/9] RDMA/hns: Modify fields of struct hns_roce_srq Weihang Li
@ 2019-11-05 11:07 ` Weihang Li
  2019-11-05 11:07 ` [PATCH v2 for-next 6/9] RDMA/hns: Simplify doorbell initialization code Weihang Li
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Yixing Liu <liuyixing1@huawei.com>

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

Signed-off-by: Yixing Liu <liuyixing1@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.h b/drivers/infiniband/hw/hns/hns_roce_cmd.h
index 2b6ac64..cd3ed2b 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cmd.h
+++ b/drivers/infiniband/hw/hns/hns_roce_cmd.h
@@ -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,
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index d1d7739..713df1f 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -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);
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 5b499a9..d5d9521 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -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,
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index bfe9cee..89a4c3a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -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);
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 5f8416b..577946b 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -48,21 +48,21 @@ unsigned long key_to_hw_index(u32 key)
 	return (key << 24) | (key >> 8);
 }
 
-static int hns_roce_sw2hw_mpt(struct hns_roce_dev *hr_dev,
-			      struct hns_roce_cmd_mailbox *mailbox,
-			      unsigned long mpt_index)
+static int hns_roce_hw_create_mpt(struct hns_roce_dev *hr_dev,
+				  struct hns_roce_cmd_mailbox *mailbox,
+				  unsigned long mpt_index)
 {
 	return hns_roce_cmd_mbox(hr_dev, mailbox->dma, 0, mpt_index, 0,
-				 HNS_ROCE_CMD_SW2HW_MPT,
+				 HNS_ROCE_CMD_CREATE_MPT,
 				 HNS_ROCE_CMD_TIMEOUT_MSECS);
 }
 
-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)
 {
 	return hns_roce_cmd_mbox(hr_dev, 0, mailbox ? mailbox->dma : 0,
-				 mpt_index, !mailbox, HNS_ROCE_CMD_HW2SW_MPT,
+				 mpt_index, !mailbox, HNS_ROCE_CMD_DESTROY_MPT,
 				 HNS_ROCE_CMD_TIMEOUT_MSECS);
 }
 
@@ -707,10 +707,11 @@ static void hns_roce_mr_free(struct hns_roce_dev *hr_dev,
 	int ret;
 
 	if (mr->enabled) {
-		ret = hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mr->key)
-					 & (hr_dev->caps.num_mtpts - 1));
+		ret = hns_roce_hw_destroy_mpt(hr_dev, NULL,
+					      key_to_hw_index(mr->key) &
+					      (hr_dev->caps.num_mtpts - 1));
 		if (ret)
-			dev_warn(dev, "HW2SW_MPT failed (%d)\n", ret);
+			dev_warn(dev, "DESTROY_MPT failed (%d)\n", ret);
 	}
 
 	if (mr->size != ~0ULL) {
@@ -763,10 +764,10 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
 		goto err_page;
 	}
 
-	ret = hns_roce_sw2hw_mpt(hr_dev, mailbox,
-				 mtpt_idx & (hr_dev->caps.num_mtpts - 1));
+	ret = hns_roce_hw_create_mpt(hr_dev, mailbox,
+				     mtpt_idx & (hr_dev->caps.num_mtpts - 1));
 	if (ret) {
-		dev_err(dev, "SW2HW_MPT failed (%d)\n", ret);
+		dev_err(dev, "CREATE_MPT failed (%d)\n", ret);
 		goto err_page;
 	}
 
@@ -1308,9 +1309,9 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
 	if (ret)
 		goto free_cmd_mbox;
 
-	ret = hns_roce_hw2sw_mpt(hr_dev, NULL, mtpt_idx);
+	ret = hns_roce_hw_destroy_mpt(hr_dev, NULL, mtpt_idx);
 	if (ret)
-		dev_warn(dev, "HW2SW_MPT failed (%d)\n", ret);
+		dev_warn(dev, "DESTROY_MPT failed (%d)\n", ret);
 
 	mr->enabled = 0;
 
@@ -1332,9 +1333,9 @@ int hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start, u64 length,
 			goto free_cmd_mbox;
 	}
 
-	ret = hns_roce_sw2hw_mpt(hr_dev, mailbox, mtpt_idx);
+	ret = hns_roce_hw_create_mpt(hr_dev, mailbox, mtpt_idx);
 	if (ret) {
-		dev_err(dev, "SW2HW_MPT failed (%d)\n", ret);
+		dev_err(dev, "CREATE_MPT failed (%d)\n", ret);
 		ib_umem_release(mr->umem);
 		goto free_cmd_mbox;
 	}
@@ -1448,10 +1449,11 @@ static void hns_roce_mw_free(struct hns_roce_dev *hr_dev,
 	int ret;
 
 	if (mw->enabled) {
-		ret = hns_roce_hw2sw_mpt(hr_dev, NULL, key_to_hw_index(mw->rkey)
-					 & (hr_dev->caps.num_mtpts - 1));
+		ret = hns_roce_hw_destroy_mpt(hr_dev, NULL,
+					      key_to_hw_index(mw->rkey) &
+					      (hr_dev->caps.num_mtpts - 1));
 		if (ret)
-			dev_warn(dev, "MW HW2SW_MPT failed (%d)\n", ret);
+			dev_warn(dev, "MW DESTROY_MPT failed (%d)\n", ret);
 
 		hns_roce_table_put(hr_dev, &hr_dev->mr_table.mtpt_table,
 				   key_to_hw_index(mw->rkey));
@@ -1487,10 +1489,10 @@ static int hns_roce_mw_enable(struct hns_roce_dev *hr_dev,
 		goto err_page;
 	}
 
-	ret = hns_roce_sw2hw_mpt(hr_dev, mailbox,
-				 mtpt_idx & (hr_dev->caps.num_mtpts - 1));
+	ret = hns_roce_hw_create_mpt(hr_dev, mailbox,
+				     mtpt_idx & (hr_dev->caps.num_mtpts - 1));
 	if (ret) {
-		dev_err(dev, "MW sw2hw_mpt failed (%d)\n", ret);
+		dev_err(dev, "MW CREATE_MPT failed (%d)\n", ret);
 		goto err_page;
 	}
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index 6f9d1d2..d275818 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -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);
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 6/9] RDMA/hns: Simplify doorbell initialization code
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (4 preceding siblings ...)
  2019-11-05 11:07 ` [PATCH v2 for-next 5/9] RDMA/hns: Replace not intuitive function/macro names Weihang Li
@ 2019-11-05 11:07 ` Weihang Li
  2019-11-05 11:08 ` [PATCH v2 for-next 7/9] RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code Weihang Li
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:07 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Lang Cheng <chenglang@huawei.com>

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

Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 266d746d..f65bd7a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -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,
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 7/9] RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (5 preceding siblings ...)
  2019-11-05 11:07 ` [PATCH v2 for-next 6/9] RDMA/hns: Simplify doorbell initialization code Weihang Li
@ 2019-11-05 11:08 ` Weihang Li
  2019-11-05 11:08 ` [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes Weihang Li
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:08 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Lang Cheng <chenglang@huawei.com>

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.

Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index f65bd7a..fdc0cd6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -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) {
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (6 preceding siblings ...)
  2019-11-05 11:08 ` [PATCH v2 for-next 7/9] RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code Weihang Li
@ 2019-11-05 11:08 ` Weihang Li
  2019-11-05 17:00   ` Leon Romanovsky
  2019-11-05 11:08 ` [PATCH v2 for-next 9/9] RDMA/hns: Modify appropriate printings Weihang Li
  2019-11-08 20:45 ` [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Jason Gunthorpe
  9 siblings, 1 reply; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:08 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Yixian Liu <liuyixian@huawei.com>

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

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
index 8c063c5..da574c2 100644
--- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
+++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
@@ -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);
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index 713df1f..699c987 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -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 */
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 577946b..6589e28 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -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 */
diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c
index 912b89b4..780c780 100644
--- a/drivers/infiniband/hw/hns/hns_roce_pd.c
+++ b/drivers/infiniband/hw/hns/hns_roce_pd.c
@@ -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)
diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index d275818..96ff782 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -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;
 	}
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 for-next 9/9] RDMA/hns: Modify appropriate printings
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (7 preceding siblings ...)
  2019-11-05 11:08 ` [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes Weihang Li
@ 2019-11-05 11:08 ` Weihang Li
  2019-11-08 20:45 ` [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Jason Gunthorpe
  9 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-05 11:08 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, linuxarm

From: Wenpeng Liang <liangwenpeng@huawei.com>

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

Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
 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(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index 699c987..e25fa19 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -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;
 	}
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index b5d196c..b9200d53 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -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;
 	}
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index ecfa875..b0e5e8b 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -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);
diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index 96ff782..a1bfa51 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -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;
 	}
 
-- 
2.8.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes
  2019-11-05 11:08 ` [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes Weihang Li
@ 2019-11-05 17:00   ` Leon Romanovsky
  2019-11-06 10:44     ` Weihang Li
  0 siblings, 1 reply; 16+ messages in thread
From: Leon Romanovsky @ 2019-11-05 17:00 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, jgg, linux-rdma, linuxarm

On Tue, Nov 05, 2019 at 07:08:01PM +0800, Weihang Li wrote:
> From: Yixian Liu <liuyixian@huawei.com>
>
> It is better to return a linux error code than define a private constant.
>
> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
> Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
> Signed-off-by: Weihang Li <liweihang@hisilicon.com>
> ---
>  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(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
> index 8c063c5..da574c2 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
> @@ -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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes
  2019-11-05 17:00   ` Leon Romanovsky
@ 2019-11-06 10:44     ` Weihang Li
  2019-11-06 15:43       ` Leon Romanovsky
  0 siblings, 1 reply; 16+ messages in thread
From: Weihang Li @ 2019-11-06 10:44 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: dledford, jgg, linux-rdma, linuxarm



On 2019/11/6 1:00, Leon Romanovsky wrote:
> On Tue, Nov 05, 2019 at 07:08:01PM +0800, Weihang Li wrote:
>> From: Yixian Liu <liuyixian@huawei.com>
>>
>> It is better to return a linux error code than define a private constant.
>>
>> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
>> Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
>> Signed-off-by: Weihang Li <liweihang@hisilicon.com>
>> ---
>>  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(-)
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
>> index 8c063c5..da574c2 100644
>> --- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
>> +++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
>> @@ -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
> 
> .
> 

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


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes
  2019-11-06 10:44     ` Weihang Li
@ 2019-11-06 15:43       ` Leon Romanovsky
  2019-11-08  8:11         ` Weihang Li
  0 siblings, 1 reply; 16+ messages in thread
From: Leon Romanovsky @ 2019-11-06 15:43 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, jgg, linux-rdma, linuxarm

On Wed, Nov 06, 2019 at 06:44:06PM +0800, Weihang Li wrote:
>
>
> On 2019/11/6 1:00, Leon Romanovsky wrote:
> > On Tue, Nov 05, 2019 at 07:08:01PM +0800, Weihang Li wrote:
> >> From: Yixian Liu <liuyixian@huawei.com>
> >>
> >> It is better to return a linux error code than define a private constant.
> >>
> >> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
> >> Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
> >> Signed-off-by: Weihang Li <liweihang@hisilicon.com>
> >> ---
> >>  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(-)
> >>
> >> diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
> >> index 8c063c5..da574c2 100644
> >> --- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
> >> +++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
> >> @@ -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
> >
> > .
> >
>
> 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.

>
> 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

>
> Thanks,
> Weihang
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes
  2019-11-06 15:43       ` Leon Romanovsky
@ 2019-11-08  8:11         ` Weihang Li
  0 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-08  8:11 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: dledford, jgg, linux-rdma, linuxarm



On 2019/11/6 23:43, Leon Romanovsky wrote:
> On Wed, Nov 06, 2019 at 06:44:06PM +0800, Weihang Li wrote:
>>
>>
>> On 2019/11/6 1:00, Leon Romanovsky wrote:
>>> On Tue, Nov 05, 2019 at 07:08:01PM +0800, Weihang Li wrote:
>>>> From: Yixian Liu <liuyixian@huawei.com>
>>>>
>>>> It is better to return a linux error code than define a private constant.
>>>>
>>>> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
>>>> Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
>>>> Signed-off-by: Weihang Li <liweihang@hisilicon.com>
>>>> ---
>>>>  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(-)
>>>>
>>>> diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
>>>> index 8c063c5..da574c2 100644
>>>> --- a/drivers/infiniband/hw/hns/hns_roce_alloc.c
>>>> +++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
>>>> @@ -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
>>>
>>> .
>>>
>>
>> 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.

> 
>>
>> 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
> 
>>
>> Thanks,
>> Weihang
>>
> 
> .
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08
  2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
                   ` (8 preceding siblings ...)
  2019-11-05 11:08 ` [PATCH v2 for-next 9/9] RDMA/hns: Modify appropriate printings Weihang Li
@ 2019-11-08 20:45 ` Jason Gunthorpe
  2019-11-09  2:18   ` Weihang Li
  9 siblings, 1 reply; 16+ messages in thread
From: Jason Gunthorpe @ 2019-11-08 20:45 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, linux-rdma, linuxarm

On Tue, Nov 05, 2019 at 07:07:53PM +0800, Weihang Li wrote:
> 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

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08
  2019-11-08 20:45 ` [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Jason Gunthorpe
@ 2019-11-09  2:18   ` Weihang Li
  0 siblings, 0 replies; 16+ messages in thread
From: Weihang Li @ 2019-11-09  2:18 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: dledford, linux-rdma, linuxarm



On 2019/11/9 4:45, Jason Gunthorpe wrote:
> On Tue, Nov 05, 2019 at 07:07:53PM +0800, Weihang Li wrote:
>> 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
> 
> 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

> Thanks,
> Jason
> 
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, back to index

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 11:07 [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Weihang Li
2019-11-05 11:07 ` [PATCH v2 for-next 1/9] RDMA/hns: Delete unnecessary variable max_post Weihang Li
2019-11-05 11:07 ` [PATCH v2 for-next 2/9] RDMA/hns: Remove unnecessary structure hns_roce_sqp Weihang Li
2019-11-05 11:07 ` [PATCH v2 for-next 3/9] RDMA/hns: Delete unnecessary uar from hns_roce_cq Weihang Li
2019-11-05 11:07 ` [PATCH v2 for-next 4/9] RDMA/hns: Modify fields of struct hns_roce_srq Weihang Li
2019-11-05 11:07 ` [PATCH v2 for-next 5/9] RDMA/hns: Replace not intuitive function/macro names Weihang Li
2019-11-05 11:07 ` [PATCH v2 for-next 6/9] RDMA/hns: Simplify doorbell initialization code Weihang Li
2019-11-05 11:08 ` [PATCH v2 for-next 7/9] RDMA/hns: Modify hns_roce_hw_v2_get_cfg to simplify the code Weihang Li
2019-11-05 11:08 ` [PATCH v2 for-next 8/9] RDMA/hns: Fix non-standard error codes Weihang Li
2019-11-05 17:00   ` Leon Romanovsky
2019-11-06 10:44     ` Weihang Li
2019-11-06 15:43       ` Leon Romanovsky
2019-11-08  8:11         ` Weihang Li
2019-11-05 11:08 ` [PATCH v2 for-next 9/9] RDMA/hns: Modify appropriate printings Weihang Li
2019-11-08 20:45 ` [PATCH v2 for-next 0/9] RDMA/hns: Cleanups for hip08 Jason Gunthorpe
2019-11-09  2:18   ` Weihang Li

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git