From e7613ae249465ebca5434421199fe97aee845a90 Mon Sep 17 00:00:00 2001
From: wenglianfa <wenglianfa@huawei.com>
Date: Wed, 12 Jun 2024 17:11:13 +0800
Subject: [PATCH] libhns: Fix the exception branch of wr_start() is not locked

driver inclusion
category: feature
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/IB66RT

------------------------------------------------------------------

The provider should provide locking to ensure that ibv_wr_start()
and ibv_wr_complete()/abort() form a per-QP critical section
where no other threads can enter.

The exception branch of wr_start() is not locked, fix it here.
Because check_qp_send () does not require lock protection,
hns_roce_spin_lock () is placed after check_qp_send ().

Fixes: 36446a56eea5 ("libhns: Extended QP supports the new post send mechanism")

Signed-off-by: wenglianfa <wenglianfa@huawei.com>
Signed-off-by: Xinghai Cen <cenxinghai@h-partners.com>
---
 providers/hns/hns_roce_u_hw_v2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 465ef1e..e4232ea 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -2930,6 +2930,7 @@ static void wr_start(struct ibv_qp_ex *ibv_qp)
 
 	ret = check_qp_send(qp, ctx);
 	if (ret) {
+		hns_roce_spin_lock(&qp->sq.hr_lock);
 		qp->err = ret;
 		return;
 	}
-- 
2.25.1

