-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uadk: driver alloc and free resources by itself #555
Conversation
|
||
if (!priv) | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem when deleting directly here. After the priv is removed at the API layer, a solution needs to be added to prevent repeated uninitialization. Otherwise, the function of preventing double release will be gone, which will cause other problems.
Thanks.
Longfang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en, for the drivers only supporting init once, drv.init can check whether drv.priv is null or not.
For the drivers support multi-entry, like adapter, just let it go. adapter has detected each workers.init.
if (worker->inited)
continue;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The priv here is still in the wd_cipher_setting structure. It is used to prevent repeated uninitialization of resources at the API layer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the driver does not support repeated exit, it is the driver's responsibility to prevent repeated un-initialization, not the caller's.
Now both hisi_sec_init and hisi_sec_exit has checked drv.priv.
For drivers permitted multi-init and multi-exit, it is OK, just like free().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this problem is not solved in the current patch. If merged into the patch will cause problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wd_alg_try_init(&wd_digest_setting.status) can prevent re-init2
Whether the driver can call init multi-times depends on the driver itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this wd_alg_try_init is possible.
You can add it and verify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wd_alg_try_init still there, in wd_xxx_init, this patch does not change that.
rebased to master, to solve conflict |
6953848
to
3c7307b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
A driver should alloc and free resources by himself instead of the caller, considering multi-driver exists, the caller can not hold ctxs for all drivers, so drv.init malloc private ctx and drv.exit free. Add driver as para of alg ops, not only for getting private ctx, but easier for multi-driver support. Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
A driver should alloc and free resources by himself instead of the caller, considering multi-driver exists, the caller can not hold ctx for all drivers, so drv.init malloc private ctx and drv.exit free.
Add driver as para of alg ops, not only for getting private ctx, but easier for multi-driver support.