-
Notifications
You must be signed in to change notification settings - Fork 364
audio: module-adapter: make generic code compatible with user-space #10950
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,13 +57,15 @@ int module_load_config(struct comp_dev *dev, const void *cfg, size_t size) | |
|
|
||
| if (!dst->data) { | ||
| /* No space for config available yet, allocate now */ | ||
| dst->data = rballoc(SOF_MEM_FLAG_USER, size); | ||
| dst->data = sof_heap_alloc(sof_sys_user_heap_get(), | ||
| SOF_MEM_FLAG_USER, size, 0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so, we're releasing some of VMH memory and using the standard heap here. Have you checked how big these allocations are typically and how many we switch? Do we need to reallocate some memory from VMH to the userspace heap?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, right. I don't think we should touch the virtual/direct heap mix in the same PRs as we add support for user-space LL use. And yeah, that's what I'm doing here and some of earlier rballoc(). I could use SOF_MEM_FLAG_LARGE_BUFFER to mark places where rballoc() was used, but that is hardcoded to kernel in current zephyr/alloc.c, so won't work either. But alas, some cleaner solution is needed. Sizing the VMH split is a much more complicated problem and I don't want to tackle that in these PRs... |
||
| } else if (dst->size != size) { | ||
| /* The size allocated for previous config doesn't match the new one. | ||
| * Free old container and allocate new one. | ||
| */ | ||
| rfree(dst->data); | ||
| dst->data = rballoc(SOF_MEM_FLAG_USER, size); | ||
| sof_heap_free(sof_sys_user_heap_get(), dst->data); | ||
| dst->data = sof_heap_alloc(sof_sys_user_heap_get(), | ||
| SOF_MEM_FLAG_USER, size, 0); | ||
| } | ||
| if (!dst->data) { | ||
| comp_err(dev, "failed to allocate space for setup config."); | ||
|
|
@@ -538,7 +540,7 @@ int module_prepare(struct processing_module *mod, | |
| * as it has been applied during the procedure - it is safe to | ||
| * free it. | ||
| */ | ||
| rfree(md->cfg.data); | ||
| sof_heap_free(sof_sys_user_heap_get(), md->cfg.data); | ||
|
|
||
| md->cfg.avail = false; | ||
| md->cfg.data = NULL; | ||
|
|
@@ -673,7 +675,7 @@ int module_reset(struct processing_module *mod) | |
|
|
||
| md->cfg.avail = false; | ||
| md->cfg.size = 0; | ||
| rfree(md->cfg.data); | ||
| sof_heap_free(sof_sys_user_heap_get(), md->cfg.data); | ||
| md->cfg.data = NULL; | ||
|
|
||
| #if CONFIG_IPC_MAJOR_3 | ||
|
|
@@ -724,10 +726,10 @@ int module_free(struct processing_module *mod) | |
| /* Free all memory shared by module_adapter & module */ | ||
| md->cfg.avail = false; | ||
| md->cfg.size = 0; | ||
| rfree(md->cfg.data); | ||
| sof_heap_free(sof_sys_user_heap_get(), md->cfg.data); | ||
| md->cfg.data = NULL; | ||
| if (md->runtime_params) { | ||
| rfree(md->runtime_params); | ||
| sof_heap_free(sof_sys_user_heap_get(), md->runtime_params); | ||
| md->runtime_params = NULL; | ||
| } | ||
| #if CONFIG_IPC_MAJOR_3 | ||
|
|
@@ -794,7 +796,9 @@ int module_set_configuration(struct processing_module *mod, | |
| } | ||
|
|
||
| /* Allocate buffer for new params */ | ||
| md->runtime_params = rballoc(SOF_MEM_FLAG_USER, md->new_cfg_size); | ||
| md->runtime_params = sof_heap_alloc(sof_sys_user_heap_get(), | ||
| SOF_MEM_FLAG_USER, | ||
| md->new_cfg_size, 0); | ||
| if (!md->runtime_params) { | ||
| comp_err(dev, "space allocation for new params failed"); | ||
| return -ENOMEM; | ||
|
|
@@ -835,7 +839,7 @@ int module_set_configuration(struct processing_module *mod, | |
| md->new_cfg_size = 0; | ||
|
|
||
| if (md->runtime_params) | ||
| rfree(md->runtime_params); | ||
| sof_heap_free(sof_sys_user_heap_get(), md->runtime_params); | ||
| md->runtime_params = NULL; | ||
|
|
||
| return ret; | ||
|
|
||
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.
could just use
sof_sys_user_heap_get()directly as in other cases. But this one also addsCOHERENT- that's on purpose, right? Maybe mention in the commit messageThere 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.
Ok, fixing both. Earlier version of the patch stored a heap instance, but no need for that. And COHERENT is a mistake, we should align flags. Will fix.