From f3c815425f6b14d6b0638a50752c7896793fd6a8 Mon Sep 17 00:00:00 2001 From: Yangyang Li Date: Fri, 8 Dec 2023 10:00:33 +0800 Subject: [PATCH] libhns: Bugfix for wrong timing of modifying ibv_qp state to err [ Upstream commit 886cf76ed44c58bacc9ac3451e4383bf8625385d ] Currently the QPC state in HW is modified inside the critical section of spinlock but the ibv_qp state is modified outside. There will be a short period when QPC state has been modified to err with ibv_qp state still remaining RTS. WQEs during this period will still be post-send by RTS-state ibv_qp but then dropped by err-state HW with no flush CQEs generated. To fix this problem, the QPC state in HW and ibv_qp state should be both modified to err inside the critical section of spinlock. Fixes: f1a80cc3dfe2 ("libhns: Bugfix for flush cqe in case multi-process") Signed-off-by: Yangyang Li Signed-off-by: Junxian Huang Signed-off-by: Nicolas Morey --- providers/hns/hns_roce_u_hw_v2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index d423cebc0..f782b214c 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -1552,6 +1552,8 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd)); if (flag) { + if (!ret) + qp->state = IBV_QPS_ERR; pthread_spin_unlock(&hr_qp->rq.lock); pthread_spin_unlock(&hr_qp->sq.lock); }