libhns:Fixes several bugs for hns

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IALOAP

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

Fixes several bugs for hns:
libhns: Fix overwritten SL in DSCP mode
libhns: Support returning the final value of SL configuration
libhns: Fix memory leakage when DCA is enabled
libhns: Fix the exception branch of wr_start() is not locked

Signed-off-by: Xinghai Cen <cenxinghai@h-partners.com>
(cherry picked from commit f7e92a7c61500e17a864d2e016e842436bd1f442)
This commit is contained in:
Xinghai Cen 2024-08-22 16:15:57 +08:00 committed by openeuler-sync-bot
parent dd5e2c84dd
commit 4ece021efa
5 changed files with 158 additions and 1 deletions

View File

@ -0,0 +1,44 @@
From 40e7e1643cd67bbdd0865372c4ff64d42d1aaf0b Mon Sep 17 00:00:00 2001
From: Luoyouming <luoyouming@huawei.com>
Date: Mon, 29 Jan 2024 15:38:18 +0800
Subject: [PATCH 1/4] libhns: Fix overwritten SL in DSCP mode
After configuring the DSCP mode, the driver needs to use the
priority as the SL instead of the user-configured SL.
Adjusting the assignment order ensures that the priority is
used as the SL in DSCP mode.
Fixes: 6ec5d1f3f04c ("libhns: Support DSCP")
Signed-off-by: Luoyouming <luoyouming@huawei.com>
---
providers/hns/hns_roce_u_hw_v2.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 8f071e1..42b4f32 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -1896,7 +1896,9 @@ static void record_qp_attr(struct ibv_qp *qp, struct ibv_qp_attr *attr,
if (attr_mask & IBV_QP_PORT)
hr_qp->port_num = attr->port_num;
- if (attr_mask & IBV_QP_AV)
+ if (hr_qp->tc_mode == HNS_ROCE_TC_MAP_MODE_DSCP)
+ hr_qp->sl = hr_qp->priority;
+ else if (attr_mask & IBV_QP_AV)
hr_qp->sl = attr->ah_attr.sl;
if (attr_mask & IBV_QP_QKEY)
@@ -1959,9 +1961,6 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
hns_roce_init_qp_indices(to_hr_qp(qp));
}
- if (hr_qp->tc_mode == HNS_ROCE_TC_MAP_MODE_DSCP)
- hr_qp->sl = hr_qp->priority;
-
/* Try to shrink the DCA mem */
if (ctx->dca_ctx.mem_cnt > 0)
hns_roce_shrink_dca_mem(ctx);
--
2.33.0

View File

@ -0,0 +1,34 @@
From fc50769b446a5418767058cd2a5b5e7a9724a391 Mon Sep 17 00:00:00 2001
From: Luoyouming <luoyouming@huawei.com>
Date: Mon, 29 Jan 2024 16:12:55 +0800
Subject: [PATCH 2/4] libhns: Support returning the final value of SL
configuration
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Returns the real SL used in HW to user, which can be used in variety of scenarios.
E.g. The STARS mode.
Signed-off-by: Luoyouming <luoyouming@huawei.com>
---
providers/hns/hns_roce_u_hw_v2.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 42b4f32..af25e6e 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -1967,6 +1967,9 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
record_qp_attr(qp, attr, attr_mask);
+ // Update the SL value and return it to the user.
+ attr->ah_attr.sl = hr_qp->sl;
+
return ret;
}
--
2.33.0

View File

@ -0,0 +1,34 @@
From 485a60f8850630c37856f68be3fbf37bfa9ac019 Mon Sep 17 00:00:00 2001
From: wenglianfa <wenglianfa@huawei.com>
Date: Thu, 25 Jul 2024 11:06:01 +0800
Subject: [PATCH 3/4] libhns: Fix memory leakage when DCA is enabled
After DCA is enabled and a QP is created, the memory block
applied for DCA is not free when the QP is destroyed. Here
fix it.
Fixes: 3aa4683ef700 ("libhns: Add support for attaching QP's WQE buffer")
Signed-off-by: wenglianfa <wenglianfa@huawei.com>
---
providers/hns/hns_roce_u_verbs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 090efbf..dae8298 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -1617,7 +1617,10 @@ static void qp_free_wqe(struct hns_roce_qp *qp)
if (qp->rq.wqe_cnt)
free(qp->rq.wrid);
- hns_roce_free_buf(&qp->buf);
+ if (qp->dca_wqe.bufs)
+ free(qp->dca_wqe.bufs);
+ else
+ hns_roce_free_buf(&qp->buf);
}
static int qp_alloc_wqe(struct ibv_qp_init_attr_ex *attr,
--
2.33.0

View File

@ -0,0 +1,35 @@
From 41592115435779d7c41e7f1677520b9c641289d9 Mon Sep 17 00:00:00 2001
From: wenglianfa <wenglianfa@huawei.com>
Date: Wed, 12 Jun 2024 17:11:13 +0800
Subject: [PATCH 4/4] libhns: Fix the exception branch of wr_start() is not
locked
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>
---
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 af25e6e..79f225c 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -2975,6 +2975,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.33.0

View File

@ -1,6 +1,6 @@
Name: rdma-core Name: rdma-core
Version: 41.0 Version: 41.0
Release: 26 Release: 27
Summary: RDMA core userspace libraries and daemons Summary: RDMA core userspace libraries and daemons
License: GPLv2 or BSD License: GPLv2 or BSD
Url: https://github.com/linux-rdma/rdma-core Url: https://github.com/linux-rdma/rdma-core
@ -88,6 +88,10 @@ patch79: 0079-libhns-Removes-a-repeated-initialization-of-a-spinlo.patch
patch80: 0080-libhns-Fix-owner-bit-when-SQ-wraps-around-in-new-IO.patch patch80: 0080-libhns-Fix-owner-bit-when-SQ-wraps-around-in-new-IO.patch
patch81: 0081-libhns-Fix-missing-DB-when-compiler-does-not-support.patch patch81: 0081-libhns-Fix-missing-DB-when-compiler-does-not-support.patch
patch82: 0082-ibnetdisc-Fix-leak-in-add_to_portlid_hash.patch patch82: 0082-ibnetdisc-Fix-leak-in-add_to_portlid_hash.patch
patch83: 0083-libhns-Fix-overwritten-SL-in-DSCP-mode.patch
patch84: 0084-libhns-Support-returning-the-final-value-of-SL-confi.patch
patch85: 0085-libhns-Fix-memory-leakage-when-DCA-is-enabled.patch
patch86: 0086-libhns-Fix-the-exception-branch-of-wr_start-is-not-l.patch
BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0) BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0)
BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel
@ -335,6 +339,12 @@ fi
%{_mandir}/* %{_mandir}/*
%changelog %changelog
* Thu Aug 22 2024 Xinghai Cen <cenxinghai@h-partners.com> - 41.0-27
- Type: bugfix
- ID: NA
- SUG: NA
- DESC: Fixes several bugs for hns
* Thu Aug 8 2024 yanshuai <yanshuai01@kylinos.cn> - 41.0-26 * Thu Aug 8 2024 yanshuai <yanshuai01@kylinos.cn> - 41.0-26
- Type: bugfix - Type: bugfix
- ID: NA - ID: NA