From: Lijun Ou <oulijun@xxxxxxxxxx> When a qp attached with a srq needs to be modified to reset or error state, the corresponding cq should be cleaned and then the wqe placeholder of the srq can be released. Fixes: 6fe30a1a705f ("libhns: Introduce QP operations referred to hip08 RoCE device) Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx> Signed-off-by: Weihang Li <liweihang@xxxxxxxxxxxxx> --- providers/hns/hns_roce_u_hw_v2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index b473f07..7f5a2ce 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -1040,6 +1040,8 @@ out: static void __hns_roce_v2_cq_clean(struct hns_roce_cq *cq, uint32_t qpn, struct hns_roce_srq *srq) { + bool is_rcqe; + int wqe_index; int nfreed = 0; uint32_t prod_index; uint8_t owner_bit = 0; @@ -1055,6 +1057,14 @@ static void __hns_roce_v2_cq_clean(struct hns_roce_cq *cq, uint32_t qpn, cqe = get_cqe_v2(cq, prod_index & cq->ibv_cq.cqe); if ((roce_get_field(cqe->byte_16, CQE_BYTE_16_LCL_QPN_M, CQE_BYTE_16_LCL_QPN_S) & 0xffffff) == qpn) { + is_rcqe = roce_get_bit(cqe->byte_4, CQE_BYTE_4_S_R_S); + + if (srq && is_rcqe) { + wqe_index = roce_get_field(cqe->byte_4, + CQE_BYTE_4_WQE_IDX_M, + CQE_BYTE_4_WQE_IDX_S); + hns_roce_free_srq_wqe(srq, wqe_index); + } ++nfreed; } else if (nfreed) { dest = get_cqe_v2(cq, -- 2.8.1