RDMA/hns: Updates for 5.15
Subsystems (2)
cover RDMA/hns: Updates for 5.15
As usual, this series collects some miscellaneous fixes and cleanups at the end of 5.15 for the hns driver:
* #1 ~ #2 are fixes.
* #3 ~ #7 are some small cleanups.
Weihang Li (1):
RDMA/hns: Remove RST2RST error prints for hw v1
Wenpeng Liang (4):
RDMA/hns: Fix query destination qpn
RDMA/hns: Fix QP's resp incomplete assignment RDMA/hns: Remove dqpn filling when modify qp from Init to Init RDMA/hns: Adjust the order in which irq are requested and enabled
Xinhao Liu (1):
RDMA/hns: Delete unnecessary blank lines.
Yixing Liu (1):
RDMA/hns: Encapsulate the qp db as a function
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 40 +++----- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 - drivers/infiniband/hw/hns/hns_roce_qp.c | 150 ++++++++++++++++------------- 3 files changed, 98 insertions(+), 93 deletions(-)
--
2.8.1
PATCH 1/7 RDMA/hns: Fix query destination qpn
The bit width of dqpn is 24 bits, using u8 will cause truncation error.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -1
@@ -5130,7 +5130,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_attr->rq_psn =hr_reg_read (&context,QPC_RX_REQ_EPSN ); qp_attr->sq_psn = (u32 )hr_reg_read (&context,QPC_SQ_CUR_PSN ); - qp_attr->dest_qp_num = (u8 )hr_reg_read (&context,QPC_DQPN ); + qp_attr->dest_qp_num =hr_reg_read (&context,QPC_DQPN ); qp_attr->qp_access_flags = ((hr_reg_read (&context,QPC_RRE )) <<V2_QP_RRE_S ) | ((hr_reg_read(&context, QPC_RWE)) << V2_QP_RWE_S) |
Signature · 1 line
2.8.1
PATCH 2/7 RDMA/hns: Fix QP's resp incomplete assignment
In reply to Wenpeng LiangThe resp passed to the user space represents the enable flag of qp, incomplete assignment will cause some features of the user space to be disabled.
--- drivers/infiniband/hw/hns/hns_roce_qp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +1 -2
@@ -848,7 +848,6 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, goto err_out; } hr_qp->en_flags |=HNS_ROCE_QP_CAP_SQ_RECORD_DB ; - resp->cap_flags |=HNS_ROCE_QP_CAP_SQ_RECORD_DB ; }if (user_qp_has_rdb (hr_dev, init_attr, udata, resp)) {
@@ -861,7 +860,6 @@ static int alloc_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, goto err_sdb; } hr_qp->en_flags |=HNS_ROCE_QP_CAP_RQ_RECORD_DB ; - resp->cap_flags |=HNS_ROCE_QP_CAP_RQ_RECORD_DB ; } }else {if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP09 )
@@ -1071,6 +1069,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, }if (udata) { + resp.cap_flags = hr_qp->en_flags; ret =ib_copy_to_udata (udata, &resp,min (udata->outlen,sizeof (resp)));if (ret) {
Signature · 1 line
2.8.1
PATCH 3/7 RDMA/hns: Remove dqpn filling when modify qp from Init to Init
In reply to Wenpeng LiangAccording to the IB specification, the destination qpn is allowed to be filled into the qpc only when the qp transitions from Init to RTR, so this code is unused.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -7
@@ -4143,8 +4143,6 @@ static void modify_qp_init_to_init(struct ib_qp *ibqp,struct hns_roce_v2_qp_context *context, struct hns_roce_v2_qp_context *qpc_mask) { - struct hns_roce_qp *hr_qp = to_hr_qp(ibqp); -/* * In v2 engine, software pass context and context mask to hardware * when modifying qp. If software need modify some fields in context,
@@ -4169,11 +4167,6 @@ static void modify_qp_init_to_init(struct ib_qp *ibqp,hr_reg_write (context,QPC_SRQN ,to_hr_srq (ibqp->srq)->srqn);hr_reg_clear (qpc_mask,QPC_SRQN ); } - -if (attr_mask &IB_QP_DEST_QPN ) { -hr_reg_write (context,QPC_DQPN , hr_qp->qpn); -hr_reg_clear (qpc_mask,QPC_DQPN ); - } } static int config_qp_rq_buf(struct hns_roce_dev *hr_dev,
Signature · 1 line
2.8.1
PATCH 4/7 RDMA/hns: Remove RST2RST error prints for hw v1
In reply to Wenpeng LiangFrom: Weihang Li <[email protected]>
There is no need to prints error for hw_v1.
--- drivers/infiniband/hw/hns/hns_roce_qp.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +1 -10
@@ -1302,17 +1302,8 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,if (ret) goto out; -if (cur_state == new_state && cur_state ==IB_QPS_RESET ) { -if (hr_dev->hw_rev ==HNS_ROCE_HW_VER1 ) { - ret = -EPERM ; -ibdev_err (&hr_dev->ib_dev, -"RST2RST state is not supported\n" ); - }else { - ret =0 ; - } - +if (cur_state == new_state && cur_state ==IB_QPS_RESET ) goto out; - } ret = hr_dev->hw->modify_qp (ibqp, attr, attr_mask, cur_state, new_state);
Signature · 1 line
2.8.1
PATCH 5/7 RDMA/hns: Adjust the order in which irq are requested and enabled
In reply to Wenpeng LiangIt should first alloc workqueue and request irq, and finally enable irq.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +13 -16
@@ -6114,35 +6114,32 @@ static int hns_roce_v2_init_eq_table(struct hns_roce_dev *hr_dev) ret =hns_roce_v2_create_eq (hr_dev, eq, eq_cmd);if (ret) { -dev_err (dev,"eq create failed.\n" ); +dev_err (dev,"failed to create eq.\n" ); goto err_create_eq_fail; } } -/* enable irq */ -hns_roce_v2_int_mask_enable (hr_dev, eq_num,EQ_ENABLE ); + hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" ,0 ); +if (!hr_dev->irq_workq) { +dev_err (dev,"failed to create irq workqueue.\n" ); + ret = -ENOMEM ; + goto err_create_eq_fail; + } - ret =__hns_roce_request_irq (hr_dev, irq_num, comp_num, - aeq_num, other_num); + ret =__hns_roce_request_irq (hr_dev, irq_num, comp_num, aeq_num, + other_num);if (ret) { -dev_err (dev,"Request irq failed.\n" ); +dev_err (dev,"failed to request irq.\n" ); goto err_request_irq_fail; } - hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" ,0 ); -if (!hr_dev->irq_workq) { -dev_err (dev,"Create irq workqueue failed!\n" ); - ret = -ENOMEM ; - goto err_create_wq_fail; - } +/* enable irq */ +hns_roce_v2_int_mask_enable (hr_dev, eq_num,EQ_ENABLE );return 0 ; -err_create_wq_fail: -__hns_roce_free_irq (hr_dev); - err_request_irq_fail: -hns_roce_v2_int_mask_enable (hr_dev, eq_num,EQ_DISABLE ); +destroy_workqueue (hr_dev->irq_workq); err_create_eq_fail:for (i -=1 ; i >=0 ; i--)
Signature · 1 line
2.8.1
PATCH 6/7 RDMA/hns: Encapsulate the qp db as a function
In reply to Wenpeng LiangFrom: Yixing Liu <[email protected]>
Encapsulate qp db into two functions: user and kernel.
--- drivers/infiniband/hw/hns/hns_roce_qp.c | 135 +++++++++++++++++++------------- 1 file changed, 82 insertions(+), 53 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +82 -53
@@ -823,75 +823,104 @@ static inline bool kernel_qp_has_rdb(struct hns_roce_dev *hr_dev, hns_roce_qp_has_rq(init_attr)); } +static int alloc_user_qp_db (struct hns_roce_dev *hr_dev, +struct hns_roce_qp *hr_qp, +struct ib_qp_init_attr *init_attr, +struct ib_udata *udata, +struct hns_roce_ib_create_qp *ucmd, +struct hns_roce_ib_create_qp_resp *resp) +{ +struct hns_roce_ucontext *uctx =rdma_udata_to_drv_context (udata, + struct hns_roce_ucontext, ibucontext); +struct ib_device *ibdev = &hr_dev->ib_dev; +int ret; + +if (user_qp_has_sdb (hr_dev, init_attr, udata, resp, ucmd)) { + ret =hns_roce_db_map_user (uctx, ucmd->sdb_addr, &hr_qp->sdb); +if (ret) { +ibdev_err (ibdev, +"failed to map user SQ doorbell, ret = %d.\n" , + ret); + goto err_out; + } + hr_qp->en_flags |=HNS_ROCE_QP_CAP_SQ_RECORD_DB ; + } + +if (user_qp_has_rdb (hr_dev, init_attr, udata, resp)) { + ret =hns_roce_db_map_user (uctx, ucmd->db_addr, &hr_qp->rdb); +if (ret) { +ibdev_err (ibdev, +"failed to map user RQ doorbell, ret = %d.\n" , + ret); + goto err_sdb; + } + hr_qp->en_flags |=HNS_ROCE_QP_CAP_RQ_RECORD_DB ; + } + +return 0 ; + +err_sdb: +if (hr_qp->en_flags &HNS_ROCE_QP_CAP_SQ_RECORD_DB ) +hns_roce_db_unmap_user (uctx, &hr_qp->sdb); +err_out: +return ret; +} + +static int alloc_kernel_qp_db (struct hns_roce_dev *hr_dev, +struct hns_roce_qp *hr_qp, +struct ib_qp_init_attr *init_attr) +{ +struct ib_device *ibdev = &hr_dev->ib_dev; +int ret; + +if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP09 ) + hr_qp->sq.db_reg = hr_dev->mem_base + +HNS_ROCE_DWQE_SIZE * hr_qp->qpn; +else + hr_qp->sq.db_reg = hr_dev->reg_base + hr_dev->sdb_offset + +DB_REG_OFFSET * hr_dev->priv_uar.index; + + hr_qp->rq.db_reg = hr_dev->reg_base + hr_dev->odb_offset + +DB_REG_OFFSET * hr_dev->priv_uar.index; + +if (kernel_qp_has_rdb (hr_dev, init_attr)) { + ret =hns_roce_alloc_db (hr_dev, &hr_qp->rdb,0 ); +if (ret) { +ibdev_err (ibdev, +"failed to alloc kernel RQ doorbell, ret = %d.\n" , + ret); +return ret; + } + *hr_qp->rdb.db_record =0 ; + hr_qp->en_flags |=HNS_ROCE_QP_CAP_RQ_RECORD_DB ; + } + +return 0 ; +} +static int alloc_qp_db (struct hns_roce_dev *hr_dev,struct hns_roce_qp *hr_qp,struct ib_qp_init_attr *init_attr,struct ib_udata *udata,struct hns_roce_ib_create_qp *ucmd,struct hns_roce_ib_create_qp_resp *resp) { -struct hns_roce_ucontext *uctx =rdma_udata_to_drv_context ( - udata, struct hns_roce_ucontext, ibucontext); -struct ib_device *ibdev = &hr_dev->ib_dev;int ret;if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_SDI_MODE ) hr_qp->en_flags |=HNS_ROCE_QP_CAP_OWNER_DB ;if (udata) { -if (user_qp_has_sdb (hr_dev, init_attr, udata, resp, ucmd)) { - ret =hns_roce_db_map_user (uctx, ucmd->sdb_addr, - &hr_qp->sdb); -if (ret) { -ibdev_err (ibdev, -"failed to map user SQ doorbell, ret = %d.\n" , - ret); - goto err_out; - } - hr_qp->en_flags |=HNS_ROCE_QP_CAP_SQ_RECORD_DB ; - } - -if (user_qp_has_rdb (hr_dev, init_attr, udata, resp)) { - ret =hns_roce_db_map_user (uctx, ucmd->db_addr, - &hr_qp->rdb); -if (ret) { -ibdev_err (ibdev, -"failed to map user RQ doorbell, ret = %d.\n" , - ret); - goto err_sdb; - } - hr_qp->en_flags |=HNS_ROCE_QP_CAP_RQ_RECORD_DB ; - } + ret =alloc_user_qp_db (hr_dev, hr_qp, init_attr, udata, ucmd, + resp); +if (ret) +return ret; }else { -if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP09 ) - hr_qp->sq.db_reg = hr_dev->mem_base + -HNS_ROCE_DWQE_SIZE * hr_qp->qpn; -else - hr_qp->sq.db_reg = - hr_dev->reg_base + hr_dev->sdb_offset + -DB_REG_OFFSET * hr_dev->priv_uar.index; - - hr_qp->rq.db_reg = hr_dev->reg_base + hr_dev->odb_offset + -DB_REG_OFFSET * hr_dev->priv_uar.index; - -if (kernel_qp_has_rdb (hr_dev, init_attr)) { - ret =hns_roce_alloc_db (hr_dev, &hr_qp->rdb,0 ); -if (ret) { -ibdev_err (ibdev, -"failed to alloc kernel RQ doorbell, ret = %d.\n" , - ret); - goto err_out; - } - *hr_qp->rdb.db_record =0 ; - hr_qp->en_flags |=HNS_ROCE_QP_CAP_RQ_RECORD_DB ; - } + ret =alloc_kernel_qp_db (hr_dev, hr_qp, init_attr); +if (ret) +return ret; }return 0 ; -err_sdb: -if (udata && hr_qp->en_flags &HNS_ROCE_QP_CAP_SQ_RECORD_DB ) -hns_roce_db_unmap_user (uctx, &hr_qp->sdb); -err_out: -return ret; } static void free_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
Signature · 1 line
2.8.1
PATCH 7/7 RDMA/hns: Delete unnecessary blank lines.
In reply to Wenpeng LiangFrom: Xinhao Liu <[email protected]>
Just delete unnecessary blank lines.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 -- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 - drivers/infiniband/hw/hns/hns_roce_qp.c | 1 - 3 files changed, 4 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -2
@@ -5220,7 +5220,6 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,if (send_cq && send_cq != recv_cq)__hns_roce_v2_cq_clean (send_cq, hr_qp->qpn,NULL ); - }hns_roce_qp_remove (hr_dev, hr_qp);
@@ -6360,7 +6359,6 @@ static int hns_roce_hw_v2_init_instance(struct hnae3_handle *handle) handle->rinfo.instance_state =HNS_ROCE_STATE_INITED ; -return 0 ; reset_chk_err:
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +0 -1
@@ -1407,7 +1407,6 @@ struct hns_roce_cmq_desc {__le32 rsv[4 ]; } func_info; }; - };struct hns_roce_v2_cmq_ring {
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -1
@@ -715,7 +715,6 @@ static int alloc_rq_inline_buf(struct hns_roce_qp *hr_qp,/* allocate recv inline buf */ wqe_list =kcalloc (wqe_cnt,sizeof (struct hns_roce_rinl_wqe ),GFP_KERNEL ); -if (!wqe_list) goto err;
Signature · 1 line
2.8.1
Quoted 15 lines · Wenpeng Liang
As usual, this series collects some miscellaneous fixes and cleanups at the end of 5.15 for the hns driver:
* #1 ~ #2 are fixes.
* #3 ~ #7 are some small cleanups.Weihang Li (1):
RDMA/hns: Remove RST2RST error prints for hw v1Wenpeng Liang (4):
RDMA/hns: Fix query destination qpn
RDMA/hns: Fix QP's resp incomplete assignment RDMA/hns: Remove dqpn filling when modify qp from Init to Init RDMA/hns: Adjust the order in which irq are requested and enabled
Quoted 5 lines
Xinhao Liu (1):
RDMA/hns: Delete unnecessary blank lines.Yixing Liu (1):
RDMA/hns: Encapsulate the qp db as a function
Applied to for-next, thanks
Jason