rdma-core/0055-libhns-separate-the-initialization-steps-of-lock.patch

114 lines
3.5 KiB
Diff
Raw Normal View History

From 87a32d939f7b4504c0a90adc0b0294adf5b8cad1 Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang@huawei.com>
Date: Tue, 26 Sep 2023 19:19:08 +0800
Subject: [PATCH 3/5] libhns: separate the initialization steps of lock
driver inclusion
category: cleanup
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I83BP0
----------------------------------------------------------
Separate the initialization steps of the lock from create_cq() and
create_srq(), just like in create_qp(), to unify all create-style
processes.
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
providers/hns/hns_roce_u_verbs.c | 48 +++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 8fb415b..e7a7388 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -545,13 +545,28 @@ static void hns_roce_uninit_cq_swc(struct hns_roce_cq *cq)
}
}
+static int hns_roce_cq_spinlock_init(struct ibv_context *context,
+ struct hns_roce_cq *cq,
+ struct ibv_cq_init_attr_ex *attr)
+{
+ struct hns_roce_pad *pad = NULL;
+ int need_lock;
+
+ if (attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_PD)
+ pad = to_hr_pad(attr->parent_domain);
+
+ need_lock = hns_roce_whether_need_lock(pad ? &pad->pd.ibv_pd : NULL);
+ if (!need_lock)
+ verbs_info(verbs_get_ctx(context), "configure cq as no lock.\n");
+
+ return hns_roce_spinlock_init(&cq->hr_lock, need_lock);
+}
+
static struct ibv_cq_ex *create_cq(struct ibv_context *context,
struct ibv_cq_init_attr_ex *attr)
{
struct hns_roce_context *hr_ctx = to_hr_ctx(context);
- struct hns_roce_pad *pad = NULL;
struct hns_roce_cq *cq;
- int need_lock;
int ret;
ret = verify_cq_create_attr(attr, hr_ctx);
@@ -564,14 +579,7 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *context,
goto err;
}
- if (attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_PD)
- pad = to_hr_pad(attr->parent_domain);
-
- need_lock = hns_roce_whether_need_lock(pad ? &pad->pd.ibv_pd : NULL);
- if (!need_lock)
- verbs_info(verbs_get_ctx(context), "configure cq as no lock.\n");
-
- ret = hns_roce_spinlock_init(&cq->hr_lock, need_lock);
+ ret = hns_roce_cq_spinlock_init(context, cq, attr);
if (ret)
goto err_lock;
@@ -889,12 +897,24 @@ static void init_srq_cq_list(struct hns_roce_srq *srq,
hns_roce_spin_unlock(&srq_cq->hr_lock);
}
+static int hns_roce_srq_spinlock_init(struct ibv_context *context,
+ struct hns_roce_srq *srq,
+ struct ibv_srq_init_attr_ex *attr)
+{
+ int need_lock;
+
+ need_lock = hns_roce_whether_need_lock(attr->pd);
+ if (!need_lock)
+ verbs_info(verbs_get_ctx(context), "configure srq as no lock.\n");
+
+ return hns_roce_spinlock_init(&srq->hr_lock, need_lock);
+}
+
static struct ibv_srq *create_srq(struct ibv_context *context,
struct ibv_srq_init_attr_ex *init_attr)
{
struct hns_roce_context *hr_ctx = to_hr_ctx(context);
struct hns_roce_srq *srq;
- int need_lock;
int ret;
ret = verify_srq_create_attr(hr_ctx, init_attr);
@@ -907,11 +927,7 @@ static struct ibv_srq *create_srq(struct ibv_context *context,
goto err;
}
- need_lock = hns_roce_whether_need_lock(init_attr->pd);
- if (!need_lock)
- verbs_info(verbs_get_ctx(context), "configure srq as no lock.\n");
-
- if (hns_roce_spinlock_init(&srq->hr_lock, need_lock))
+ if (hns_roce_srq_spinlock_init(context, srq, init_attr))
goto err_free_srq;
set_srq_param(context, srq, init_attr);
--
2.25.1