From 6d09f184653da67730140b859095dd9e15a66827 Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:25 +0800 Subject: [PATCH 01/11] uadk: remove unused inner async poll The internal asynchronous polling interface is not used in any scenario, remove it. Signed-off-by: Weili Qian --- docs/wd_environment_variable | 7 - include/wd_aead.h | 3 +- include/wd_cipher.h | 3 +- include/wd_comp.h | 3 +- include/wd_digest.h | 3 +- include/wd_ecc.h | 3 +- include/wd_rsa.h | 3 +- include/wd_util.h | 37 ---- test/sanity_test.sh | 2 - wd_aead.c | 24 +- wd_cipher.c | 24 +- wd_comp.c | 28 +-- wd_dh.c | 24 +- wd_digest.c | 24 +- wd_ecc.c | 24 +- wd_rsa.c | 24 +- wd_util.c | 418 +---------------------------------- 17 files changed, 70 insertions(+), 584 deletions(-) diff --git a/docs/wd_environment_variable b/docs/wd_environment_variable index 828208aae..914def346 100644 --- a/docs/wd_environment_variable +++ b/docs/wd_environment_variable @@ -13,13 +13,6 @@ offer process level WD configures. 1. WD environment variables define ================================== -WD__ASYNC_POLL_EN ----------------------- - - Define if enble polling threads in WD. WD__ASYNC_POLL_EN=1 means enable - polling threads in WD, otherwise caller should poll finished request by - WD APIs. - WD_COMP_CTX_NUM ----------------- diff --git a/include/wd_aead.h b/include/wd_aead.h index 4b5095f92..3585c862b 100644 --- a/include/wd_aead.h +++ b/include/wd_aead.h @@ -254,7 +254,8 @@ void wd_aead_ctx_num_uninit(void); * @type: operation type. * @mode: 0: sync mode, 1: async mode * @num: return ctx num. - * @is_enable return enable inner poll flag. + * @is_enable: return enable inner poll flag, inner poll is not + * supported, and is_enable will always be 0. * * If the current algorithm library does not require the type parameter, * the type parameter is invalid. The function returns 0 to indicate that diff --git a/include/wd_cipher.h b/include/wd_cipher.h index a6f8be12b..383d31537 100644 --- a/include/wd_cipher.h +++ b/include/wd_cipher.h @@ -218,7 +218,8 @@ void wd_cipher_ctx_num_uninit(void); * @type: operation type. * @mode: 0: sync mode, 1: async mode * @num: return ctx num. - * @is_enable return enable inner poll flag. + * @is_enable: return enable inner poll flag, inner poll is not + * supported, and is_enable will always be 0. */ int wd_cipher_get_env_param(__u32 node, __u32 type, __u32 mode, __u32 *num, __u8 *is_enable); diff --git a/include/wd_comp.h b/include/wd_comp.h index 5d095369b..2cbefd741 100644 --- a/include/wd_comp.h +++ b/include/wd_comp.h @@ -251,7 +251,8 @@ void wd_comp_ctx_num_uninit(void); * @type: operation type. * @mode: 0: sync mode, 1: async mode * @num: return ctx num. - * @is_enable return enable inner poll flag. + * @is_enable: return enable inner poll flag, inner poll is not + * supported, and is_enable will always be 0. * * If the current algorithm library does not require the type parameter, * the type parameter is invalid. The function returns 0 to indicate that diff --git a/include/wd_digest.h b/include/wd_digest.h index 42a95db3c..410c7f991 100644 --- a/include/wd_digest.h +++ b/include/wd_digest.h @@ -278,7 +278,8 @@ void wd_digest_ctx_num_uninit(void); * @type: operation type. * @mode: 0: sync mode, 1: async mode * @num: return ctx num. - * @is_enable return enable inner poll flag. + * @is_enable: return enable inner poll flag, inner poll is not + * supported, and is_enable will always be 0. */ int wd_digest_get_env_param(__u32 node, __u32 type, __u32 mode, __u32 *num, __u8 *is_enable); diff --git a/include/wd_ecc.h b/include/wd_ecc.h index 18c1c0d0c..d86895108 100644 --- a/include/wd_ecc.h +++ b/include/wd_ecc.h @@ -548,7 +548,8 @@ void wd_ecc_ctx_num_uninit(void); * @type: operation type. * @mode: 0: sync mode, 1: async mode * @num: return ctx num. - * @is_enable return enable inner poll flag. + * @is_enable: return enable inner poll flag, inner poll is not + * supported, and is_enable will always be 0. */ int wd_ecc_get_env_param(__u32 node, __u32 type, __u32 mode, __u32 *num, __u8 *is_enable); diff --git a/include/wd_rsa.h b/include/wd_rsa.h index 9c9143252..b0ead0a7e 100644 --- a/include/wd_rsa.h +++ b/include/wd_rsa.h @@ -239,7 +239,8 @@ void wd_rsa_ctx_num_uninit(void); * @type: operation type. * @mode: 0: sync mode, 1: async mode * @num: return ctx num. - * @is_enable return enable inner poll flag. + * @is_enable: return enable inner poll flag, inner poll is not + * supported, and is_enable will always be 0. */ int wd_rsa_get_env_param(__u32 node, __u32 type, __u32 mode, __u32 *num, __u8 *is_enable); diff --git a/include/wd_util.h b/include/wd_util.h index 2abceec27..341274130 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -78,16 +78,10 @@ struct wd_env_config_per_numa { /* Resource begin */ struct uacce_dev *dev; int dev_num; - /* This can be made statically currently */ - unsigned long async_poll_num; - void *async_task_queue_array; }; struct wd_env_config { struct wd_env_config_per_numa *config_per_numa; - /* Let's make it as a gobal config, not per numa */ - bool enable_internal_poll; - /* resource config */ struct wd_sched *sched; bool internal_sched; @@ -270,28 +264,6 @@ int wd_check_datalist(struct wd_datalist *head, __u64 size); */ int wd_parse_ctx_num(struct wd_env_config *config, const char *s); -/* - * wd_parse_async_poll_en() - Parse async polling thread related environment - * variable and store it. - * @config: Pointer of wd_env_config which is used to store environment - * variable information. - * @s: Related environment variable string. - * - * More information, please see docs/wd_environment_variable. - */ -int wd_parse_async_poll_en(struct wd_env_config *config, const char *s); - -/* - * wd_parse_async_poll_num() - Parse async polling thread related environment - * variable and store it. - * @config: Pointer of wd_env_config which is used to store environment - * variable information. - * @s: Related environment variable string. - * - * More information, please see docs/wd_environment_variable. - */ -int wd_parse_async_poll_num(struct wd_env_config *config, const char *s); - /* * wd_alg_env_init() - Init wd algorithm environment variable configurations. * This is a help function which can be used by specific @@ -320,15 +292,6 @@ int wd_alg_env_init(struct wd_env_config *env_config, void wd_alg_env_uninit(struct wd_env_config *env_config, const struct wd_alg_ops *ops); -/* - * wd_add_task_to_async_queue() - Add an async request to its related async - * task queue. - * @config: Pointer of wd_env_config which is used to store environment - * variable information. - * @idx: Index of ctx in config. - */ -int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx); - /* * dump_env_info() - dump wd algorithm ctx info. * @config: Pointer of wd_env_config which is used to store environment diff --git a/test/sanity_test.sh b/test/sanity_test.sh index e7650934d..50ba77f44 100755 --- a/test/sanity_test.sh +++ b/test/sanity_test.sh @@ -397,8 +397,6 @@ run_zip_test_v2() return 0 fi export WD_COMP_CTX_NUM="sync-comp:4@0,sync-decomp:4@0,async-comp:4@0,async-decomp:4@0" - export WD_COMP_ASYNC_POLL_EN=1 - export WD_COMP_ASYNC_POLL_NUM="4@0" # test without environment variables # limit test text file in 8MB rm -fr /tmp/textfile diff --git a/wd_aead.c b/wd_aead.c index 74d652bf5..42dc774e8 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -960,9 +960,6 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_aead_env_config, idx); - if (ret) - goto fail_with_msg; return 0; @@ -1042,15 +1039,10 @@ int wd_aead_poll(__u32 expt, __u32 *count) return sched->poll_policy(h_ctx, expt, count); } -static const struct wd_config_variable table[] = { - { .name = "WD_AEAD_CTX_NUM", - .def_val = "sync:2@0,async:2@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_AEAD_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - } +static const struct wd_config_variable table = { + .name = "WD_AEAD_CTX_NUM", + .def_val = "sync:2@0,async:2@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_aead_ops = { @@ -1065,8 +1057,8 @@ int wd_aead_env_init(struct wd_sched *sched) { wd_aead_env_config.sched = sched; - return wd_alg_env_init(&wd_aead_env_config, table, - &wd_aead_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_aead_env_config, &table, + &wd_aead_ops, 1, NULL); } void wd_aead_env_uninit(void) @@ -1083,8 +1075,8 @@ int wd_aead_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_aead_env_config, table, - &wd_aead_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_aead_env_config, &table, + &wd_aead_ops, 1, &ctx_attr); } void wd_aead_ctx_num_uninit(void) diff --git a/wd_cipher.c b/wd_cipher.c index 1c54d729f..5258191fc 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -805,9 +805,6 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_cipher_env_config, idx); - if (ret) - goto fail_with_msg; return 0; @@ -888,15 +885,10 @@ int wd_cipher_poll(__u32 expt, __u32 *count) return sched->poll_policy(h_ctx, expt, count); } -static const struct wd_config_variable table[] = { - { .name = "WD_CIPHER_CTX_NUM", - .def_val = "sync:2@0,async:2@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_CIPHER_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - } +static const struct wd_config_variable table = { + .name = "WD_CIPHER_CTX_NUM", + .def_val = "sync:2@0,async:2@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_cipher_ops = { @@ -911,8 +903,8 @@ int wd_cipher_env_init(struct wd_sched *sched) { wd_cipher_env_config.sched = sched; - return wd_alg_env_init(&wd_cipher_env_config, table, - &wd_cipher_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_cipher_env_config, &table, + &wd_cipher_ops, 1, NULL); } void wd_cipher_env_uninit(void) @@ -929,8 +921,8 @@ int wd_cipher_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_cipher_env_config, table, - &wd_cipher_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_cipher_env_config, &table, + &wd_cipher_ops, 1, &ctx_attr); } void wd_cipher_ctx_num_uninit(void) diff --git a/wd_comp.c b/wd_comp.c index 00445b29f..112e92c26 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -883,9 +883,6 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_comp_env_config, idx); - if (unlikely(ret)) - goto fail_with_msg; return 0; @@ -911,19 +908,10 @@ int wd_comp_poll(__u32 expt, __u32 *count) return sched->poll_policy(h_sched_ctx, expt, count); } -static const struct wd_config_variable table[] = { - { .name = "WD_COMP_CTX_NUM", - .def_val = "sync-comp:1@0,sync-decomp:1@0,async-comp:1@0,async-decomp:1@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_COMP_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - }, - { .name = "WD_COMP_ASYNC_POLL_NUM", - .def_val = "1@0", - .parse_fn = wd_parse_async_poll_num - } +static const struct wd_config_variable table = { + .name = "WD_COMP_CTX_NUM", + .def_val = "sync-comp:1@0,sync-decomp:1@0,async-comp:1@0,async-decomp:1@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_comp_ops = { @@ -938,8 +926,8 @@ int wd_comp_env_init(struct wd_sched *sched) { wd_comp_env_config.sched = sched; - return wd_alg_env_init(&wd_comp_env_config, table, - &wd_comp_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_comp_env_config, &table, + &wd_comp_ops, 1, NULL); } void wd_comp_env_uninit(void) @@ -961,8 +949,8 @@ int wd_comp_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_comp_env_config, table, - &wd_comp_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_comp_env_config, &table, + &wd_comp_ops, 1, &ctx_attr); } void wd_comp_ctx_num_uninit(void) diff --git a/wd_dh.c b/wd_dh.c index 0c1372c50..9a0176b8f 100644 --- a/wd_dh.c +++ b/wd_dh.c @@ -446,9 +446,6 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_dh_env_config, idx); - if (ret) - goto fail_with_msg; return WD_SUCCESS; @@ -659,15 +656,10 @@ void wd_dh_free_sess(handle_t sess) free(sess_t); } -static const struct wd_config_variable table[] = { - { .name = "WD_DH_CTX_NUM", - .def_val = "sync:2@0,async:2@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_DH_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - } +static const struct wd_config_variable table = { + .name = "WD_DH_CTX_NUM", + .def_val = "sync:2@0,async:2@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_dh_ops = { @@ -682,8 +674,8 @@ int wd_dh_env_init(struct wd_sched *sched) { wd_dh_env_config.sched = sched; - return wd_alg_env_init(&wd_dh_env_config, table, - &wd_dh_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_dh_env_config, &table, + &wd_dh_ops, 1, NULL); } void wd_dh_env_uninit(void) @@ -700,8 +692,8 @@ int wd_dh_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_dh_env_config, table, - &wd_dh_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_dh_env_config, &table, + &wd_dh_ops, 1, &ctx_attr); } void wd_dh_ctx_num_uninit(void) diff --git a/wd_digest.c b/wd_digest.c index 0b37f8bac..e0341e6b3 100644 --- a/wd_digest.c +++ b/wd_digest.c @@ -759,9 +759,6 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_digest_env_config, idx); - if (ret) - goto fail_with_msg; return 0; @@ -843,15 +840,10 @@ int wd_digest_poll(__u32 expt, __u32 *count) return sched->poll_policy(h_ctx, expt, count); } -static const struct wd_config_variable table[] = { - { .name = "WD_DIGEST_CTX_NUM", - .def_val = "sync:2@0,async:2@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_DIGEST_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - } +static const struct wd_config_variable table = { + .name = "WD_DIGEST_CTX_NUM", + .def_val = "sync:2@0,async:2@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_digest_ops = { @@ -866,8 +858,8 @@ int wd_digest_env_init(struct wd_sched *sched) { wd_digest_env_config.sched = sched; - return wd_alg_env_init(&wd_digest_env_config, table, - &wd_digest_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_digest_env_config, &table, + &wd_digest_ops, 1, NULL); } void wd_digest_env_uninit(void) @@ -884,8 +876,8 @@ int wd_digest_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_digest_env_config, table, - &wd_digest_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_digest_env_config, &table, + &wd_digest_ops, 1, &ctx_attr); } void wd_digest_ctx_num_uninit(void) diff --git a/wd_ecc.c b/wd_ecc.c index 2c88d0a15..dae8a05da 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -2348,9 +2348,6 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_ecc_env_config, idx); - if (ret) - goto fail_with_msg; return WD_SUCCESS; @@ -2430,15 +2427,10 @@ int wd_ecc_poll(__u32 expt, __u32 *count) return wd_ecc_setting.sched.poll_policy(h_sched_sess, expt, count); } -static const struct wd_config_variable table[] = { - { .name = "WD_ECC_CTX_NUM", - .def_val = "sync:2@0,async:2@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_ECC_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - } +static const struct wd_config_variable table = { + .name = "WD_ECC_CTX_NUM", + .def_val = "sync:2@0,async:2@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_ecc_ops = { @@ -2453,8 +2445,8 @@ int wd_ecc_env_init(struct wd_sched *sched) { wd_ecc_env_config.sched = sched; - return wd_alg_env_init(&wd_ecc_env_config, table, - &wd_ecc_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_ecc_env_config, &table, + &wd_ecc_ops, 1, NULL); } void wd_ecc_env_uninit(void) @@ -2471,8 +2463,8 @@ int wd_ecc_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_ecc_env_config, table, - &wd_ecc_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_ecc_env_config, &table, + &wd_ecc_ops, 1, &ctx_attr); } void wd_ecc_ctx_num_uninit(void) diff --git a/wd_rsa.c b/wd_rsa.c index bc78c6ac7..93ec33645 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -507,9 +507,6 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req) } wd_dfx_msg_cnt(config, WD_CTX_CNT_NUM, idx); - ret = wd_add_task_to_async_queue(&wd_rsa_env_config, idx); - if (ret) - goto fail_with_msg; return WD_SUCCESS; @@ -1271,15 +1268,10 @@ void wd_rsa_get_prikey(handle_t sess, struct wd_rsa_prikey **prikey) *prikey = ((struct wd_rsa_sess *)sess)->prikey; } -static const struct wd_config_variable table[] = { - { .name = "WD_RSA_CTX_NUM", - .def_val = "sync:2@0,async:2@0", - .parse_fn = wd_parse_ctx_num - }, - { .name = "WD_RSA_ASYNC_POLL_EN", - .def_val = "0", - .parse_fn = wd_parse_async_poll_en - } +static const struct wd_config_variable table = { + .name = "WD_RSA_CTX_NUM", + .def_val = "sync:2@0,async:2@0", + .parse_fn = wd_parse_ctx_num }; static const struct wd_alg_ops wd_rsa_ops = { @@ -1294,8 +1286,8 @@ int wd_rsa_env_init(struct wd_sched *sched) { wd_rsa_env_config.sched = sched; - return wd_alg_env_init(&wd_rsa_env_config, table, - &wd_rsa_ops, ARRAY_SIZE(table), NULL); + return wd_alg_env_init(&wd_rsa_env_config, &table, + &wd_rsa_ops, 1, NULL); } void wd_rsa_env_uninit(void) @@ -1312,8 +1304,8 @@ int wd_rsa_ctx_num_init(__u32 node, __u32 type, __u32 num, __u8 mode) if (ret) return ret; - return wd_alg_env_init(&wd_rsa_env_config, table, - &wd_rsa_ops, ARRAY_SIZE(table), &ctx_attr); + return wd_alg_env_init(&wd_rsa_env_config, &table, + &wd_rsa_ops, 1, &ctx_attr); } void wd_rsa_ctx_num_uninit(void) diff --git a/wd_util.c b/wd_util.c index bf82fc149..33aeee603 100644 --- a/wd_util.c +++ b/wd_util.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include "wd_sched.h" @@ -72,27 +71,6 @@ static const char *wd_env_name[WD_TYPE_MAX] = { "WD_JOIN_GATHER_CTX_NUM", }; -struct async_task { - __u32 idx; -}; - -struct async_task_queue { - struct async_task *head; - int depth; - /* the producer offset of task queue */ - int prod; - /* the consumer offset of task queue */ - int cons; - int cur_task; - int left_task; - int end; - sem_t empty_sem; - sem_t full_sem; - pthread_mutex_t lock; - pthread_t tid; - int (*alg_poll_ctx)(__u32, __u32, __u32 *); -}; - struct drv_lib_list { void *dlhandle; struct drv_lib_list *next; @@ -782,17 +760,6 @@ static int str_to_bool(const char *s, bool *target) return 0; } -int wd_parse_async_poll_en(struct wd_env_config *config, const char *s) -{ - int ret; - - ret = str_to_bool(s, &config->enable_internal_poll); - if (ret) - WD_ERR("failed to parse async poll enable flag(%s)!\n", s); - - return ret; -} - static int parse_num_on_numa(const char *s, int *num, int *node) { char *sep, *start, *left; @@ -1034,41 +1001,6 @@ int wd_parse_ctx_num(struct wd_env_config *config, const char *s) return parse_ctx_num(config, s); } -int wd_parse_async_poll_num(struct wd_env_config *config, const char *s) -{ - struct wd_env_config_per_numa *config_numa; - char *left, *section, *start; - int node, poll_num, ret; - - if (!config->enable_internal_poll) { - WD_ERR("internal poll not enabled, skip parse poll number!\n"); - return 0; - } - - start = strdup(s); - if (!start) - return -ENOMEM; - - left = start; - while ((section = strsep(&left, ","))) { - ret = parse_num_on_numa(section, &poll_num, &node); - if (ret) - goto out; - config_numa = wd_get_config_numa(config, node); - if (!config_numa) { - ret = -WD_EINVAL; - goto out; - } - config_numa->async_poll_num = poll_num; - } - - free(start); - return 0; -out: - free(start); - return ret; -} - static int wd_parse_env(struct wd_env_config *config) { const struct wd_config_variable *var; @@ -1117,8 +1049,6 @@ static int wd_parse_ctx_attr(struct wd_env_config *env_config, /* Use default sched and disable internal poll */ env_config->sched = NULL; - env_config->enable_internal_poll = 0; - config_numa->async_poll_num = 0; return 0; } @@ -1345,21 +1275,17 @@ static int wd_init_sched_config(struct wd_env_config *config, { struct wd_env_config_per_numa *config_numa; int i, j, ret, max_node, type_num; - void *func = NULL; type_num = config->op_type_num; max_node = numa_max_node() + 1; if (max_node <= 0) return -WD_EINVAL; - if (!config->enable_internal_poll) - func = alg_poll_ctx; - config->internal_sched = false; if (!config->sched) { WD_ERR("no sched is specified, alloc a default sched!\n"); config->sched = wd_sched_rr_alloc(SCHED_POLICY_RR, type_num, - max_node, func); + max_node, alg_poll_ctx); if (!config->sched) return -WD_ENOMEM; @@ -1386,339 +1312,6 @@ static int wd_init_sched_config(struct wd_env_config *config, return ret; } -static struct async_task_queue *find_async_queue(struct wd_env_config *config, - __u32 idx) -{ - struct wd_env_config_per_numa *config_numa; - struct wd_ctx_range **ctx_table; - struct async_task_queue *head; - unsigned long offset = 0; - __u32 i, num = 0; - - FOREACH_NUMA(i, config, config_numa) { - num += config_numa->sync_ctx_num + config_numa->async_ctx_num; - if (idx < num) - break; - } - - if (i == config->numa_num) { - WD_ERR("failed to find a proper numa node!\n"); - return NULL; - } - - if (!config_numa->async_poll_num) { - WD_ERR("invalid: async_poll_num of numa is zero!\n"); - return NULL; - } - - ctx_table = config_numa->ctx_table; - for (i = 0; i < config_numa->op_type_num; i++) { - if (idx <= ctx_table[CTX_MODE_ASYNC][i].end && - idx >= ctx_table[CTX_MODE_ASYNC][i].begin) { - offset = (idx - ctx_table[CTX_MODE_ASYNC][i].begin) % - config_numa->async_poll_num; - break; - } - } - - if (i == config_numa->op_type_num) { - WD_ERR("failed to find async queue for ctx: idx %u!\n", idx); - return NULL; - } - - head = (struct async_task_queue *)config_numa->async_task_queue_array; - - return head + offset; -} - -int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx) -{ - struct async_task_queue *task_queue; - struct async_task *task; - int curr_prod, ret; - - if (!config->enable_internal_poll) - return 0; - - task_queue = find_async_queue(config, idx); - if (!task_queue) - return -WD_EINVAL; - - ret = sem_wait(&task_queue->empty_sem); - if (ret) { - WD_ERR("failed to wait empty_sem!\n"); - return ret; - } - - pthread_mutex_lock(&task_queue->lock); - - /* get an available async task and fill ctx idx */ - curr_prod = task_queue->prod; - task = task_queue->head + curr_prod; - task->idx = idx; - - /* update global information of task queue */ - task_queue->prod = (curr_prod + 1) % task_queue->depth; - task_queue->cur_task++; - task_queue->left_task--; - - pthread_mutex_unlock(&task_queue->lock); - - ret = sem_post(&task_queue->full_sem); - if (ret) { - WD_ERR("failed to post full_sem!\n"); - goto err_out; - } - - return 0; - -err_out: - pthread_mutex_lock(&task_queue->lock); - task_queue->left_task++; - task_queue->cur_task--; - task_queue->prod = curr_prod; - pthread_mutex_unlock(&task_queue->lock); - sem_post(&task_queue->empty_sem); - - return ret; -} - -static void *async_poll_process_func(void *args) -{ - struct async_task_queue *task_queue = args; - struct async_task *head, *task; - __u32 count; - int cons, ret; - - while (1) { - if (sem_wait(&task_queue->full_sem)) { - if (errno == EINTR) { - continue; - } - } - if (__atomic_load_n(&task_queue->end, __ATOMIC_ACQUIRE)) { - __atomic_store_n(&task_queue->end, 0, __ATOMIC_RELEASE); - goto out; - } - - pthread_mutex_lock(&task_queue->lock); - - /* async sending message isn't submitted yet */ - if (task_queue->cons == task_queue->prod) { - pthread_mutex_unlock(&task_queue->lock); - sem_post(&task_queue->full_sem); - continue; - } - - cons = task_queue->cons; - head = task_queue->head; - task = head + cons; - - task_queue->cons = (cons + 1) % task_queue->depth; - task_queue->cur_task--; - task_queue->left_task++; - - pthread_mutex_unlock(&task_queue->lock); - - ret = task_queue->alg_poll_ctx(task->idx, 1, &count); - if (ret < 0) { - pthread_mutex_lock(&task_queue->lock); - task_queue->cons = cons; - task_queue->cur_task++; - task_queue->left_task--; - pthread_mutex_unlock(&task_queue->lock); - if (ret == -WD_EAGAIN) { - sem_post(&task_queue->full_sem); - continue; - } else - goto out; - } - - if (sem_post(&task_queue->empty_sem)) - goto out; - } -out: - return NULL; -} - -static int wd_init_one_task_queue(struct async_task_queue *task_queue, - void *alg_poll_ctx) - -{ - struct async_task *head; - pthread_t thread_id; - pthread_attr_t attr; - int depth, ret; - - task_queue->depth = depth = WD_ASYNC_DEF_QUEUE_DEPTH; - - head = calloc(task_queue->depth, sizeof(*head)); - if (!head) - return -WD_ENOMEM; - - task_queue->head = head; - task_queue->left_task = depth; - task_queue->alg_poll_ctx = alg_poll_ctx; - - if (sem_init(&task_queue->empty_sem, 0, depth)) { - WD_ERR("failed to init empty_sem!\n"); - goto err_free_head; - } - - if (sem_init(&task_queue->full_sem, 0, 0)) { - WD_ERR("failed to init full_sem!\n"); - goto err_uninit_empty_sem; - } - - if (pthread_mutex_init(&task_queue->lock, NULL)) { - WD_ERR("failed to init task queue's mutex lock!\n"); - goto err_uninit_full_sem; - } - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - task_queue->tid = 0; - if (pthread_create(&thread_id, &attr, async_poll_process_func, - task_queue)) { - WD_ERR("failed to create poll thread!\n"); - goto err_destory_mutex; - } - - task_queue->tid = thread_id; - pthread_attr_destroy(&attr); - - return 0; - -err_destory_mutex: - pthread_attr_destroy(&attr); - pthread_mutex_destroy(&task_queue->lock); -err_uninit_full_sem: - sem_destroy(&task_queue->full_sem); -err_uninit_empty_sem: - sem_destroy(&task_queue->empty_sem); -err_free_head: - free(head); - ret = -errno; - return ret; -} - -static void wd_uninit_one_task_queue(struct async_task_queue *task_queue) -{ - /* - * If there's no async task, async_poll_process_func() is sleeping - * on task_queue->full_sem. It'll cause that threads could not - * be end and memory leak. - */ - sem_post(&task_queue->full_sem); - __atomic_store_n(&task_queue->end, 1, __ATOMIC_RELEASE); - while (__atomic_load_n(&task_queue->end, __ATOMIC_ACQUIRE)) - sched_yield(); - - pthread_mutex_destroy(&task_queue->lock); - sem_destroy(&task_queue->full_sem); - sem_destroy(&task_queue->empty_sem); - free(task_queue->head); - task_queue->head = NULL; -} - -static int wd_init_async_polling_thread_per_numa(struct wd_env_config *config, - struct wd_env_config_per_numa *config_numa, - void *alg_poll_ctx) -{ - struct async_task_queue *task_queue, *queue_head; - int i, j, ret; - double num; - - if (!config_numa->async_ctx_num) - return 0; - - if (!config_numa->async_poll_num) { - WD_ERR("invalid async poll num (%lu) is set.\n", - config_numa->async_poll_num); - WD_ERR("change to default value: %d\n", WD_ASYNC_DEF_POLL_NUM); - config_numa->async_poll_num = WD_ASYNC_DEF_POLL_NUM; - } - - num = MIN(config_numa->async_poll_num, config_numa->async_ctx_num); - - /* make max task queues as the number of async ctxs */ - queue_head = calloc(config_numa->async_ctx_num, sizeof(*queue_head)); - if (!queue_head) - return -WD_ENOMEM; - - task_queue = queue_head; - for (i = 0; i < num; task_queue++, i++) { - ret = wd_init_one_task_queue(task_queue, alg_poll_ctx); - if (ret) { - for (j = 0; j < i; task_queue++, j++) - wd_uninit_one_task_queue(task_queue); - free(queue_head); - return ret; - } - } - - config_numa->async_task_queue_array = (void *)queue_head; - - return 0; -} - -static void wd_uninit_async_polling_thread_per_numa(struct wd_env_config *cfg, - struct wd_env_config_per_numa *config_numa) -{ - struct async_task_queue *task_queue, *head; - double num; - int i; - - if (!config_numa || !config_numa->async_task_queue_array) - return; - - head = config_numa->async_task_queue_array; - task_queue = head; - num = MIN(config_numa->async_poll_num, config_numa->async_ctx_num); - - for (i = 0; i < num; task_queue++, i++) - wd_uninit_one_task_queue(task_queue); - free(head); - config_numa->async_task_queue_array = NULL; -} - -static int wd_init_async_polling_thread(struct wd_env_config *config, - void *alg_poll_ctx) -{ - struct wd_env_config_per_numa *config_numa; - int i, ret; - - if (!config->enable_internal_poll) - return 0; - - FOREACH_NUMA(i, config, config_numa) { - ret = wd_init_async_polling_thread_per_numa(config, config_numa, - alg_poll_ctx); - if (ret) - goto out; - } - - return 0; - -out: - FOREACH_NUMA(i, config, config_numa) - wd_uninit_async_polling_thread_per_numa(config, config_numa); - - return ret; -} - -static void wd_uninit_async_polling_thread(struct wd_env_config *config) -{ - struct wd_env_config_per_numa *config_numa; - int i; - - if (!config->enable_internal_poll) - return; - - FOREACH_NUMA(i, config, config_numa) - wd_uninit_async_polling_thread_per_numa(config, config_numa); -} - static int wd_init_resource(struct wd_env_config *config, const struct wd_alg_ops *ops) { @@ -1736,14 +1329,8 @@ static int wd_init_resource(struct wd_env_config *config, if (ret) goto err_uninit_sched; - ret = wd_init_async_polling_thread(config, ops->alg_poll_ctx); - if (ret) - goto err_uninit_alg; - return 0; -err_uninit_alg: - ops->alg_uninit(); err_uninit_sched: wd_uninit_sched_config(config); err_uninit_ctx: @@ -1754,7 +1341,6 @@ static int wd_init_resource(struct wd_env_config *config, static void wd_uninit_resource(struct wd_env_config *config, const struct wd_alg_ops *ops) { - wd_uninit_async_polling_thread(config); ops->alg_uninit(); wd_uninit_sched_config(config); wd_free_ctx(config); @@ -1808,7 +1394,7 @@ int wd_alg_get_env_param(struct wd_env_config *env_config, return -WD_EINVAL; } - *is_enable = env_config->enable_internal_poll; + *is_enable = 0; config_numa = wd_get_config_numa(env_config, attr.node); if (!config_numa) From 52885c2a6cef7841b644568041a002e46515f44f Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:26 +0800 Subject: [PATCH 02/11] uadk: fix memory leak when wd_get_alg_type() fails When wd_get_alg_type() fails, the memory allocated by strdup() is not freed. fix it. Signed-off-by: Weili Qian --- wd_util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wd_util.c b/wd_util.c index 33aeee603..cf1baa033 100644 --- a/wd_util.c +++ b/wd_util.c @@ -1690,13 +1690,13 @@ static int wd_env_set_ctx_nums(const char *alg_name, const char *name, const cha ret = wd_get_alg_type(alg_name, alg_type); if (ret) - return ret; + goto free_start; list = wd_get_accel_list(alg_type); if (!list) { WD_ERR("failed to get devices!\n"); - free(start); - return -WD_ENODEV; + ret = -WD_ENODEV; + goto free_start; } left = start; @@ -1707,6 +1707,7 @@ static int wd_env_set_ctx_nums(const char *alg_name, const char *name, const cha } wd_free_list_accels(list); +free_start: free(start); return ret; } From 8893b969eeef2c55cacb33a0ead4787a71428f6a Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:27 +0800 Subject: [PATCH 03/11] uadk: check the strdup() return value strdup () may fail to allocate memory. Therefore, the return value needs to be checked, fix it. Signed-off-by: Weili Qian --- wd_util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wd_util.c b/wd_util.c index cf1baa033..043179f97 100644 --- a/wd_util.c +++ b/wd_util.c @@ -306,6 +306,9 @@ int wd_init_sched(struct wd_sched *in, struct wd_sched *from) in->h_sched_ctx = from->h_sched_ctx; in->name = strdup(from->name); + if (!in->name) + return -WD_ENOMEM; + in->sched_init = from->sched_init; in->pick_next_ctx = from->pick_next_ctx; in->poll_policy = from->poll_policy; From 2edbebe9234b1dc7de67ab47da73ea0909f8717f Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:28 +0800 Subject: [PATCH 04/11] uadk/v1: replaced the deprecated with The header file is deprecated in modern Linux systems(e.g., glibc). Current builds may trigger a compilation warning when -Werror is enabled: #warning redirecting incorrect #include to Therefore, use poll.h instead of sys/poll.h. Signed-off-by: Weili Qian --- v1/wd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v1/wd.c b/v1/wd.c index bab2712fa..f008695f0 100644 --- a/v1/wd.c +++ b/v1/wd.c @@ -18,12 +18,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include From 2637ec53cf3c533883bc212abd6d20ba3571d3a3 Mon Sep 17 00:00:00 2001 From: Longfang Liu Date: Fri, 22 May 2026 16:51:06 +0800 Subject: [PATCH 05/11] =?UTF-8?q?uadk=EF=BC=9Aupdate=20compression=20algor?= =?UTF-8?q?ithm=20memory=20pool=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the UADK no-SVA mode memory pool, queues are used to create memory pools, and algorithms are employed to find the required queues. However, a compression algorithm queue cannot simultaneously support both compression and decompression modes—a queue must be defined as either compression or decompression. Therefore, when allocating a memory pool, a queue of the corresponding type must be specified for use. To facilitate queue lookup for the memory pool, the algorithm name is distinguished by appending a "-comp" or "-decomp" suffix. Similarly, when users request a memory pool, the compression algorithm must also include the corresponding suffix for querying. Signed-off-by: Longfang Liu --- include/wd_util.h | 4 ++++ wd_comp.c | 2 +- wd_util.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/wd_util.h b/include/wd_util.h index 341274130..56dd9bab8 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -27,6 +27,10 @@ extern "C" { for ((i) = 0, (config_numa) = (config)->config_per_numa; \ (i) < (config)->numa_num; (config_numa)++, (i)++) +#define COMP_ALG "comp" +#define CTX_COMP_ALG "zlib-comp gzip-comp deflate-comp lz77_zstd-comp lz4-comp lz77_only-comp" +#define CTX_DECOMP_ALG "zlib-decomp gzip-decomp deflate-decomp lz77_zstd-decomp lz4-decomp lz77_only-decomp" + enum wd_status { WD_UNINIT, WD_INITING, diff --git a/wd_comp.c b/wd_comp.c index 112e92c26..7a2b0bc29 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -148,7 +148,7 @@ static int wd_comp_init_nolock(struct wd_ctx_config *config, struct wd_sched *sc if (ret < 0) return ret; - wd_comp_setting.config.alg_name = "zlib gzip deflate lz77_zstd lz4 lz77_only"; + wd_comp_setting.config.alg_name = COMP_ALG; ret = wd_init_ctx_config(&wd_comp_setting.config, config); if (ret < 0) return ret; diff --git a/wd_util.c b/wd_util.c index 043179f97..707cdb5f4 100644 --- a/wd_util.c +++ b/wd_util.c @@ -242,6 +242,7 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, struct wd_ctx_config *cfg) { struct wd_ctx_internal *ctxs; + char *alg_name; __u32 i, j; int ret; @@ -274,7 +275,15 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in, goto err_out; } - ret = wd_insert_ctx_list(cfg->ctxs[i].ctx, in->alg_name); + alg_name = in->alg_name; + if (strcmp(in->alg_name, COMP_ALG) == 0) { + if (cfg->ctxs[i].op_type == 0) + alg_name = CTX_COMP_ALG; + else + alg_name = CTX_DECOMP_ALG; + } + + ret = wd_insert_ctx_list(cfg->ctxs[i].ctx, alg_name); if (ret) { WD_ERR("failed to add ctx to mem list!\n"); goto err_out; From 416e4e57a5f02fe5511a95e7442e356decc79686 Mon Sep 17 00:00:00 2001 From: Longfang Liu Date: Fri, 22 May 2026 11:29:30 +0800 Subject: [PATCH 06/11] uadk: update compression algorithm memory pool creation In the ZIP algorithm compression testing tool, when using no-SVA mode, the creation of the memory pool requires the use of different device queues based on compression and decompression operations. We address this distinction through a convention of appending suffixes. Therefore, when querying queues, suffixes need to be added for processing. Signed-off-by: Longfang Liu --- uadk_tool/benchmark/zip_uadk_benchmark.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c index 092f71081..d0f1795fb 100644 --- a/uadk_tool/benchmark/zip_uadk_benchmark.c +++ b/uadk_tool/benchmark/zip_uadk_benchmark.c @@ -803,12 +803,19 @@ static void free_uadk_bd_pool(void) static int init_uadk_rsv_pool(struct acc_option *option) { struct wd_mempool_setup pool_setup; - char *alg = option->algclass; + char alg[CRYPTO_MAX_ALG_NAME]; u32 insize = g_pktlen; handle_t h_ctx; u32 outsize; int i, j; + if (option->optype == 1) + snprintf(alg, CRYPTO_MAX_ALG_NAME - 1, "%s-decomp", + option->algclass); + else + snprintf(alg, CRYPTO_MAX_ALG_NAME - 1, "%s-comp", + option->algclass); + h_ctx = wd_find_ctx(alg); if (!h_ctx) { ZIP_TST_PRT("failed to find a ctx for alg: %s\n", option->algname); From a6384cadb21f531ba2c2fdbbb90ffa43dbdbfc06 Mon Sep 17 00:00:00 2001 From: Zhushuai Yin Date: Fri, 22 May 2026 11:29:31 +0800 Subject: [PATCH 07/11] uadk/v1:fix integer overflow problem Multiplying two u32 values and assigning the result to a left-hand u64 value carries a risk of overflow, so the right-hand value needs to be explicitly cast to u64. Signed-off-by: Zhushuai Yin --- v1/wd_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v1/wd_util.c b/v1/wd_util.c index eae148b02..cb9c96037 100644 --- a/v1/wd_util.c +++ b/v1/wd_util.c @@ -156,7 +156,7 @@ void wd_free_id(__u8 *buf, __u32 size, __u32 id, __u32 id_max) int wd_init_cookie_pool(struct wd_cookie_pool *pool, __u32 cookies_size, __u32 cookies_num) { - __u64 total_size = cookies_size * cookies_num; + __u64 total_size = (__u64)cookies_size * cookies_num; pool->cookies = calloc(1, total_size + cookies_num); if (!pool->cookies) From e3f4135f91f586e035affc9e68389784e52e4f9e Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:32 +0800 Subject: [PATCH 08/11] uadk: remove redundant check Since sess in cleanup_session() cannot be null, the check on sess can be removed. Signed-off-by: Weili Qian --- wd_aead.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wd_aead.c b/wd_aead.c index 42dc774e8..a9e6279a5 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -413,8 +413,7 @@ static void cleanup_session(struct wd_aead_sess *sess) sess->mm_ops.free(sess->mm_ops.usr, sess->ckey); sess->mm_ops.free(sess->mm_ops.usr, sess->akey); - if (sess) - free(sess); + free(sess); } static int wd_aead_sess_eops_init(struct wd_aead_sess *sess) From 2e70e6765bd90fa969b7ad81bce31e152f318b27 Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:33 +0800 Subject: [PATCH 09/11] uadk: include missing header file Include missing header file: v1/wd_ecc.h v1/wd_comp.h. Remove internal header file v1/uacce.h. Signed-off-by: Qi Tao Signed-off-by: Weili Qian --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b38c5ce6d..62d0c3e09 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,8 +40,8 @@ pkginclude_HEADERS = include/wd.h include/wd_internal.h include/wd_cipher.h incl include/wd_udma.h include/wd_join_gather.h \ include/wd_bmm.h -nobase_pkginclude_HEADERS = v1/wd.h v1/wd_cipher.h v1/wd_aead.h v1/uacce.h v1/wd_dh.h \ - v1/wd_digest.h v1/wd_rsa.h v1/wd_bmm.h +nobase_pkginclude_HEADERS=v1/wd.h v1/wd_cipher.h v1/wd_aead.h v1/wd_dh.h v1/wd_digest.h \ + v1/wd_rsa.h v1/wd_bmm.h v1/wd_ecc.h v1/wd_comp.h lib_LTLIBRARIES=libwd.la libwd_comp.la libwd_crypto.la libwd_dae.la libwd_udma.la From ed6cd7b099cd4b60e004020f1b7314c6ce4ed692 Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 22 May 2026 11:29:34 +0800 Subject: [PATCH 10/11] uadk: move library dependencies to LIBADD The -lpthread flags should be placed in LIBADD instead of LDFLAGS to follow libtool conventions. And add -lm for libwd_dae_la_LIBADD. Signed-off-by: Weili Qian --- Makefile.am | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index 62d0c3e09..ae5170e4c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,20 +120,20 @@ if WD_STATIC_DRV AM_CFLAGS += -DWD_STATIC_DRV -fPIC AM_CFLAGS += -DWD_NO_LOG -libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma +libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread -libwd_comp_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma +libwd_comp_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread libwd_comp_la_DEPENDENCIES = libwd.la -libhisi_zip_la_LIBADD = -ldl +libhisi_zip_la_LIBADD = -ldl -lpthread -libwd_crypto_la_LIBADD = -lwd -ldl -lnuma -lm -lpthread +libwd_crypto_la_LIBADD = -lwd -ldl -lnuma -lpthread libwd_crypto_la_DEPENDENCIES = libwd.la libwd_udma_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lm -lpthread libwd_udma_la_DEPENDENCIES = libwd.la -libwd_dae_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma +libwd_dae_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lm -lpthread libwd_dae_la_DEPENDENCIES = libwd.la libhisi_sec_la_LIBADD = $(libwd_la_OBJECTS) $(libwd_crypto_la_OBJECTS) @@ -164,19 +164,19 @@ UADK_V1_SYMBOL= -Wl,--version-script,$(top_srcdir)/v1/libwd.map libwd_la_LDFLAGS=$(UADK_VERSION) $(UADK_WD_SYMBOL) $(UADK_V1_SYMBOL) libwd_la_LIBADD= -ldl -lnuma -libwd_comp_la_LIBADD= -lwd -ldl -lnuma -libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL) -lpthread +libwd_comp_la_LIBADD= -lwd -ldl -lnuma -lpthread +libwd_comp_la_LDFLAGS=$(UADK_VERSION) $(UADK_COMP_SYMBOL) libwd_comp_la_DEPENDENCIES= libwd.la -libwd_crypto_la_LIBADD= -lwd -ldl -lnuma -libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL) -lpthread +libwd_crypto_la_LIBADD= -lwd -ldl -lnuma -lpthread +libwd_crypto_la_LDFLAGS=$(UADK_VERSION) $(UADK_CRYPTO_SYMBOL) libwd_crypto_la_DEPENDENCIES= libwd.la libwd_udma_la_LIBADD= -lwd -ldl -lnuma -lm -lpthread libwd_udma_la_LDFLAGS=$(UADK_VERSION) $(UADK_DAE_SYMBOL) libwd_udma_la_DEPENDENCIES= libwd.la -libwd_dae_la_LIBADD= -lwd -ldl -lnuma -lm +libwd_dae_la_LIBADD= -lwd -ldl -lnuma -lm -lpthread libwd_dae_la_LDFLAGS=$(UADK_VERSION) $(UADK_DAE_SYMBOL) libwd_dae_la_DEPENDENCIES= libwd.la From 98f0a2d6b789bde91a758282983d8eca13957b3d Mon Sep 17 00:00:00 2001 From: Chenghai Huang Date: Fri, 22 May 2026 11:29:35 +0800 Subject: [PATCH 11/11] uadk - fix the log frequency limit function The log frequency limit function iuses the alarm function. If users use the alarm function, the log frequency limiting function may be affected. Therefore, the log frequency limiting function is changed to timer_settime. Signed-off-by: Chenghai Huang --- Makefile.am | 2 +- v1/drv/hisi_zip_udrv.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index ae5170e4c..ef7199148 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,7 +120,7 @@ if WD_STATIC_DRV AM_CFLAGS += -DWD_STATIC_DRV -fPIC AM_CFLAGS += -DWD_NO_LOG -libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread +libwd_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread -lrt libwd_comp_la_LIBADD = $(libwd_la_OBJECTS) -ldl -lnuma -lpthread libwd_comp_la_DEPENDENCIES = libwd.la diff --git a/v1/drv/hisi_zip_udrv.c b/v1/drv/hisi_zip_udrv.c index d4e5dc44a..b73a9293e 100644 --- a/v1/drv/hisi_zip_udrv.c +++ b/v1/drv/hisi_zip_udrv.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "v1/wd_util.h" #include "v1/wd_comp.h" #include "v1/wd_cipher.h" @@ -132,21 +133,27 @@ struct zip_fill_sqe_ops { void (*fill_sqe_hw_info)(void *ssqe, struct wcrypto_comp_msg *msg); }; -static unsigned int g_err_print_enable = 1; +static timer_t g_timerid; +static sig_atomic_t g_err_print_enable = 1; -static void zip_err_print_alarm_end(int sig) +static void zip_err_print_alarm_end(union sigval sv) { - if (sig == SIGALRM) { - g_err_print_enable = 1; - alarm(0); - } + timer_delete(g_timerid); + g_err_print_enable = 1; } static void zip_err_print_time_start(void) { - g_err_print_enable = 0; - signal(SIGALRM, zip_err_print_alarm_end); - alarm(PRINT_TIME_INTERVAL); + struct itimerspec its = {0}; + struct sigevent sev = {0}; + + sev.sigev_notify = SIGEV_THREAD; + sev.sigev_notify_function = zip_err_print_alarm_end; + sev.sigev_value.sival_ptr = &g_timerid; + timer_create(CLOCK_REALTIME, &sev, &g_timerid); + + its.it_value.tv_sec = PRINT_TIME_INTERVAL; + timer_settime(g_timerid, 0, &its, NULL); } static void zip_err_bd_print(__u16 ctx_st, __u32 status, __u32 type) @@ -155,6 +162,7 @@ static void zip_err_bd_print(__u16 ctx_st, __u32 status, __u32 type) WD_ERR("bad status(ctx_st=0x%x, s=0x%x, t=%u)\n", ctx_st, status, type); } else if (g_err_print_enable == 1) { + g_err_print_enable = 0; WD_ERR("bad status(ctx_st=0x%x, s=0x%x, t=%u)\n", ctx_st, status, type); zip_err_print_time_start();