代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。