* [PATCH for-next 0/9] Fixes for hip08 driver
@ 2019-08-21 13:14 Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 Lijun Ou
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
Here optimizes some codes and removes some warnings
by sparse tool checking as well as fixes some defects.
Lang Cheng (3):
RDMA/hns: Modify the data structure of hns_roce_av
RDMA/hns: Fix cast from or to restricted __le32 for driver
RDMA/hns: Add reset process for function-clear
Lijun Ou (3):
RDMA/hns: Refactor the codes of creating qp
RDMA/hns: Remove the some magic number
RDMA/hns: Fix wrong assignment of qp_access_flags
Wenpeng Liang (2):
RDMA/hns: Remove if-else judgment statements for creating srq
RDMA/hns: Delete the not-used lines
Yixian Liu (1):
RDMA/hns: Refactor cmd init and mode selection for hip08
drivers/infiniband/hw/hns/hns_roce_ah.c | 23 +--
drivers/infiniband/hw/hns/hns_roce_cmd.c | 14 +-
drivers/infiniband/hw/hns/hns_roce_device.h | 17 +-
drivers/infiniband/hw/hns/hns_roce_hem.c | 34 ++--
drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 49 +++---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 256 +++++++++++++++++++---------
drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 5 +-
drivers/infiniband/hw/hns/hns_roce_main.c | 18 +-
drivers/infiniband/hw/hns/hns_roce_mr.c | 7 +-
drivers/infiniband/hw/hns/hns_roce_qp.c | 108 +++++++-----
drivers/infiniband/hw/hns/hns_roce_srq.c | 30 +---
11 files changed, 314 insertions(+), 247 deletions(-)
--
2.8.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 17:19 ` Leon Romanovsky
2019-08-21 13:14 ` [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp Lijun Ou
` (8 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
From: Yixian Liu <liuyixian@huawei.com>
This patch refactor the initialization of cmd, and also for the cmd
mode selection on event and poll mode.
Signed-off-by: Yixian Liu <liuyixian@huawei.com>
Signed-off-by: Lang Chen <chenglang@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_cmd.c | 14 ++++----------
drivers/infiniband/hw/hns/hns_roce_main.c | 18 ++++++++----------
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c
index ade26fa..547002f 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
@@ -251,23 +251,17 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev)
hr_cmd->token_mask = CMD_TOKEN_MASK;
hr_cmd->use_events = 1;
- down(&hr_cmd->poll_sem);
-
return 0;
}
void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev)
{
struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
- int i;
-
- hr_cmd->use_events = 0;
- for (i = 0; i < hr_cmd->max_cmds; ++i)
- down(&hr_cmd->event_sem);
-
- kfree(hr_cmd->context);
- up(&hr_cmd->poll_sem);
+ if (hr_cmd->use_events) {
+ kfree(hr_cmd->context);
+ hr_cmd->use_events = 0;
+ }
}
struct hns_roce_cmd_mailbox
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index 1b757cc..f3b2f67 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -902,6 +902,7 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
goto error_failed_cmd_init;
}
+ /* EQ depends on poll mode, event mode depends on EQ */
ret = hr_dev->hw->init_eq(hr_dev);
if (ret) {
dev_err(dev, "eq init failed!\n");
@@ -911,8 +912,9 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
if (hr_dev->cmd_mod) {
ret = hns_roce_cmd_use_events(hr_dev);
if (ret) {
- dev_err(dev, "Switch to event-driven cmd failed!\n");
- goto error_failed_use_event;
+ dev_warn(dev,
+ "Cmd event mode failed, set back to poll!\n");
+ hns_roce_cmd_use_polling(hr_dev);
}
}
@@ -928,12 +930,10 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
goto error_failed_setup_hca;
}
- if (hr_dev->hw->hw_init) {
- ret = hr_dev->hw->hw_init(hr_dev);
- if (ret) {
- dev_err(dev, "hw_init failed!\n");
- goto error_failed_engine_init;
- }
+ ret = hr_dev->hw->hw_init(hr_dev);
+ if (ret) {
+ dev_err(dev, "hw_init failed!\n");
+ goto error_failed_engine_init;
}
ret = hns_roce_register_device(hr_dev);
@@ -955,8 +955,6 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
error_failed_init_hem:
if (hr_dev->cmd_mod)
hns_roce_cmd_use_polling(hr_dev);
-
-error_failed_use_event:
hr_dev->hw->cleanup_eq(hr_dev);
error_failed_eq_table:
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-28 15:19 ` Doug Ledford
2019-08-21 13:14 ` [PATCH for-next 3/9] RDMA/hns: Modify the data structure of hns_roce_av Lijun Ou
` (7 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
Here packages the codes of allocating receive rq inline buffer
in hns_roce_create_qp_common function in order to reduce the
complexity.
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_qp.c | 100 +++++++++++++++++++-------------
1 file changed, 61 insertions(+), 39 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index ec6b5dd..7e10820 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -635,6 +635,55 @@ static int hns_roce_qp_has_rq(struct ib_qp_init_attr *attr)
return 1;
}
+static int hns_roce_alloc_recv_inline_buffer(struct hns_roce_qp *hr_qp,
+ struct ib_qp_init_attr *init_attr)
+{
+ int ret;
+ int i;
+
+ /* allocate recv inline buf */
+ hr_qp->rq_inl_buf.wqe_list = kcalloc(hr_qp->rq.wqe_cnt,
+ sizeof(struct hns_roce_rinl_wqe),
+ GFP_KERNEL);
+ if (!hr_qp->rq_inl_buf.wqe_list) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ hr_qp->rq_inl_buf.wqe_cnt = hr_qp->rq.wqe_cnt;
+
+ /* Firstly, allocate a list of sge space buffer */
+ hr_qp->rq_inl_buf.wqe_list[0].sg_list =
+ kcalloc(hr_qp->rq_inl_buf.wqe_cnt,
+ init_attr->cap.max_recv_sge *
+ sizeof(struct hns_roce_rinl_sge),
+ GFP_KERNEL);
+ if (!hr_qp->rq_inl_buf.wqe_list[0].sg_list) {
+ ret = -ENOMEM;
+ goto err_wqe_list;
+ }
+
+ for (i = 1; i < hr_qp->rq_inl_buf.wqe_cnt; i++)
+ /* Secondly, reallocate the buffer */
+ hr_qp->rq_inl_buf.wqe_list[i].sg_list =
+ &hr_qp->rq_inl_buf.wqe_list[0].sg_list[i *
+ init_attr->cap.max_recv_sge];
+
+ return 0;
+
+err_wqe_list:
+ kfree(hr_qp->rq_inl_buf.wqe_list);
+
+err:
+ return ret;
+}
+
+static void hns_roce_free_recv_inline_buffer(struct hns_roce_qp *hr_qp)
+{
+ kfree(hr_qp->rq_inl_buf.wqe_list[0].sg_list);
+ kfree(hr_qp->rq_inl_buf.wqe_list);
+}
+
static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
struct ib_pd *ib_pd,
struct ib_qp_init_attr *init_attr,
@@ -676,33 +725,11 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) &&
hns_roce_qp_has_rq(init_attr)) {
- /* allocate recv inline buf */
- hr_qp->rq_inl_buf.wqe_list = kcalloc(hr_qp->rq.wqe_cnt,
- sizeof(struct hns_roce_rinl_wqe),
- GFP_KERNEL);
- if (!hr_qp->rq_inl_buf.wqe_list) {
- ret = -ENOMEM;
+ ret = hns_roce_alloc_recv_inline_buffer(hr_qp, init_attr);
+ if (ret) {
+ dev_err(dev, "allocate receive inline buffer failed\n");
goto err_out;
}
-
- hr_qp->rq_inl_buf.wqe_cnt = hr_qp->rq.wqe_cnt;
-
- /* Firstly, allocate a list of sge space buffer */
- hr_qp->rq_inl_buf.wqe_list[0].sg_list =
- kcalloc(hr_qp->rq_inl_buf.wqe_cnt,
- init_attr->cap.max_recv_sge *
- sizeof(struct hns_roce_rinl_sge),
- GFP_KERNEL);
- if (!hr_qp->rq_inl_buf.wqe_list[0].sg_list) {
- ret = -ENOMEM;
- goto err_wqe_list;
- }
-
- for (i = 1; i < hr_qp->rq_inl_buf.wqe_cnt; i++)
- /* Secondly, reallocate the buffer */
- hr_qp->rq_inl_buf.wqe_list[i].sg_list =
- &hr_qp->rq_inl_buf.wqe_list[0].sg_list[i *
- init_attr->cap.max_recv_sge];
}
page_shift = PAGE_SHIFT + hr_dev->caps.mtt_buf_pg_sz;
@@ -710,14 +737,14 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
dev_err(dev, "ib_copy_from_udata error for create qp\n");
ret = -EFAULT;
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
ret = hns_roce_set_user_sq_size(hr_dev, &init_attr->cap, hr_qp,
&ucmd);
if (ret) {
dev_err(dev, "hns_roce_set_user_sq_size error for create qp\n");
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
hr_qp->umem = ib_umem_get(udata, ucmd.buf_addr,
@@ -725,7 +752,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
if (IS_ERR(hr_qp->umem)) {
dev_err(dev, "ib_umem_get error for create qp\n");
ret = PTR_ERR(hr_qp->umem);
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
hr_qp->region_cnt = split_wqe_buf_region(hr_dev, hr_qp,
hr_qp->regions, ARRAY_SIZE(hr_qp->regions),
@@ -786,13 +813,13 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) {
dev_err(dev, "init_attr->create_flags error!\n");
ret = -EINVAL;
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO) {
dev_err(dev, "init_attr->create_flags error!\n");
ret = -EINVAL;
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
/* Set SQ size */
@@ -800,7 +827,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
hr_qp);
if (ret) {
dev_err(dev, "hns_roce_set_kernel_sq_size error!\n");
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
/* QP doorbell register address */
@@ -814,7 +841,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
ret = hns_roce_alloc_db(hr_dev, &hr_qp->rdb, 0);
if (ret) {
dev_err(dev, "rq record doorbell alloc failed!\n");
- goto err_rq_sge_list;
+ goto err_alloc_recv_inline_buffer;
}
*hr_qp->rdb.db_record = 0;
hr_qp->rdb_en = 1;
@@ -980,15 +1007,10 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB))
hns_roce_free_db(hr_dev, &hr_qp->rdb);
-err_rq_sge_list:
- if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) &&
- hns_roce_qp_has_rq(init_attr))
- kfree(hr_qp->rq_inl_buf.wqe_list[0].sg_list);
-
-err_wqe_list:
+err_alloc_recv_inline_buffer:
if ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) &&
hns_roce_qp_has_rq(init_attr))
- kfree(hr_qp->rq_inl_buf.wqe_list);
+ hns_roce_free_recv_inline_buffer(hr_qp);
err_out:
return ret;
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 3/9] RDMA/hns: Modify the data structure of hns_roce_av
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 4/9] RDMA/hns: Remove the some magic number Lijun Ou
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
From: Lang Cheng <chenglang@huawei.com>
we change type of some members to u32/u8 from __le32 as well as
split sl_tclass_flowlabel into three variables in hns_roce_av.
Signed-off-by: Lang Cheng <chenglang@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_ah.c | 23 +++++++----------------
drivers/infiniband/hw/hns/hns_roce_device.h | 8 +++++---
drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 9 +++------
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 9 +++------
4 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c
index cdd2ac2..90e08c0 100644
--- a/drivers/infiniband/hw/hns/hns_roce_ah.c
+++ b/drivers/infiniband/hw/hns/hns_roce_ah.c
@@ -66,11 +66,9 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr,
HNS_ROCE_VLAN_SL_SHIFT;
}
- ah->av.port_pd = cpu_to_le32(to_hr_pd(ibah->pd)->pdn |
- (rdma_ah_get_port_num(ah_attr) <<
- HNS_ROCE_PORT_NUM_SHIFT));
+ ah->av.port = rdma_ah_get_port_num(ah_attr);
ah->av.gid_index = grh->sgid_index;
- ah->av.vlan = cpu_to_le16(vlan_tag);
+ ah->av.vlan = vlan_tag;
ah->av.vlan_en = vlan_en;
dev_dbg(dev, "gid_index = 0x%x,vlan = 0x%x\n", ah->av.gid_index,
ah->av.vlan);
@@ -79,8 +77,7 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr,
ah->av.stat_rate = IB_RATE_10_GBPS;
memcpy(ah->av.dgid, grh->dgid.raw, HNS_ROCE_GID_SIZE);
- ah->av.sl_tclass_flowlabel = cpu_to_le32(rdma_ah_get_sl(ah_attr) <<
- HNS_ROCE_SL_SHIFT);
+ ah->av.sl = rdma_ah_get_sl(ah_attr);
return 0;
}
@@ -91,17 +88,11 @@ int hns_roce_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
memset(ah_attr, 0, sizeof(*ah_attr));
- rdma_ah_set_sl(ah_attr, (le32_to_cpu(ah->av.sl_tclass_flowlabel) >>
- HNS_ROCE_SL_SHIFT));
- rdma_ah_set_port_num(ah_attr, (le32_to_cpu(ah->av.port_pd) >>
- HNS_ROCE_PORT_NUM_SHIFT));
+ rdma_ah_set_sl(ah_attr, ah->av.sl);
+ rdma_ah_set_port_num(ah_attr, ah->av.port);
rdma_ah_set_static_rate(ah_attr, ah->av.stat_rate);
- rdma_ah_set_grh(ah_attr, NULL,
- (le32_to_cpu(ah->av.sl_tclass_flowlabel) &
- HNS_ROCE_FLOW_LABEL_MASK), ah->av.gid_index,
- ah->av.hop_limit,
- (le32_to_cpu(ah->av.sl_tclass_flowlabel) >>
- HNS_ROCE_TCLASS_SHIFT));
+ rdma_ah_set_grh(ah_attr, NULL, ah->av.flowlabel,
+ ah->av.gid_index, ah->av.hop_limit, ah->av.tclass);
rdma_ah_set_dgid_raw(ah_attr, ah->av.dgid);
return 0;
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index c7bf738..011e038 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -568,14 +568,16 @@ struct hns_roce_raq_table {
};
struct hns_roce_av {
- __le32 port_pd;
+ u8 port;
u8 gid_index;
u8 stat_rate;
u8 hop_limit;
- __le32 sl_tclass_flowlabel;
+ u32 flowlabel;
+ u8 sl;
+ u8 tclass;
u8 dgid[HNS_ROCE_GID_SIZE];
u8 mac[ETH_ALEN];
- __le16 vlan;
+ u16 vlan;
bool vlan_en;
};
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 0ff5f96..d5be11a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -175,13 +175,11 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
roce_set_field(ud_sq_wqe->u32_36,
UD_SEND_WQE_U32_36_FLOW_LABEL_M,
UD_SEND_WQE_U32_36_FLOW_LABEL_S,
- ah->av.sl_tclass_flowlabel &
- HNS_ROCE_FLOW_LABEL_MASK);
+ ah->av.flowlabel);
roce_set_field(ud_sq_wqe->u32_36,
UD_SEND_WQE_U32_36_PRIORITY_M,
UD_SEND_WQE_U32_36_PRIORITY_S,
- le32_to_cpu(ah->av.sl_tclass_flowlabel) >>
- HNS_ROCE_SL_SHIFT);
+ ah->av.sl);
roce_set_field(ud_sq_wqe->u32_36,
UD_SEND_WQE_U32_36_SGID_INDEX_M,
UD_SEND_WQE_U32_36_SGID_INDEX_S,
@@ -195,8 +193,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
roce_set_field(ud_sq_wqe->u32_40,
UD_SEND_WQE_U32_40_TRAFFIC_CLASS_M,
UD_SEND_WQE_U32_40_TRAFFIC_CLASS_S,
- ah->av.sl_tclass_flowlabel >>
- HNS_ROCE_TCLASS_SHIFT);
+ ah->av.tclass);
memcpy(&ud_sq_wqe->dgid[0], &ah->av.dgid[0], GID_LEN);
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 206dfdb..67e56b8 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -397,18 +397,15 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
roce_set_field(ud_sq_wqe->byte_36,
V2_UD_SEND_WQE_BYTE_36_TCLASS_M,
V2_UD_SEND_WQE_BYTE_36_TCLASS_S,
- ah->av.sl_tclass_flowlabel >>
- HNS_ROCE_TCLASS_SHIFT);
+ ah->av.tclass);
roce_set_field(ud_sq_wqe->byte_40,
V2_UD_SEND_WQE_BYTE_40_FLOW_LABEL_M,
V2_UD_SEND_WQE_BYTE_40_FLOW_LABEL_S,
- ah->av.sl_tclass_flowlabel &
- HNS_ROCE_FLOW_LABEL_MASK);
+ ah->av.flowlabel);
roce_set_field(ud_sq_wqe->byte_40,
V2_UD_SEND_WQE_BYTE_40_SL_M,
V2_UD_SEND_WQE_BYTE_40_SL_S,
- le32_to_cpu(ah->av.sl_tclass_flowlabel) >>
- HNS_ROCE_SL_SHIFT);
+ ah->av.sl);
roce_set_field(ud_sq_wqe->byte_40,
V2_UD_SEND_WQE_BYTE_40_PORTN_M,
V2_UD_SEND_WQE_BYTE_40_PORTN_S,
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 4/9] RDMA/hns: Remove the some magic number
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (2 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 3/9] RDMA/hns: Modify the data structure of hns_roce_av Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 5/9] RDMA/hns: Fix cast from or to restricted __le32 for driver Lijun Ou
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
Here uses the meaningful macro instead of the magic number
for readability.
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Lang Chen <chenglang@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_device.h | 5 +++++
drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 3 ++-
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++--
drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 3 ++-
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 011e038..5eb7134 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -127,6 +127,11 @@
#define HNS_ROCE_IDX_QUE_ENTRY_SZ 4
#define SRQ_DB_REG 0x230
+/* The chip implementation of the consumer index is calculated
+ * according to twice the actual EQ depth
+ */
+#define EQ_DEPTH_COEFF 2
+
enum {
HNS_ROCE_SUPPORT_RQ_RECORD_DB = 1 << 0,
HNS_ROCE_SUPPORT_SQ_RECORD_DB = 1 << 1,
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index d5be11a..73d17a3 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -4016,7 +4016,8 @@ static int hns_roce_v1_ceq_int(struct hns_roce_dev *hr_dev,
++eq->cons_index;
ceqes_found = 1;
- if (eq->cons_index > 2 * hr_dev->caps.ceqe_depth - 1) {
+ if (eq->cons_index >
+ EQ_DEPTH_COEFF * hr_dev->caps.ceqe_depth - 1) {
dev_warn(&eq->hr_dev->pdev->dev,
"cons_index overflow, set back to 0.\n");
eq->cons_index = 0;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 67e56b8..d4c4c41 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5084,7 +5084,7 @@ static int hns_roce_v2_ceq_int(struct hns_roce_dev *hr_dev,
++eq->cons_index;
ceqe_found = 1;
- if (eq->cons_index > (2 * eq->entries - 1)) {
+ if (eq->cons_index > (EQ_DEPTH_COEFF * eq->entries - 1)) {
dev_warn(dev, "cons_index overflow, set back to 0.\n");
eq->cons_index = 0;
}
@@ -6501,7 +6501,7 @@ static int hns_roce_hw_v2_reset_notify_uninit(struct hnae3_handle *handle)
handle->rinfo.reset_state = HNS_ROCE_STATE_RST_UNINIT;
dev_info(&handle->pdev->dev, "In reset process RoCE client uninit.\n");
- msleep(100);
+ msleep(HNS_ROCE_V2_HW_RST_UNINT_DELAY);
__hns_roce_hw_v2_uninit_instance(handle, false);
return 0;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 58931b5..1301629 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -96,7 +96,8 @@
#define HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE 2
#define HNS_ROCE_V2_RSV_QPS 8
-#define HNS_ROCE_V2_HW_RST_TIMEOUT 1000
+#define HNS_ROCE_V2_HW_RST_TIMEOUT 1000
+#define HNS_ROCE_V2_HW_RST_UNINT_DELAY 100
#define HNS_ROCE_CONTEXT_HOP_NUM 1
#define HNS_ROCE_SCCC_HOP_NUM 1
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 5/9] RDMA/hns: Fix cast from or to restricted __le32 for driver
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (3 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 4/9] RDMA/hns: Remove the some magic number Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 6/9] RDMA/hns: Add reset process for function-clear Lijun Ou
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
From: Lang Cheng <chenglang@huawei.com>
Sparse is whining about the u32 and __le32 mixed usage in the driver.
The roce_set_field() is used to __le32 data of hardware only.
If a variable is not delivered to the hardware, the __le32 type and
related operations are not required.
Signed-off-by: Lang Cheng <chenglang@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_device.h | 4 +-
drivers/infiniband/hw/hns/hns_roce_hem.c | 34 +++----
drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 37 ++++----
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 141 ++++++++++++++--------------
drivers/infiniband/hw/hns/hns_roce_mr.c | 7 +-
drivers/infiniband/hw/hns/hns_roce_qp.c | 8 +-
6 files changed, 105 insertions(+), 126 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index 5eb7134..96d1302 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -657,7 +657,7 @@ struct hns_roce_qp {
u8 rdb_en;
u8 sdb_en;
u32 doorbell_qpn;
- __le32 sq_signal_bits;
+ u32 sq_signal_bits;
u32 sq_next_wqe;
struct hns_roce_wq sq;
@@ -712,7 +712,7 @@ enum {
};
struct hns_roce_ceqe {
- u32 comp;
+ __le32 comp;
};
struct hns_roce_aeqe {
diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c
index f2c4fef..e822157 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hem.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
@@ -368,9 +368,9 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
unsigned long flags;
struct hns_roce_hem_iter iter;
void __iomem *bt_cmd;
- u32 bt_cmd_h_val = 0;
- u32 bt_cmd_val[2];
- u32 bt_cmd_l = 0;
+ __le32 bt_cmd_val[2];
+ __le32 bt_cmd_h = 0;
+ __le32 bt_cmd_l = 0;
u64 bt_ba = 0;
int ret = 0;
@@ -380,30 +380,20 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
switch (table->type) {
case HEM_TYPE_QPC:
- roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_QPC);
- break;
case HEM_TYPE_MTPT:
- roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S,
- HEM_TYPE_MTPT);
- break;
case HEM_TYPE_CQC:
- roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_CQC);
- break;
case HEM_TYPE_SRQC:
- roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S,
- HEM_TYPE_SRQC);
+ roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
+ ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, table->type);
break;
default:
return ret;
}
- roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
+
+ roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj);
- roce_set_bit(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0);
- roce_set_bit(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_HW_SYNS_S, 1);
+ roce_set_bit(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0);
+ roce_set_bit(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_HW_SYNS_S, 1);
/* Currently iter only a chunk */
for (hns_roce_hem_first(table->hem[i], &iter);
@@ -429,13 +419,13 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
return -EBUSY;
}
- bt_cmd_l = (u32)bt_ba;
- roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M,
+ bt_cmd_l = cpu_to_le32(bt_ba);
+ roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S,
bt_ba >> BT_BA_SHIFT);
bt_cmd_val[0] = bt_cmd_l;
- bt_cmd_val[1] = bt_cmd_h_val;
+ bt_cmd_val[1] = bt_cmd_h;
hns_roce_write64_k(bt_cmd_val,
hr_dev->reg_base + ROCEE_BT_CMD_L_REG);
spin_unlock_irqrestore(lock, flags);
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 73d17a3..ec6ffe6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -73,7 +73,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
int ps_opcode = 0, i = 0;
unsigned long flags = 0;
void *wqe = NULL;
- u32 doorbell[2];
+ __le32 doorbell[2];
int nreq = 0;
u32 ind = 0;
int ret = 0;
@@ -332,10 +332,10 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
SQ_DOORBELL_U32_8_QPN_S, qp->doorbell_qpn);
roce_set_bit(sq_db.u32_8, SQ_DOORBELL_HW_SYNC_S, 1);
- doorbell[0] = le32_to_cpu(sq_db.u32_4);
- doorbell[1] = le32_to_cpu(sq_db.u32_8);
+ doorbell[0] = sq_db.u32_4;
+ doorbell[1] = sq_db.u32_8;
- hns_roce_write64_k((__le32 *)doorbell, qp->sq.db_reg_l);
+ hns_roce_write64_k(doorbell, qp->sq.db_reg_l);
qp->sq_next_wqe = ind;
}
@@ -360,7 +360,7 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
struct device *dev = &hr_dev->pdev->dev;
struct hns_roce_rq_db rq_db;
- uint32_t doorbell[2] = {0};
+ __le32 doorbell[2] = {0};
spin_lock_irqsave(&hr_qp->rq.lock, flags);
ind = hr_qp->rq.head & (hr_qp->rq.wqe_cnt - 1);
@@ -434,11 +434,10 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
roce_set_bit(rq_db.u32_8, RQ_DOORBELL_U32_8_HW_SYNC_S,
1);
- doorbell[0] = le32_to_cpu(rq_db.u32_4);
- doorbell[1] = le32_to_cpu(rq_db.u32_8);
+ doorbell[0] = rq_db.u32_4;
+ doorbell[1] = rq_db.u32_8;
- hns_roce_write64_k((__le32 *)doorbell,
- hr_qp->rq.db_reg_l);
+ hns_roce_write64_k(doorbell, hr_qp->rq.db_reg_l);
}
}
spin_unlock_irqrestore(&hr_qp->rq.lock, flags);
@@ -712,7 +711,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev)
struct ib_cq *cq;
struct ib_pd *pd;
union ib_gid dgid;
- u64 subnet_prefix;
+ __be64 subnet_prefix;
int attr_mask = 0;
int ret;
int i, j;
@@ -2160,7 +2159,7 @@ static int hns_roce_v1_req_notify_cq(struct ib_cq *ibcq,
{
struct hns_roce_cq *hr_cq = to_hr_cq(ibcq);
u32 notification_flag;
- __le32 doorbell[2];
+ __le32 doorbell[2] = {};
notification_flag = (flags & IB_CQ_SOLICITED_MASK) ==
IB_CQ_SOLICITED ? CQ_DB_REQ_NOT : CQ_DB_REQ_NOT_SOL;
@@ -2435,18 +2434,12 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev,
switch (table->type) {
case HEM_TYPE_QPC:
- roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_QPC);
bt_ba = priv->bt_table.qpc_buf.map >> 12;
break;
case HEM_TYPE_MTPT:
- roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_MTPT);
bt_ba = priv->bt_table.mtpt_buf.map >> 12;
break;
case HEM_TYPE_CQC:
- roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
- ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_CQC);
bt_ba = priv->bt_table.cqc_buf.map >> 12;
break;
case HEM_TYPE_SRQC:
@@ -2455,6 +2448,8 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev,
default:
return 0;
}
+ roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
+ ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, table->type);
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj);
roce_set_bit(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0);
@@ -2479,7 +2474,7 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev,
end -= HW_SYNC_SLEEP_TIME_INTERVAL;
}
- bt_cmd_val[0] = (__le32)bt_ba;
+ bt_cmd_val[0] = cpu_to_le32(bt_ba);
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S, bt_ba >> 32);
hns_roce_write64_k(bt_cmd_val, hr_dev->reg_base + ROCEE_BT_CMD_L_REG);
@@ -2622,7 +2617,7 @@ static int hns_roce_v1_m_sqp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
QP1C_BYTES_16_PORT_NUM_S, hr_qp->phy_port);
roce_set_bit(context->qp1c_bytes_16,
QP1C_BYTES_16_SIGNALING_TYPE_S,
- le32_to_cpu(hr_qp->sq_signal_bits));
+ hr_qp->sq_signal_bits);
roce_set_bit(context->qp1c_bytes_16, QP1C_BYTES_16_RQ_BA_FLG_S,
1);
roce_set_bit(context->qp1c_bytes_16, QP1C_BYTES_16_SQ_BA_FLG_S,
@@ -2928,7 +2923,7 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
1);
roce_set_bit(context->qpc_bytes_32,
QP_CONTEXT_QPC_BYTE_32_SIGNALING_TYPE_S,
- le32_to_cpu(hr_qp->sq_signal_bits));
+ hr_qp->sq_signal_bits);
port = (attr_mask & IB_QP_PORT) ? (attr->port_num - 1) :
hr_qp->port;
@@ -3573,7 +3568,7 @@ static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
qp_attr->retry_cnt = roce_get_field(context->qpc_bytes_148,
QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_M,
QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_S);
- qp_attr->rnr_retry = (u8)context->rnr_retry;
+ qp_attr->rnr_retry = (u8)le32_to_cpu(context->rnr_retry);
done:
qp_attr->cur_qp_state = qp_attr->qp_state;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index d4c4c41..7730983 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1039,7 +1039,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
* If the command is sync, wait for the firmware to write back,
* if multi descriptors to be sent, use the first one to check
*/
- if ((desc->flag) & HNS_ROCE_CMD_FLAG_NO_INTR) {
+ if (le16_to_cpu(desc->flag) & HNS_ROCE_CMD_FLAG_NO_INTR) {
do {
if (hns_roce_cmq_csq_done(hr_dev))
break;
@@ -1056,7 +1056,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
desc_to_use = &csq->desc[ntc];
desc[handle] = *desc_to_use;
dev_dbg(hr_dev->dev, "Get cmq desc:\n");
- desc_ret = desc[handle].retval;
+ desc_ret = le16_to_cpu(desc[handle].retval);
if (desc_ret == CMD_EXEC_SUCCESS)
ret = 0;
else
@@ -1119,7 +1119,7 @@ static int hns_roce_cmq_query_hw_info(struct hns_roce_dev *hr_dev)
return ret;
resp = (struct hns_roce_query_version *)desc.data;
- hr_dev->hw_rev = le32_to_cpu(resp->rocee_hw_version);
+ hr_dev->hw_rev = le16_to_cpu(resp->rocee_hw_version);
hr_dev->vendor_id = hr_dev->pci_dev->vendor;
return 0;
@@ -1293,7 +1293,7 @@ static int hns_roce_set_vf_switch_param(struct hns_roce_dev *hr_dev,
swt = (struct hns_roce_vf_switch *)desc.data;
hns_roce_cmq_setup_basic_desc(&desc, HNS_SWITCH_PARAMETER_CFG, true);
- swt->rocee_sel |= cpu_to_le16(HNS_ICL_SWITCH_CMD_ROCEE_SEL);
+ swt->rocee_sel |= cpu_to_le32(HNS_ICL_SWITCH_CMD_ROCEE_SEL);
roce_set_field(swt->fun_id,
VF_SWITCH_DATA_FUN_ID_VF_ID_M,
VF_SWITCH_DATA_FUN_ID_VF_ID_S,
@@ -1719,9 +1719,10 @@ static int hns_roce_config_link_table(struct hns_roce_dev *hr_dev,
desc[i].flag &= ~cpu_to_le16(HNS_ROCE_CMD_FLAG_NEXT);
if (i == 0) {
- req_a->base_addr_l = link_tbl->table.map & 0xffffffff;
- req_a->base_addr_h = (link_tbl->table.map >> 32) &
- 0xffffffff;
+ req_a->base_addr_l =
+ cpu_to_le32(link_tbl->table.map & 0xffffffff);
+ req_a->base_addr_h =
+ cpu_to_le32(link_tbl->table.map >> 32);
roce_set_field(req_a->depth_pgsz_init_en,
CFG_LLM_QUE_DEPTH_M,
CFG_LLM_QUE_DEPTH_S,
@@ -1730,13 +1731,15 @@ static int hns_roce_config_link_table(struct hns_roce_dev *hr_dev,
CFG_LLM_QUE_PGSZ_M,
CFG_LLM_QUE_PGSZ_S,
link_tbl->pg_sz);
- req_a->head_ba_l = entry[0].blk_ba0;
- req_a->head_ba_h_nxtptr = entry[0].blk_ba1_nxt_ptr;
+ req_a->head_ba_l = cpu_to_le32(entry[0].blk_ba0);
+ req_a->head_ba_h_nxtptr =
+ cpu_to_le32(entry[0].blk_ba1_nxt_ptr);
roce_set_field(req_a->head_ptr,
CFG_LLM_HEAD_PTR_M,
CFG_LLM_HEAD_PTR_S, 0);
} else {
- req_b->tail_ba_l = entry[page_num - 1].blk_ba0;
+ req_b->tail_ba_l =
+ cpu_to_le32(entry[page_num - 1].blk_ba0);
roce_set_field(req_b->tail_ba_h,
CFG_LLM_TAIL_BA_H_M,
CFG_LLM_TAIL_BA_H_S,
@@ -1812,17 +1815,13 @@ static int hns_roce_init_link_table(struct hns_roce_dev *hr_dev,
link_tbl->pg_list[i].map = t;
- entry[i].blk_ba0 = (t >> 12) & 0xffffffff;
- roce_set_field(entry[i].blk_ba1_nxt_ptr,
- HNS_ROCE_LINK_TABLE_BA1_M,
- HNS_ROCE_LINK_TABLE_BA1_S,
- t >> 44);
+ entry[i].blk_ba0 = (u32)(t >> 12);
+ entry[i].blk_ba1_nxt_ptr = (u32)(t >> 44);
if (i < (pg_num - 1))
- roce_set_field(entry[i].blk_ba1_nxt_ptr,
- HNS_ROCE_LINK_TABLE_NXT_PTR_M,
- HNS_ROCE_LINK_TABLE_NXT_PTR_S,
- i + 1);
+ entry[i].blk_ba1_nxt_ptr |=
+ (i + 1) << HNS_ROCE_LINK_TABLE_NXT_PTR_S;
+
}
link_tbl->npages = pg_num;
link_tbl->pg_sz = buf_chk_sz;
@@ -1947,7 +1946,7 @@ static int hns_roce_query_mbox_status(struct hns_roce_dev *hr_dev)
if (status)
return status;
- return cpu_to_le32(mb_st->mb_status_hw_run);
+ return le32_to_cpu(mb_st->mb_status_hw_run);
}
static int hns_roce_v2_cmd_pending(struct hns_roce_dev *hr_dev)
@@ -1973,10 +1972,10 @@ static int hns_roce_mbox_post(struct hns_roce_dev *hr_dev, u64 in_param,
hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_POST_MB, false);
- mb->in_param_l = cpu_to_le64(in_param);
- mb->in_param_h = cpu_to_le64(in_param) >> 32;
- mb->out_param_l = cpu_to_le64(out_param);
- mb->out_param_h = cpu_to_le64(out_param) >> 32;
+ mb->in_param_l = cpu_to_le32(in_param);
+ mb->in_param_h = cpu_to_le32(in_param >> 32);
+ mb->out_param_l = cpu_to_le32(out_param);
+ mb->out_param_h = cpu_to_le32(out_param >> 32);
mb->cmd_tag = cpu_to_le32(in_modifier << 8 | op);
mb->token_event_en = cpu_to_le32(event << 16 | token);
@@ -2118,7 +2117,7 @@ static int hns_roce_v2_set_mac(struct hns_roce_dev *hr_dev, u8 phy_port,
roce_set_field(smac_tb->vf_smac_h_rsv,
CFG_SMAC_TB_VF_SMAC_H_M,
CFG_SMAC_TB_VF_SMAC_H_S, reg_smac_h);
- smac_tb->vf_smac_l = reg_smac_l;
+ smac_tb->vf_smac_l = cpu_to_le32(reg_smac_l);
return hns_roce_cmq_send(hr_dev, &desc, 1);
}
@@ -2473,29 +2472,26 @@ static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev,
V2_CQC_BYTE_4_SHIFT_S, ilog2((unsigned int)nent));
roce_set_field(cq_context->byte_4_pg_ceqn, V2_CQC_BYTE_4_CEQN_M,
V2_CQC_BYTE_4_CEQN_S, vector);
- cq_context->byte_4_pg_ceqn = cpu_to_le32(cq_context->byte_4_pg_ceqn);
roce_set_field(cq_context->byte_8_cqn, V2_CQC_BYTE_8_CQN_M,
V2_CQC_BYTE_8_CQN_S, hr_cq->cqn);
- cq_context->cqe_cur_blk_addr = (u32)(mtts[0] >> PAGE_ADDR_SHIFT);
- cq_context->cqe_cur_blk_addr =
- cpu_to_le32(cq_context->cqe_cur_blk_addr);
+ cq_context->cqe_cur_blk_addr = cpu_to_le32(mtts[0] >> PAGE_ADDR_SHIFT);
roce_set_field(cq_context->byte_16_hop_addr,
V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_M,
V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_S,
- cpu_to_le32((mtts[0]) >> (32 + PAGE_ADDR_SHIFT)));
+ mtts[0] >> (32 + PAGE_ADDR_SHIFT));
roce_set_field(cq_context->byte_16_hop_addr,
V2_CQC_BYTE_16_CQE_HOP_NUM_M,
V2_CQC_BYTE_16_CQE_HOP_NUM_S, hr_dev->caps.cqe_hop_num ==
HNS_ROCE_HOP_NUM_0 ? 0 : hr_dev->caps.cqe_hop_num);
- cq_context->cqe_nxt_blk_addr = (u32)(mtts[1] >> PAGE_ADDR_SHIFT);
+ cq_context->cqe_nxt_blk_addr = cpu_to_le32(mtts[1] >> PAGE_ADDR_SHIFT);
roce_set_field(cq_context->byte_24_pgsz_addr,
V2_CQC_BYTE_24_CQE_NXT_BLK_ADDR_M,
V2_CQC_BYTE_24_CQE_NXT_BLK_ADDR_S,
- cpu_to_le32((mtts[1]) >> (32 + PAGE_ADDR_SHIFT)));
+ mtts[1] >> (32 + PAGE_ADDR_SHIFT));
roce_set_field(cq_context->byte_24_pgsz_addr,
V2_CQC_BYTE_24_CQE_BA_PG_SZ_M,
V2_CQC_BYTE_24_CQE_BA_PG_SZ_S,
@@ -2505,7 +2501,7 @@ static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev,
V2_CQC_BYTE_24_CQE_BUF_PG_SZ_S,
hr_dev->caps.cqe_buf_pg_sz + PG_SHIFT_OFFSET);
- cq_context->cqe_ba = (u32)(dma_handle >> 3);
+ cq_context->cqe_ba = cpu_to_le32(dma_handle >> 3);
roce_set_field(cq_context->byte_40_cqe_ba, V2_CQC_BYTE_40_CQE_BA_M,
V2_CQC_BYTE_40_CQE_BA_S, (dma_handle >> (32 + 3)));
@@ -2518,7 +2514,7 @@ static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev,
V2_CQC_BYTE_44_DB_RECORD_ADDR_M,
V2_CQC_BYTE_44_DB_RECORD_ADDR_S,
((u32)hr_cq->db.dma) >> 1);
- cq_context->db_record_addr = hr_cq->db.dma >> 32;
+ cq_context->db_record_addr = cpu_to_le32(hr_cq->db.dma >> 32);
roce_set_field(cq_context->byte_56_cqe_period_maxcnt,
V2_CQC_BYTE_56_CQ_MAX_CNT_M,
@@ -2536,7 +2532,7 @@ static int hns_roce_v2_req_notify_cq(struct ib_cq *ibcq,
struct hns_roce_dev *hr_dev = to_hr_dev(ibcq->device);
struct hns_roce_cq *hr_cq = to_hr_cq(ibcq);
u32 notification_flag;
- u32 doorbell[2];
+ __le32 doorbell[2];
doorbell[0] = 0;
doorbell[1] = 0;
@@ -2663,9 +2659,9 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *hr_cq,
++wq->tail;
} else if ((*cur_qp)->ibqp.srq) {
srq = to_hr_srq((*cur_qp)->ibqp.srq);
- wqe_ctr = le16_to_cpu(roce_get_field(cqe->byte_4,
- V2_CQE_BYTE_4_WQE_INDX_M,
- V2_CQE_BYTE_4_WQE_INDX_S));
+ wqe_ctr = (u16)roce_get_field(cqe->byte_4,
+ V2_CQE_BYTE_4_WQE_INDX_M,
+ V2_CQE_BYTE_4_WQE_INDX_S);
wc->wr_id = srq->wrid[wqe_ctr];
hns_roce_free_srq_wqe(srq, wqe_ctr);
} else {
@@ -3240,7 +3236,7 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp,
roce_set_field(qpc_mask->byte_68_rq_db,
V2_QPC_BYTE_68_RQ_DB_RECORD_ADDR_M,
V2_QPC_BYTE_68_RQ_DB_RECORD_ADDR_S, 0);
- context->rq_db_record_addr = hr_qp->rdb.dma >> 32;
+ context->rq_db_record_addr = cpu_to_le32(hr_qp->rdb.dma >> 32);
qpc_mask->rq_db_record_addr = 0;
roce_set_bit(context->byte_76_srqn_op_en, V2_QPC_BYTE_76_RQIE_S,
@@ -3623,7 +3619,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
}
dmac = (u8 *)attr->ah_attr.roce.dmac;
- context->wqe_sge_ba = (u32)(wqe_sge_ba >> 3);
+ context->wqe_sge_ba = cpu_to_le32(wqe_sge_ba >> 3);
qpc_mask->wqe_sge_ba = 0;
/*
@@ -3679,7 +3675,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
V2_QPC_BYTE_16_WQE_SGE_BUF_PG_SZ_M,
V2_QPC_BYTE_16_WQE_SGE_BUF_PG_SZ_S, 0);
- context->rq_cur_blk_addr = (u32)(mtts[0] >> PAGE_ADDR_SHIFT);
+ context->rq_cur_blk_addr = cpu_to_le32(mtts[0] >> PAGE_ADDR_SHIFT);
qpc_mask->rq_cur_blk_addr = 0;
roce_set_field(context->byte_92_srq_info,
@@ -3690,7 +3686,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
V2_QPC_BYTE_92_RQ_CUR_BLK_ADDR_M,
V2_QPC_BYTE_92_RQ_CUR_BLK_ADDR_S, 0);
- context->rq_nxt_blk_addr = (u32)(mtts[1] >> PAGE_ADDR_SHIFT);
+ context->rq_nxt_blk_addr = cpu_to_le32(mtts[1] >> PAGE_ADDR_SHIFT);
qpc_mask->rq_nxt_blk_addr = 0;
roce_set_field(context->byte_104_rq_sge,
@@ -3705,7 +3701,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
V2_QPC_BYTE_132_TRRL_BA_S, dma_handle_3 >> 4);
roce_set_field(qpc_mask->byte_132_trrl, V2_QPC_BYTE_132_TRRL_BA_M,
V2_QPC_BYTE_132_TRRL_BA_S, 0);
- context->trrl_ba = (u32)(dma_handle_3 >> (16 + 4));
+ context->trrl_ba = cpu_to_le32(dma_handle_3 >> (16 + 4));
qpc_mask->trrl_ba = 0;
roce_set_field(context->byte_140_raq, V2_QPC_BYTE_140_TRRL_BA_M,
V2_QPC_BYTE_140_TRRL_BA_S,
@@ -3713,7 +3709,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
roce_set_field(qpc_mask->byte_140_raq, V2_QPC_BYTE_140_TRRL_BA_M,
V2_QPC_BYTE_140_TRRL_BA_S, 0);
- context->irrl_ba = (u32)(dma_handle_2 >> 6);
+ context->irrl_ba = cpu_to_le32(dma_handle_2 >> 6);
qpc_mask->irrl_ba = 0;
roce_set_field(context->byte_208_irrl, V2_QPC_BYTE_208_IRRL_BA_M,
V2_QPC_BYTE_208_IRRL_BA_S,
@@ -3861,7 +3857,7 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp,
* we should set all bits of the relevant fields in context mask to
* 0 at the same time, else set them to 0x1.
*/
- context->sq_cur_blk_addr = (u32)(sq_cur_blk >> PAGE_ADDR_SHIFT);
+ context->sq_cur_blk_addr = cpu_to_le32(sq_cur_blk >> PAGE_ADDR_SHIFT);
roce_set_field(context->byte_168_irrl_idx,
V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_M,
V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_S,
@@ -3873,8 +3869,8 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp,
context->sq_cur_sge_blk_addr = ((ibqp->qp_type == IB_QPT_GSI) ||
hr_qp->sq.max_gs > HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE) ?
- ((u32)(sge_cur_blk >>
- PAGE_ADDR_SHIFT)) : 0;
+ cpu_to_le32(sge_cur_blk >>
+ PAGE_ADDR_SHIFT) : 0;
roce_set_field(context->byte_184_irrl_idx,
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_M,
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_S,
@@ -3887,7 +3883,8 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp,
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_M,
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_S, 0);
- context->rx_sq_cur_blk_addr = (u32)(sq_cur_blk >> PAGE_ADDR_SHIFT);
+ context->rx_sq_cur_blk_addr =
+ cpu_to_le32(sq_cur_blk >> PAGE_ADDR_SHIFT);
roce_set_field(context->byte_232_irrl_sge,
V2_QPC_BYTE_232_RX_SQ_CUR_BLK_ADDR_M,
V2_QPC_BYTE_232_RX_SQ_CUR_BLK_ADDR_S,
@@ -4262,7 +4259,7 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
}
if (attr_mask & IB_QP_QKEY) {
- context->qkey_xrcd = attr->qkey;
+ context->qkey_xrcd = cpu_to_le32(attr->qkey);
qpc_mask->qkey_xrcd = 0;
hr_qp->qkey = attr->qkey;
}
@@ -4531,7 +4528,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
qp_attr->retry_cnt = roce_get_field(context.byte_212_lsn,
V2_QPC_BYTE_212_RETRY_CNT_M,
V2_QPC_BYTE_212_RETRY_CNT_S);
- qp_attr->rnr_retry = context.rq_rnr_timer;
+ qp_attr->rnr_retry = le32_to_cpu(context.rq_rnr_timer);
done:
qp_attr->cur_qp_state = qp_attr->qp_state;
@@ -4860,7 +4857,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;
- u32 doorbell[2];
+ __le32 doorbell[2];
doorbell[0] = 0;
doorbell[1] = 0;
@@ -5125,14 +5122,14 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id)
int_st = roce_read(hr_dev, ROCEE_VF_ABN_INT_ST_REG);
int_en = roce_read(hr_dev, ROCEE_VF_ABN_INT_EN_REG);
- if (roce_get_bit(int_st, HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S)) {
+ if (int_st & BIT(HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S)) {
struct pci_dev *pdev = hr_dev->pci_dev;
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
const struct hnae3_ae_ops *ops = ae_dev->ops;
dev_err(dev, "AEQ overflow!\n");
- roce_set_bit(int_st, HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S, 1);
+ int_st |= 1 << HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S;
roce_write(hr_dev, ROCEE_VF_ABN_INT_ST_REG, int_st);
/* Set reset level for reset_event() */
@@ -5142,27 +5139,27 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id)
if (ops->reset_event)
ops->reset_event(pdev, NULL);
- roce_set_bit(int_en, HNS_ROCE_V2_VF_ABN_INT_EN_S, 1);
+ int_en |= 1 << HNS_ROCE_V2_VF_ABN_INT_EN_S;
roce_write(hr_dev, ROCEE_VF_ABN_INT_EN_REG, int_en);
int_work = 1;
- } else if (roce_get_bit(int_st, HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S)) {
+ } else if (int_st & BIT(HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S)) {
dev_err(dev, "BUS ERR!\n");
- roce_set_bit(int_st, HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S, 1);
+ int_st |= 1 << HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S;
roce_write(hr_dev, ROCEE_VF_ABN_INT_ST_REG, int_st);
- roce_set_bit(int_en, HNS_ROCE_V2_VF_ABN_INT_EN_S, 1);
+ int_en |= 1 << HNS_ROCE_V2_VF_ABN_INT_EN_S;
roce_write(hr_dev, ROCEE_VF_ABN_INT_EN_REG, int_en);
int_work = 1;
- } else if (roce_get_bit(int_st, HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S)) {
+ } else if (int_st & BIT(HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S)) {
dev_err(dev, "OTHER ERR!\n");
- roce_set_bit(int_st, HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S, 1);
+ int_st |= 1 << HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S;
roce_write(hr_dev, ROCEE_VF_ABN_INT_ST_REG, int_st);
- roce_set_bit(int_en, HNS_ROCE_V2_VF_ABN_INT_EN_S, 1);
+ int_en |= 1 << HNS_ROCE_V2_VF_ABN_INT_EN_S;
roce_write(hr_dev, ROCEE_VF_ABN_INT_EN_REG, int_en);
int_work = 1;
@@ -5972,7 +5969,7 @@ static void hns_roce_v2_write_srqc(struct hns_roce_dev *hr_dev,
roce_set_field(srq_context->byte_24_wqe_bt_ba,
SRQC_BYTE_24_SRQ_WQE_BT_BA_M,
SRQC_BYTE_24_SRQ_WQE_BT_BA_S,
- cpu_to_le32(dma_handle_wqe >> 35));
+ dma_handle_wqe >> 35);
roce_set_field(srq_context->byte_28_rqws_pd, SRQC_BYTE_28_PD_M,
SRQC_BYTE_28_PD_S, pdn);
@@ -5980,20 +5977,18 @@ static void hns_roce_v2_write_srqc(struct hns_roce_dev *hr_dev,
SRQC_BYTE_28_RQWS_S, srq->max_gs <= 0 ? 0 :
fls(srq->max_gs - 1));
- srq_context->idx_bt_ba = (u32)(dma_handle_idx >> 3);
- srq_context->idx_bt_ba = cpu_to_le32(srq_context->idx_bt_ba);
+ srq_context->idx_bt_ba = cpu_to_le32(dma_handle_idx >> 3);
roce_set_field(srq_context->rsv_idx_bt_ba,
SRQC_BYTE_36_SRQ_IDX_BT_BA_M,
SRQC_BYTE_36_SRQ_IDX_BT_BA_S,
- cpu_to_le32(dma_handle_idx >> 35));
+ dma_handle_idx >> 35);
- srq_context->idx_cur_blk_addr = (u32)(mtts_idx[0] >> PAGE_ADDR_SHIFT);
srq_context->idx_cur_blk_addr =
- cpu_to_le32(srq_context->idx_cur_blk_addr);
+ cpu_to_le32(mtts_idx[0] >> PAGE_ADDR_SHIFT);
roce_set_field(srq_context->byte_44_idxbufpgsz_addr,
SRQC_BYTE_44_SRQ_IDX_CUR_BLK_ADDR_M,
SRQC_BYTE_44_SRQ_IDX_CUR_BLK_ADDR_S,
- cpu_to_le32((mtts_idx[0]) >> (32 + PAGE_ADDR_SHIFT)));
+ mtts_idx[0] >> (32 + PAGE_ADDR_SHIFT));
roce_set_field(srq_context->byte_44_idxbufpgsz_addr,
SRQC_BYTE_44_SRQ_IDX_HOP_NUM_M,
SRQC_BYTE_44_SRQ_IDX_HOP_NUM_S,
@@ -6009,13 +6004,12 @@ static void hns_roce_v2_write_srqc(struct hns_roce_dev *hr_dev,
SRQC_BYTE_44_SRQ_IDX_BUF_PG_SZ_S,
hr_dev->caps.idx_buf_pg_sz);
- srq_context->idx_nxt_blk_addr = (u32)(mtts_idx[1] >> PAGE_ADDR_SHIFT);
srq_context->idx_nxt_blk_addr =
- cpu_to_le32(srq_context->idx_nxt_blk_addr);
+ cpu_to_le32(mtts_idx[1] >> PAGE_ADDR_SHIFT);
roce_set_field(srq_context->rsv_idxnxtblkaddr,
SRQC_BYTE_52_SRQ_IDX_NXT_BLK_ADDR_M,
SRQC_BYTE_52_SRQ_IDX_NXT_BLK_ADDR_S,
- cpu_to_le32((mtts_idx[1]) >> (32 + PAGE_ADDR_SHIFT)));
+ mtts_idx[1] >> (32 + PAGE_ADDR_SHIFT));
roce_set_field(srq_context->byte_56_xrc_cqn,
SRQC_BYTE_56_SRQ_XRC_CQN_M, SRQC_BYTE_56_SRQ_XRC_CQN_S,
cqn);
@@ -6209,9 +6203,10 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
*/
wmb();
- srq_db.byte_4 = HNS_ROCE_V2_SRQ_DB << V2_DB_BYTE_4_CMD_S |
- (srq->srqn & V2_DB_BYTE_4_TAG_M);
- srq_db.parameter = srq->head;
+ srq_db.byte_4 =
+ cpu_to_le32(HNS_ROCE_V2_SRQ_DB << V2_DB_BYTE_4_CMD_S |
+ (srq->srqn & V2_DB_BYTE_4_TAG_M));
+ srq_db.parameter = cpu_to_le32(srq->head);
hns_roce_write64(hr_dev, (__le32 *)&srq_db, srq->db_reg_l);
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 8157679..5f8416b 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -1426,7 +1426,7 @@ static int hns_roce_set_page(struct ib_mr *ibmr, u64 addr)
{
struct hns_roce_mr *mr = to_hr_mr(ibmr);
- mr->pbl_buf[mr->npages++] = cpu_to_le64(addr);
+ mr->pbl_buf[mr->npages++] = addr;
return 0;
}
@@ -1597,10 +1597,9 @@ static int hns_roce_write_mtr(struct hns_roce_dev *hr_dev,
/* Save page addr, low 12 bits : 0 */
for (i = 0; i < count; i++) {
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1)
- mtts[i] = cpu_to_le64(bufs[npage] >>
- PAGE_ADDR_SHIFT);
+ mtts[i] = bufs[npage] >> PAGE_ADDR_SHIFT;
else
- mtts[i] = cpu_to_le64(bufs[npage]);
+ mtts[i] = bufs[npage];
npage++;
}
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index 7e10820..ca0e2b7 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -690,7 +690,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
struct ib_udata *udata, unsigned long sqpn,
struct hns_roce_qp *hr_qp)
{
- dma_addr_t *buf_list[ARRAY_SIZE(hr_qp->regions)] = { 0 };
+ dma_addr_t *buf_list[ARRAY_SIZE(hr_qp->regions)] = { NULL };
struct device *dev = hr_dev->dev;
struct hns_roce_ib_create_qp ucmd;
struct hns_roce_ib_create_qp_resp resp = {};
@@ -712,9 +712,9 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
hr_qp->ibqp.qp_type = init_attr->qp_type;
if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
- hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_ALL_WR);
+ hr_qp->sq_signal_bits = IB_SIGNAL_ALL_WR;
else
- hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_REQ_WR);
+ hr_qp->sq_signal_bits = IB_SIGNAL_REQ_WR;
ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, udata,
hns_roce_qp_has_rq(init_attr), hr_qp);
@@ -937,7 +937,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
if (sqpn)
hr_qp->doorbell_qpn = 1;
else
- hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn);
+ hr_qp->doorbell_qpn = (u32)hr_qp->qpn;
if (udata) {
ret = ib_copy_to_udata(udata, &resp,
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 6/9] RDMA/hns: Add reset process for function-clear
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (4 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 5/9] RDMA/hns: Fix cast from or to restricted __le32 for driver Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 7/9] RDMA/hns: Remove if-else judgment statements for creating srq Lijun Ou
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
From: Lang Cheng <chenglang@huawei.com>
If the hardware is resetting, the driver should not perform
the mailbox operation.Function-clear needs to add relevant judgment.
Signed-off-by: Lang Cheng <chenglang@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 98 +++++++++++++++++++++++++++++-
drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 +
2 files changed, 98 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 7730983..ecd0283 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1125,26 +1125,118 @@ static int hns_roce_cmq_query_hw_info(struct hns_roce_dev *hr_dev)
return 0;
}
+static bool hns_roce_func_clr_chk_rst(struct hns_roce_dev *hr_dev)
+{
+ struct hns_roce_v2_priv *priv = (struct hns_roce_v2_priv *)hr_dev->priv;
+ struct hnae3_handle *handle = priv->handle;
+ const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+ unsigned long reset_cnt;
+ bool sw_resetting;
+ bool hw_resetting;
+
+ reset_cnt = ops->ae_dev_reset_cnt(handle);
+ hw_resetting = ops->get_hw_reset_stat(handle);
+ sw_resetting = ops->ae_dev_resetting(handle);
+
+ if (reset_cnt != hr_dev->reset_cnt || hw_resetting || sw_resetting)
+ return true;
+
+ return false;
+}
+
+static void hns_roce_func_clr_rst_prc(struct hns_roce_dev *hr_dev, int retval,
+ int flag)
+{
+ struct hns_roce_v2_priv *priv = (struct hns_roce_v2_priv *)hr_dev->priv;
+ struct hnae3_handle *handle = priv->handle;
+ const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+ unsigned long instance_stage;
+ unsigned long reset_cnt;
+ unsigned long end;
+ bool sw_resetting;
+ bool hw_resetting;
+
+ instance_stage = handle->rinfo.instance_state;
+ reset_cnt = ops->ae_dev_reset_cnt(handle);
+ hw_resetting = ops->get_hw_reset_stat(handle);
+ sw_resetting = ops->ae_dev_resetting(handle);
+
+ if (reset_cnt != hr_dev->reset_cnt) {
+ hr_dev->dis_db = true;
+ hr_dev->is_reset = true;
+ dev_info(hr_dev->dev, "Func clear success after reset.\n");
+ } else if (hw_resetting) {
+ hr_dev->dis_db = true;
+
+ dev_warn(hr_dev->dev,
+ "Func clear is pending, device in resetting state.\n");
+ end = HNS_ROCE_V2_HW_RST_TIMEOUT;
+ while (end) {
+ if (!ops->get_hw_reset_stat(handle)) {
+ hr_dev->is_reset = true;
+ dev_info(hr_dev->dev,
+ "Func clear success after reset.\n");
+ return;
+ }
+ msleep(HNS_ROCE_V2_HW_RST_COMPLETION_WAIT);
+ end -= HNS_ROCE_V2_HW_RST_COMPLETION_WAIT;
+ }
+
+ dev_warn(hr_dev->dev, "Func clear failed.\n");
+ } else if (sw_resetting && instance_stage == HNS_ROCE_STATE_INIT) {
+ hr_dev->dis_db = true;
+
+ dev_warn(hr_dev->dev,
+ "Func clear is pending, device in resetting state.\n");
+ end = HNS_ROCE_V2_HW_RST_TIMEOUT;
+ while (end) {
+ if (ops->ae_dev_reset_cnt(handle) !=
+ hr_dev->reset_cnt) {
+ hr_dev->is_reset = true;
+ dev_info(hr_dev->dev,
+ "Func clear success after sw reset\n");
+ return;
+ }
+ msleep(HNS_ROCE_V2_HW_RST_COMPLETION_WAIT);
+ end -= HNS_ROCE_V2_HW_RST_COMPLETION_WAIT;
+ }
+
+ dev_warn(hr_dev->dev, "Func clear failed because of unfinished sw reset\n");
+ } else {
+ if (retval && !flag)
+ dev_warn(hr_dev->dev,
+ "Func clear read failed, ret = %d.\n", retval);
+
+ dev_warn(hr_dev->dev, "Func clear failed.\n");
+ }
+}
static void hns_roce_function_clear(struct hns_roce_dev *hr_dev)
{
+ bool fclr_write_fail_flag = false;
struct hns_roce_func_clear *resp;
struct hns_roce_cmq_desc desc;
unsigned long end;
- int ret;
+ int ret = 0;
+
+ if (hns_roce_func_clr_chk_rst(hr_dev))
+ goto out;
hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_FUNC_CLEAR, false);
resp = (struct hns_roce_func_clear *)desc.data;
ret = hns_roce_cmq_send(hr_dev, &desc, 1);
if (ret) {
+ fclr_write_fail_flag = true;
dev_err(hr_dev->dev, "Func clear write failed, ret = %d.\n",
ret);
- return;
+ goto out;
}
msleep(HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_INTERVAL);
end = HNS_ROCE_V2_FUNC_CLEAR_TIMEOUT_MSECS;
while (end) {
+ if (hns_roce_func_clr_chk_rst(hr_dev))
+ goto out;
msleep(HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT);
end -= HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT;
@@ -1161,7 +1253,9 @@ static void hns_roce_function_clear(struct hns_roce_dev *hr_dev)
}
}
+out:
dev_err(hr_dev->dev, "Func clear fail.\n");
+ hns_roce_func_clr_rst_prc(hr_dev, ret, fclr_write_fail_flag);
}
static int hns_roce_query_fw_ver(struct hns_roce_dev *hr_dev)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 1301629..43219d2 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -99,6 +99,8 @@
#define HNS_ROCE_V2_HW_RST_TIMEOUT 1000
#define HNS_ROCE_V2_HW_RST_UNINT_DELAY 100
+#define HNS_ROCE_V2_HW_RST_COMPLETION_WAIT 20
+
#define HNS_ROCE_CONTEXT_HOP_NUM 1
#define HNS_ROCE_SCCC_HOP_NUM 1
#define HNS_ROCE_MTT_HOP_NUM 1
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 7/9] RDMA/hns: Remove if-else judgment statements for creating srq
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (5 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 6/9] RDMA/hns: Add reset process for function-clear Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 8/9] RDMA/hns: Delete the not-used lines Lijun Ou
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
From: Wenpeng Liang <liangwenpeng@huawei.com>
Because if the value of srqwqe_buf_pg_sz is zero, npages and
ib_umem_page_count are equivalent, page_shif and PAGE_SHIFT
are equivalent in hns_roce_create_srq. Here remove it.
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_srq.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index c011422..1a42172 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -191,15 +191,11 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
if (IS_ERR(srq->umem))
return PTR_ERR(srq->umem);
- if (hr_dev->caps.srqwqe_buf_pg_sz) {
- npages = (ib_umem_page_count(srq->umem) +
- (1 << hr_dev->caps.srqwqe_buf_pg_sz) - 1) /
- (1 << hr_dev->caps.srqwqe_buf_pg_sz);
- page_shift = PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz;
- ret = hns_roce_mtt_init(hr_dev, npages, page_shift, &srq->mtt);
- } else
- ret = hns_roce_mtt_init(hr_dev, ib_umem_page_count(srq->umem),
- PAGE_SHIFT, &srq->mtt);
+ npages = (ib_umem_page_count(srq->umem) +
+ (1 << hr_dev->caps.srqwqe_buf_pg_sz) - 1) /
+ (1 << hr_dev->caps.srqwqe_buf_pg_sz);
+ page_shift = PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz;
+ ret = hns_roce_mtt_init(hr_dev, npages, page_shift, &srq->mtt);
if (ret)
goto err_user_buf;
@@ -216,19 +212,8 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
goto err_user_srq_mtt;
}
- if (hr_dev->caps.idx_buf_pg_sz) {
- npages = (ib_umem_page_count(srq->idx_que.umem) +
- (1 << hr_dev->caps.idx_buf_pg_sz) - 1) /
- (1 << hr_dev->caps.idx_buf_pg_sz);
- page_shift = PAGE_SHIFT + hr_dev->caps.idx_buf_pg_sz;
- ret = hns_roce_mtt_init(hr_dev, npages, page_shift,
- &srq->idx_que.mtt);
- } else {
- ret = hns_roce_mtt_init(hr_dev,
- ib_umem_page_count(srq->idx_que.umem),
- PAGE_SHIFT,
- &srq->idx_que.mtt);
- }
+ ret = hns_roce_mtt_init(hr_dev, ib_umem_page_count(srq->idx_que.umem),
+ PAGE_SHIFT, &srq->idx_que.mtt);
if (ret) {
dev_err(hr_dev->dev, "hns_roce_mtt_init error for idx que\n");
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 8/9] RDMA/hns: Delete the not-used lines
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (6 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 7/9] RDMA/hns: Remove if-else judgment statements for creating srq Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 9/9] RDMA/hns: Fix wrong assignment of qp_access_flags Lijun Ou
2019-08-28 15:31 ` [PATCH for-next 0/9] Fixes for hip08 driver Doug Ledford
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
From: Wenpeng Liang <liangwenpeng@huawei.com>
Delete the assignment of srq->ibsrq.ext.xrc.srq_num, beacause this
value is not used.
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_srq.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index 1a42172..9591457 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -412,7 +412,6 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
goto err_wrid;
srq->event = hns_roce_ib_srq_event;
- srq->ibsrq.ext.xrc.srq_num = srq->srqn;
resp.srqn = srq->srqn;
if (udata) {
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH for-next 9/9] RDMA/hns: Fix wrong assignment of qp_access_flags
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (7 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 8/9] RDMA/hns: Delete the not-used lines Lijun Ou
@ 2019-08-21 13:14 ` Lijun Ou
2019-08-28 15:31 ` [PATCH for-next 0/9] Fixes for hip08 driver Doug Ledford
9 siblings, 0 replies; 15+ messages in thread
From: Lijun Ou @ 2019-08-21 13:14 UTC (permalink / raw)
To: dledford, jgg; +Cc: linux-rdma, linuxarm
We used wrong shifts when set qp_attr->qp_access_flag,
this patch exchange V2_QP_RRE_S and V2_QP_RWE_S to fix it.
Fixes: 2a3d923f8730 ("RDMA/hns: Replace magic numbers with #defines")
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index ecd0283..7a89d66 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4574,9 +4574,9 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
V2_QPC_BYTE_56_DQPN_M,
V2_QPC_BYTE_56_DQPN_S);
qp_attr->qp_access_flags = ((roce_get_bit(context.byte_76_srqn_op_en,
- V2_QPC_BYTE_76_RRE_S)) << V2_QP_RWE_S) |
+ V2_QPC_BYTE_76_RRE_S)) << V2_QP_RRE_S) |
((roce_get_bit(context.byte_76_srqn_op_en,
- V2_QPC_BYTE_76_RWE_S)) << V2_QP_RRE_S) |
+ V2_QPC_BYTE_76_RWE_S)) << V2_QP_RWE_S) |
((roce_get_bit(context.byte_76_srqn_op_en,
V2_QPC_BYTE_76_ATE_S)) << V2_QP_ATE_S);
--
2.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08
2019-08-21 13:14 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 Lijun Ou
@ 2019-08-21 17:19 ` Leon Romanovsky
2019-08-26 8:43 ` liweihang
0 siblings, 1 reply; 15+ messages in thread
From: Leon Romanovsky @ 2019-08-21 17:19 UTC (permalink / raw)
To: Lijun Ou; +Cc: dledford, jgg, linux-rdma, linuxarm
On Wed, Aug 21, 2019 at 09:14:28PM +0800, Lijun Ou wrote:
> From: Yixian Liu <liuyixian@huawei.com>
>
> This patch refactor the initialization of cmd, and also for the cmd
> mode selection on event and poll mode.
>
> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
> Signed-off-by: Lang Chen <chenglang@huawei.com>
> ---
> drivers/infiniband/hw/hns/hns_roce_cmd.c | 14 ++++----------
> drivers/infiniband/hw/hns/hns_roce_main.c | 18 ++++++++----------
> 2 files changed, 12 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c
> index ade26fa..547002f 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
> @@ -251,23 +251,17 @@ int hns_roce_cmd_use_events(struct hns_roce_dev *hr_dev)
> hr_cmd->token_mask = CMD_TOKEN_MASK;
> hr_cmd->use_events = 1;
>
> - down(&hr_cmd->poll_sem);
> -
> return 0;
> }
>
> void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev)
> {
> struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
> - int i;
> -
> - hr_cmd->use_events = 0;
>
> - for (i = 0; i < hr_cmd->max_cmds; ++i)
> - down(&hr_cmd->event_sem);
> -
> - kfree(hr_cmd->context);
> - up(&hr_cmd->poll_sem);
> + if (hr_cmd->use_events) {
Ensure that hr_cmd->context == NULL in places where it shouldn't be
kfreed and remove this "if (hr_cmd->use_events)".
Thanks
.
> + kfree(hr_cmd->context);
> + hr_cmd->use_events = 0;
> + }
> }
>
> struct hns_roce_cmd_mailbox
> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
> index 1b757cc..f3b2f67 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_main.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
> @@ -902,6 +902,7 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> goto error_failed_cmd_init;
> }
>
> + /* EQ depends on poll mode, event mode depends on EQ */
> ret = hr_dev->hw->init_eq(hr_dev);
> if (ret) {
> dev_err(dev, "eq init failed!\n");
> @@ -911,8 +912,9 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> if (hr_dev->cmd_mod) {
> ret = hns_roce_cmd_use_events(hr_dev);
> if (ret) {
> - dev_err(dev, "Switch to event-driven cmd failed!\n");
> - goto error_failed_use_event;
> + dev_warn(dev,
> + "Cmd event mode failed, set back to poll!\n");
> + hns_roce_cmd_use_polling(hr_dev);
> }
> }
>
> @@ -928,12 +930,10 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> goto error_failed_setup_hca;
> }
>
> - if (hr_dev->hw->hw_init) {
> - ret = hr_dev->hw->hw_init(hr_dev);
> - if (ret) {
> - dev_err(dev, "hw_init failed!\n");
> - goto error_failed_engine_init;
> - }
> + ret = hr_dev->hw->hw_init(hr_dev);
> + if (ret) {
> + dev_err(dev, "hw_init failed!\n");
> + goto error_failed_engine_init;
> }
>
> ret = hns_roce_register_device(hr_dev);
> @@ -955,8 +955,6 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> error_failed_init_hem:
> if (hr_dev->cmd_mod)
> hns_roce_cmd_use_polling(hr_dev);
> -
> -error_failed_use_event:
> hr_dev->hw->cleanup_eq(hr_dev);
>
> error_failed_eq_table:
> --
> 2.8.1
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08
2019-08-21 17:19 ` Leon Romanovsky
@ 2019-08-26 8:43 ` liweihang
0 siblings, 0 replies; 15+ messages in thread
From: liweihang @ 2019-08-26 8:43 UTC (permalink / raw)
To: Leon Romanovsky, oulijun; +Cc: linux-rdma, jgg, dledford, Linuxarm
> -----Original Message-----
> From: Linuxarm [mailto:linuxarm-bounces@huawei.com] On Behalf Of Leon
> Romanovsky
> Sent: Thursday, August 22, 2019 1:19 AM
> To: oulijun <oulijun@huawei.com>
> Cc: linux-rdma@vger.kernel.org; jgg@ziepe.ca; dledford@redhat.com;
> Linuxarm <linuxarm@huawei.com>
> Subject: Re: [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode
> selection for hip08
>
> On Wed, Aug 21, 2019 at 09:14:28PM +0800, Lijun Ou wrote:
> > From: Yixian Liu <liuyixian@huawei.com>
> >
> > This patch refactor the initialization of cmd, and also for the cmd
> > mode selection on event and poll mode.
> >
> > Signed-off-by: Yixian Liu <liuyixian@huawei.com>
> > Signed-off-by: Lang Chen <chenglang@huawei.com>
> > ---
> > drivers/infiniband/hw/hns/hns_roce_cmd.c | 14 ++++----------
> > drivers/infiniband/hw/hns/hns_roce_main.c | 18 ++++++++----------
> > 2 files changed, 12 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c
> > b/drivers/infiniband/hw/hns/hns_roce_cmd.c
> > index ade26fa..547002f 100644
> > --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
> > +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
> > @@ -251,23 +251,17 @@ int hns_roce_cmd_use_events(struct
> hns_roce_dev *hr_dev)
> > hr_cmd->token_mask = CMD_TOKEN_MASK;
> > hr_cmd->use_events = 1;
> >
> > - down(&hr_cmd->poll_sem);
> > -
> > return 0;
> > }
> >
> > void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev) {
> > struct hns_roce_cmdq *hr_cmd = &hr_dev->cmd;
> > - int i;
> > -
> > - hr_cmd->use_events = 0;
> >
> > - for (i = 0; i < hr_cmd->max_cmds; ++i)
> > - down(&hr_cmd->event_sem);
> > -
> > - kfree(hr_cmd->context);
> > - up(&hr_cmd->poll_sem);
> > + if (hr_cmd->use_events) {
>
> Ensure that hr_cmd->context == NULL in places where it shouldn't be kfreed
> and remove this "if (hr_cmd->use_events)".
>
> Thanks
> .
Hi Leon,
Thanks for your advice, will remove above judgement in v2.
>
>
> > + kfree(hr_cmd->context);
> > + hr_cmd->use_events = 0;
> > + }
> > }
> >
> > struct hns_roce_cmd_mailbox
> > diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c
> > b/drivers/infiniband/hw/hns/hns_roce_main.c
> > index 1b757cc..f3b2f67 100644
> > --- a/drivers/infiniband/hw/hns/hns_roce_main.c
> > +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
> > @@ -902,6 +902,7 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> > goto error_failed_cmd_init;
> > }
> >
> > + /* EQ depends on poll mode, event mode depends on EQ */
> > ret = hr_dev->hw->init_eq(hr_dev);
> > if (ret) {
> > dev_err(dev, "eq init failed!\n");
> > @@ -911,8 +912,9 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> > if (hr_dev->cmd_mod) {
> > ret = hns_roce_cmd_use_events(hr_dev);
> > if (ret) {
> > - dev_err(dev, "Switch to event-driven cmd failed!\n");
> > - goto error_failed_use_event;
> > + dev_warn(dev,
> > + "Cmd event mode failed, set back to
> poll!\n");
> > + hns_roce_cmd_use_polling(hr_dev);
> > }
> > }
> >
> > @@ -928,12 +930,10 @@ int hns_roce_init(struct hns_roce_dev *hr_dev)
> > goto error_failed_setup_hca;
> > }
> >
> > - if (hr_dev->hw->hw_init) {
> > - ret = hr_dev->hw->hw_init(hr_dev);
> > - if (ret) {
> > - dev_err(dev, "hw_init failed!\n");
> > - goto error_failed_engine_init;
> > - }
> > + ret = hr_dev->hw->hw_init(hr_dev);
> > + if (ret) {
> > + dev_err(dev, "hw_init failed!\n");
> > + goto error_failed_engine_init;
> > }
> >
> > ret = hns_roce_register_device(hr_dev); @@ -955,8 +955,6 @@ int
> > hns_roce_init(struct hns_roce_dev *hr_dev)
> > error_failed_init_hem:
> > if (hr_dev->cmd_mod)
> > hns_roce_cmd_use_polling(hr_dev);
> > -
> > -error_failed_use_event:
> > hr_dev->hw->cleanup_eq(hr_dev);
> >
> > error_failed_eq_table:
> > --
> > 2.8.1
> >
> _______________________________________________
> Linuxarm mailing list
> Linuxarm@huawei.com
> http://hulk.huawei.com/mailman/listinfo/linuxarm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp
2019-08-21 13:14 ` [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp Lijun Ou
@ 2019-08-28 15:19 ` Doug Ledford
2019-08-29 0:56 ` oulijun
0 siblings, 1 reply; 15+ messages in thread
From: Doug Ledford @ 2019-08-28 15:19 UTC (permalink / raw)
To: Lijun Ou, jgg; +Cc: linux-rdma, linuxarm
[-- Attachment #1: Type: text/plain, Size: 3535 bytes --]
On Wed, 2019-08-21 at 21:14 +0800, Lijun Ou wrote:
> +static int hns_roce_alloc_recv_inline_buffer(struct hns_roce_qp
> *hr_qp,
> + struct ib_qp_init_attr
> *init_attr)
> +{
> + int ret;
> + int i;
> +
> + /* allocate recv inline buf */
> + hr_qp->rq_inl_buf.wqe_list = kcalloc(hr_qp->rq.wqe_cnt,
> + sizeof(struct
> hns_roce_rinl_wqe),
> + GFP_KERNEL);
> + if (!hr_qp->rq_inl_buf.wqe_list) {
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + hr_qp->rq_inl_buf.wqe_cnt = hr_qp->rq.wqe_cnt;
> +
> + /* Firstly, allocate a list of sge space buffer */
> + hr_qp->rq_inl_buf.wqe_list[0].sg_list =
> + kcalloc(hr_qp-
> >rq_inl_buf.wqe_cnt,
> + init_attr->cap.max_recv_sge *
> + sizeof(struct
> hns_roce_rinl_sge),
> + GFP_KERNEL);
> + if (!hr_qp->rq_inl_buf.wqe_list[0].sg_list) {
> + ret = -ENOMEM;
> + goto err_wqe_list;
> + }
> +
> + for (i = 1; i < hr_qp->rq_inl_buf.wqe_cnt; i++)
> + /* Secondly, reallocate the buffer */
> + hr_qp->rq_inl_buf.wqe_list[i].sg_list =
> + &hr_qp-
> >rq_inl_buf.wqe_list[0].sg_list[i *
> + init_attr->cap.max_recv_sge];
> +
> + return 0;
> +
> +err_wqe_list:
> + kfree(hr_qp->rq_inl_buf.wqe_list);
> +
> +err:
> + return ret;
> +}
This function is klunky. You don't need int ret; at all as there are
only two possible return values and you have distinct locations for each
return, so each return can use a constant. It would be much more
readable like this:
+static int hns_roce_alloc_recv_inline_buffer(struct hns_roce_qp *hr_qp,
+ struct ib_qp_init_attr *init_attr)
+{
+ int num_sge = init_attr->cap.max_recv_sge;
+ int wqe_cnt = hr_qp->rq.wqe_cnt;
+ int i;
+
+ /* allocate recv inline WQE bufs */
+ hr_qp->rq_inl_buf.wqe_list = kcalloc(wqe_cnt,
+ sizeof(struct hns_roce_rinl_wqe),
+ GFP_KERNEL);
+ if (!hr_qp->rq_inl_buf.wqe_list)
+ goto err;
+
+ hr_qp->rq_inl_buf.wqe_cnt = wqe_cnt;
+
+ /* allocate a single sge array for all WQEs */
+ hr_qp->rq_inl_buf.wqe_list[0].sg_list =
+ kcalloc(wqe_cnt,
+ num_sge *
+ sizeof(struct hns_roce_rinl_sge),
+ GFP_KERNEL);
+ if (!hr_qp->rq_inl_buf.wqe_list[0].sg_list)
+ goto err_wqe_list;
+
+ for (i = 1; i < wqe_cnt; i++)
+ /* give each WQE a pointer to its array space */
+ hr_qp->rq_inl_buf.wqe_list[i].sg_list =
+ &hr_qp->rq_inl_buf.wqe_list[0].sg_list[i * num_sge];
+
+ return 0;
+
+err_wqe_list:
+ kfree(hr_qp->rq_inl_buf.wqe_list);
+err:
+ return -ENOMEM;
+}
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-next 0/9] Fixes for hip08 driver
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
` (8 preceding siblings ...)
2019-08-21 13:14 ` [PATCH for-next 9/9] RDMA/hns: Fix wrong assignment of qp_access_flags Lijun Ou
@ 2019-08-28 15:31 ` Doug Ledford
9 siblings, 0 replies; 15+ messages in thread
From: Doug Ledford @ 2019-08-28 15:31 UTC (permalink / raw)
To: Lijun Ou, jgg; +Cc: linux-rdma, linuxarm
[-- Attachment #1: Type: text/plain, Size: 1716 bytes --]
On Wed, 2019-08-21 at 21:14 +0800, Lijun Ou wrote:
> Here optimizes some codes and removes some warnings
> by sparse tool checking as well as fixes some defects.
>
> Lang Cheng (3):
> RDMA/hns: Modify the data structure of hns_roce_av
> RDMA/hns: Fix cast from or to restricted __le32 for driver
> RDMA/hns: Add reset process for function-clear
>
> Lijun Ou (3):
> RDMA/hns: Refactor the codes of creating qp
> RDMA/hns: Remove the some magic number
> RDMA/hns: Fix wrong assignment of qp_access_flags
>
> Wenpeng Liang (2):
> RDMA/hns: Remove if-else judgment statements for creating srq
> RDMA/hns: Delete the not-used lines
>
> Yixian Liu (1):
> RDMA/hns: Refactor cmd init and mode selection for hip08
>
> drivers/infiniband/hw/hns/hns_roce_ah.c | 23 +--
> drivers/infiniband/hw/hns/hns_roce_cmd.c | 14 +-
> drivers/infiniband/hw/hns/hns_roce_device.h | 17 +-
> drivers/infiniband/hw/hns/hns_roce_hem.c | 34 ++--
> drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 49 +++---
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 256
> +++++++++++++++++++---------
> drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 5 +-
> drivers/infiniband/hw/hns/hns_roce_main.c | 18 +-
> drivers/infiniband/hw/hns/hns_roce_mr.c | 7 +-
> drivers/infiniband/hw/hns/hns_roce_qp.c | 108 +++++++-----
> drivers/infiniband/hw/hns/hns_roce_srq.c | 30 +---
> 11 files changed, 314 insertions(+), 247 deletions(-)
>
I took patches 3-9 into for-next. Please fixup and resend 1 and 2.
Thanks.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp
2019-08-28 15:19 ` Doug Ledford
@ 2019-08-29 0:56 ` oulijun
0 siblings, 0 replies; 15+ messages in thread
From: oulijun @ 2019-08-29 0:56 UTC (permalink / raw)
To: Doug Ledford, jgg; +Cc: linux-rdma, linuxarm
在 2019/8/28 23:19, Doug Ledford 写道:
> On Wed, 2019-08-21 at 21:14 +0800, Lijun Ou wrote:
>> +static int hns_roce_alloc_recv_inline_buffer(struct hns_roce_qp
>> *hr_qp,
>> + struct ib_qp_init_attr
>> *init_attr)
>> +{
>> + int ret;
>> + int i;
>> +
>> + /* allocate recv inline buf */
>> + hr_qp->rq_inl_buf.wqe_list = kcalloc(hr_qp->rq.wqe_cnt,
>> + sizeof(struct
>> hns_roce_rinl_wqe),
>> + GFP_KERNEL);
>> + if (!hr_qp->rq_inl_buf.wqe_list) {
>> + ret = -ENOMEM;
>> + goto err;
>> + }
>> +
>> + hr_qp->rq_inl_buf.wqe_cnt = hr_qp->rq.wqe_cnt;
>> +
>> + /* Firstly, allocate a list of sge space buffer */
>> + hr_qp->rq_inl_buf.wqe_list[0].sg_list =
>> + kcalloc(hr_qp-
>>> rq_inl_buf.wqe_cnt,
>> + init_attr->cap.max_recv_sge *
>> + sizeof(struct
>> hns_roce_rinl_sge),
>> + GFP_KERNEL);
>> + if (!hr_qp->rq_inl_buf.wqe_list[0].sg_list) {
>> + ret = -ENOMEM;
>> + goto err_wqe_list;
>> + }
>> +
>> + for (i = 1; i < hr_qp->rq_inl_buf.wqe_cnt; i++)
>> + /* Secondly, reallocate the buffer */
>> + hr_qp->rq_inl_buf.wqe_list[i].sg_list =
>> + &hr_qp-
>>> rq_inl_buf.wqe_list[0].sg_list[i *
>> + init_attr->cap.max_recv_sge];
>> +
>> + return 0;
>> +
>> +err_wqe_list:
>> + kfree(hr_qp->rq_inl_buf.wqe_list);
>> +
>> +err:
>> + return ret;
>> +}
> This function is klunky. You don't need int ret; at all as there are
> only two possible return values and you have distinct locations for each
> return, so each return can use a constant. It would be much more
> readable like this:
>
> +static int hns_roce_alloc_recv_inline_buffer(struct hns_roce_qp *hr_qp,
> + struct ib_qp_init_attr *init_attr)
> +{
> + int num_sge = init_attr->cap.max_recv_sge;
> + int wqe_cnt = hr_qp->rq.wqe_cnt;
> + int i;
> +
> + /* allocate recv inline WQE bufs */
> + hr_qp->rq_inl_buf.wqe_list = kcalloc(wqe_cnt,
> + sizeof(struct hns_roce_rinl_wqe),
> + GFP_KERNEL);
> + if (!hr_qp->rq_inl_buf.wqe_list)
> + goto err;
> +
> + hr_qp->rq_inl_buf.wqe_cnt = wqe_cnt;
> +
> + /* allocate a single sge array for all WQEs */
> + hr_qp->rq_inl_buf.wqe_list[0].sg_list =
> + kcalloc(wqe_cnt,
> + num_sge *
> + sizeof(struct hns_roce_rinl_sge),
> + GFP_KERNEL);
> + if (!hr_qp->rq_inl_buf.wqe_list[0].sg_list)
> + goto err_wqe_list;
> +
> + for (i = 1; i < wqe_cnt; i++)
> + /* give each WQE a pointer to its array space */
> + hr_qp->rq_inl_buf.wqe_list[i].sg_list =
> + &hr_qp->rq_inl_buf.wqe_list[0].sg_list[i * num_sge];
> +
> + return 0;
> +
> +err_wqe_list:
> + kfree(hr_qp->rq_inl_buf.wqe_list);
> +err:
> + return -ENOMEM;
> +}
>
Thanks, I will consider accept your advice and fixes it.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-08-29 0:56 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 13:14 [PATCH for-next 0/9] Fixes for hip08 driver Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 1/9] RDMA/hns: Refactor cmd init and mode selection for hip08 Lijun Ou
2019-08-21 17:19 ` Leon Romanovsky
2019-08-26 8:43 ` liweihang
2019-08-21 13:14 ` [PATCH for-next 2/9] RDMA/hns: Refactor the codes of creating qp Lijun Ou
2019-08-28 15:19 ` Doug Ledford
2019-08-29 0:56 ` oulijun
2019-08-21 13:14 ` [PATCH for-next 3/9] RDMA/hns: Modify the data structure of hns_roce_av Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 4/9] RDMA/hns: Remove the some magic number Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 5/9] RDMA/hns: Fix cast from or to restricted __le32 for driver Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 6/9] RDMA/hns: Add reset process for function-clear Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 7/9] RDMA/hns: Remove if-else judgment statements for creating srq Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 8/9] RDMA/hns: Delete the not-used lines Lijun Ou
2019-08-21 13:14 ` [PATCH for-next 9/9] RDMA/hns: Fix wrong assignment of qp_access_flags Lijun Ou
2019-08-28 15:31 ` [PATCH for-next 0/9] Fixes for hip08 driver Doug Ledford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).