On Tue, 31 Dec 2024 at 17:35, Longfang Liu liulongfang@huawei.com wrote:
This reverts commit 3fc344aa4f7c460269cd0d870fe388f01dfa22a2.
ret = wd_alg_init_driver(&wd_rsa_setting.config,
wd_rsa_setting.driver);
wd_rsa_setting.driver,
&wd_rsa_setting.priv); if (ret) goto out_clear_pool;
@@ -197,11 +199,10 @@ out_clear_ctx_config:
static int wd_rsa_common_uninit(void) {
enum wd_status status;
wd_alg_get_init(&wd_rsa_setting.status, &status);
if (status == WD_UNINIT)
if (!wd_rsa_setting.priv) {
WD_ERR("invalid: repeat uninit rsa!\n"); return -WD_EINVAL;
} /* uninit async request pool */ wd_uninit_async_request_pool(&wd_rsa_setting.pool);
@@ -209,7 +210,8 @@ static int wd_rsa_common_uninit(void) /* unset config, sched, driver */ wd_clear_sched(&wd_rsa_setting.sched); wd_alg_uninit_driver(&wd_rsa_setting.config,
wd_rsa_setting.driver);
wd_rsa_setting.driver,
&wd_rsa_setting.priv);
int wd_alg_init_driver(struct wd_ctx_config_internal *config,
struct wd_alg_driver *driver)
struct wd_alg_driver *driver, void **drv_priv)
{
void *priv; int ret;
if (!driver->priv_size) {
WD_ERR("invalid: driver priv ctx size is zero!\n");
return -WD_EINVAL;
}
/* Init ctx related resources in specific driver */
priv = calloc(1, driver->priv_size);
if (!priv)
return -WD_ENOMEM;
if (!driver->init) { driver->fallback = 0; WD_ERR("driver have no init interface.\n");
@@ -1964,7 +1975,7 @@ int wd_alg_init_driver(struct wd_ctx_config_internal *config, goto err_alloc; }
ret = driver->init(driver, config);
ret = driver->init(config, priv); if (ret < 0) { WD_ERR("driver init failed.\n"); goto err_alloc;
@@ -1977,23 +1988,31 @@ int wd_alg_init_driver(struct wd_ctx_config_internal *config, WD_ERR("soft alg driver init failed.\n"); } }
*drv_priv = priv;
这个不太理解哎, 申请驱动A的priv_size 保存到setting->priv, 那驱动B 的priv 申请的空间不是保存不了么。
尽管咱们这个驱动不存在unload 的情况,一直都在,没有生命周期的问题。 但每个驱动保存自己的资源不是更好么?