126 Star 3 Fork 18

src-openEuler/libwd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0017-uadk-drv-hisi-fix-failed-to-init-drv-after-fork.patch 4.02 KB
一键复制 编辑 原始数据 按行查看 历史
JangShui Yang 提交于 2024-04-07 18:05 . libwd: update the source code
From 6a6831101e99323fc5e9b63baa7e86ae8ac244ee Mon Sep 17 00:00:00 2001
From: Yang Shen <shenyang39@huawei.com>
Date: Thu, 22 Feb 2024 15:23:33 +0800
Subject: [PATCH 17/44] uadk: drv/hisi - fix failed to init drv after fork
The drivers initialization function use 'drv.priv' to forbid reinit.
But if the child process is forked after the parent process has
initialized, it can't work due to the drivers go to wrong branch on
initialization.
And the algorithms initialization function is already protected
against re-entry. So it is unnecessary to check 'drv.priv' in driver.
Signed-off-by: Yang Shen <shenyang39@huawei.com>
---
drv/hisi_comp.c | 7 +------
drv/hisi_hpre.c | 34 ++++++++++++++--------------------
drv/hisi_sec.c | 7 +------
3 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c
index 2cb9a6b..a1af567 100644
--- a/drv/hisi_comp.c
+++ b/drv/hisi_comp.c
@@ -787,18 +787,13 @@ static void hisi_zip_sqe_ops_adapt(handle_t h_qp)
static int hisi_zip_init(struct wd_alg_driver *drv, void *conf)
{
- struct hisi_zip_ctx *priv = (struct hisi_zip_ctx *)drv->priv;
struct wd_ctx_config_internal *config = conf;
struct hisi_qm_priv qm_priv;
+ struct hisi_zip_ctx *priv;
handle_t h_qp = 0;
handle_t h_ctx;
__u32 i, j;
- if (priv) {
- /* return if already inited */
- return 0;
- }
-
if (!config->ctx_num) {
WD_ERR("invalid: zip init config ctx num is 0!\n");
return -WD_EINVAL;
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
index 049e60e..babc795 100644
--- a/drv/hisi_hpre.c
+++ b/drv/hisi_hpre.c
@@ -527,62 +527,56 @@ out:
static int hpre_rsa_dh_init(struct wd_alg_driver *drv, void *conf)
{
struct wd_ctx_config_internal *config = (struct wd_ctx_config_internal *)conf;
- struct hisi_hpre_ctx *priv = (struct hisi_hpre_ctx *)drv->priv;
struct hisi_qm_priv qm_priv;
+ struct hisi_hpre_ctx *priv;
int ret;
- if (priv) {
- /* return if already inited */
- return WD_SUCCESS;
- }
-
if (!config->ctx_num) {
WD_ERR("invalid: hpre rsa/dh init config ctx num is 0!\n");
return -WD_EINVAL;
}
- drv->priv = malloc(sizeof(struct hisi_hpre_ctx));
- if (!drv->priv)
+ priv = malloc(sizeof(struct hisi_hpre_ctx));
+ if (!priv)
return -WD_EINVAL;
qm_priv.op_type = HPRE_HW_V2_ALG_TYPE;
- ret = hpre_init_qm_priv(config, drv->priv, &qm_priv);
+ ret = hpre_init_qm_priv(config, priv, &qm_priv);
if (ret) {
- free(drv->priv);
+ free(priv);
return ret;
}
+ drv->priv = priv;
+
return WD_SUCCESS;
}
static int hpre_ecc_init(struct wd_alg_driver *drv, void *conf)
{
struct wd_ctx_config_internal *config = (struct wd_ctx_config_internal *)conf;
- struct hisi_hpre_ctx *priv = (struct hisi_hpre_ctx *)drv->priv;
struct hisi_qm_priv qm_priv;
+ struct hisi_hpre_ctx *priv;
int ret;
- if (priv) {
- /* return if already inited */
- return WD_SUCCESS;
- }
-
if (!config->ctx_num) {
WD_ERR("invalid: hpre ecc init config ctx num is 0!\n");
return -WD_EINVAL;
}
- drv->priv = malloc(sizeof(struct hisi_hpre_ctx));
- if (!drv->priv)
+ priv = malloc(sizeof(struct hisi_hpre_ctx));
+ if (!priv)
return -WD_EINVAL;
qm_priv.op_type = HPRE_HW_V3_ECC_ALG_TYPE;
- ret = hpre_init_qm_priv(config, drv->priv, &qm_priv);
+ ret = hpre_init_qm_priv(config, priv, &qm_priv);
if (ret) {
- free(drv->priv);
+ free(priv);
return ret;
}
+ drv->priv = priv;
+
return WD_SUCCESS;
}
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index ac62109..852340d 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -3041,18 +3041,13 @@ static int hisi_sec_aead_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *
static int hisi_sec_init(struct wd_alg_driver *drv, void *conf)
{
- struct hisi_sec_ctx *priv = (struct hisi_sec_ctx *)drv->priv;
struct wd_ctx_config_internal *config = conf;
struct hisi_qm_priv qm_priv;
+ struct hisi_sec_ctx *priv;
handle_t h_qp = 0;
handle_t h_ctx;
__u32 i, j;
- if (priv) {
- /* return if already inited */
- return 0;
- }
-
if (!config->ctx_num) {
WD_ERR("invalid: sec init config ctx num is 0!\n");
return -WD_EINVAL;
--
2.25.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/libwd.git
git@gitee.com:src-openeuler/libwd.git
src-openeuler
libwd
libwd
master

搜索帮助