Add api wd_comp_setup_blkpool. Other alg.c will need wd_xxx_setup_blkpool as well. The reason is app does not know ctx.
It will setup blkpool for ctx[0] and sglpool for sgl mode. The blkpool will be used by app and driver.
App need call wd_xxx_setup_blkpool for user pointer mode and sgl mode. The returned blkpool will be used for wd_blkpool_alloc/free.
Alloc_sess will call wd_xxx_setup_blkpool if it is not called by app. Then uadk library will alloc blkpool and memcpy to user memory, with poorer performance.
The driver will translate va to pa when configure register.
Signed-off-by: Zhangfei Gao zhangfei.gao@linaro.org --- include/wd_comp.h | 2 ++ libwd_comp.map | 1 + wd_comp.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+)
diff --git a/include/wd_comp.h b/include/wd_comp.h index 45994ff..a957021 100644 --- a/include/wd_comp.h +++ b/include/wd_comp.h @@ -10,6 +10,7 @@ #include <numa.h>
#include "wd_alg_common.h" +#include "wd_bmm.h"
#ifdef __cplusplus extern "C" { @@ -256,6 +257,7 @@ void wd_comp_ctx_num_uninit(void); int wd_comp_get_env_param(__u32 node, __u32 type, __u32 mode, __u32 *num, __u8 *is_enable);
+void *wd_comp_setup_blkpool(struct wd_blkpool_setup *setup); #ifdef __cplusplus } #endif diff --git a/libwd_comp.map b/libwd_comp.map index 6b1f8c2..033b476 100644 --- a/libwd_comp.map +++ b/libwd_comp.map @@ -22,6 +22,7 @@ global: wd_comp_get_driver; wd_comp_get_msg; wd_comp_reset_sess; + wd_comp_setup_blkpool;
wd_sched_rr_instance; wd_sched_rr_alloc; diff --git a/wd_comp.c b/wd_comp.c index 647c320..21a57ac 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -588,6 +588,25 @@ static int wd_comp_check_params(struct wd_comp_sess *sess, return 0; }
+void *wd_comp_setup_blkpool(struct wd_blkpool_setup *setup) +{ + struct wd_ctx_config_internal *config = &wd_comp_setting.config; + struct wd_ctx_internal *ctx = config->ctxs; + int ret; + + ret = wd_blkpool_setup(ctx->blkpool, setup); + if (ret) + return NULL; + + ctx->blkpool_mode = BLKPOOL_MODE_USER; + pthread_spin_lock(&ctx->lock); + if (ctx->h_sgl_pool == 0) + ctx->h_sgl_pool = wd_blkpool_create_sglpool(ctx->blkpool, + HISI_SGL_NUM_IN_BD, HISI_SGE_NUM_IN_SGL); + pthread_spin_unlock(&ctx->lock); + return ctx->blkpool; +} + static int wd_comp_sync_job(struct wd_comp_sess *sess, struct wd_comp_req *req, struct wd_comp_msg *msg)