Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/audio/data_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ EXPORT_SYMBOL(comp_data_blob_get_cmd);

static void *default_alloc(size_t size)
{
return rballoc(SOF_MEM_FLAG_USER, size);
return sof_heap_alloc(sof_sys_user_heap_get(), SOF_MEM_FLAG_USER, size, 0);
}

static void default_free(void *buf)
{
rfree(buf);
sof_heap_free(sof_sys_user_heap_get(), buf);
}

struct comp_data_blob_handler *
Expand All @@ -638,13 +638,15 @@ comp_data_blob_handler_new_ext(struct comp_dev *dev, bool single_blob,
void (*free)(void *buf))
{
struct comp_data_blob_handler *handler;
struct k_heap *heap = sof_sys_user_heap_get();

comp_dbg(dev, "entry");

handler = rzalloc(SOF_MEM_FLAG_USER,
sizeof(struct comp_data_blob_handler));
handler = sof_heap_alloc(heap, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(struct comp_data_blob_handler), 0);

if (handler) {
memset(handler, 0, sizeof(*handler));
handler->dev = dev;
handler->single_blob = single_blob;
handler->alloc = alloc ? alloc : default_alloc;
Expand All @@ -662,6 +664,6 @@ void comp_data_blob_handler_free(struct comp_data_blob_handler *blob_handler)

comp_free_data_blob(blob_handler);

rfree(blob_handler);
sof_heap_free(sof_sys_user_heap_get(), blob_handler);
}
EXPORT_SYMBOL(comp_data_blob_handler_free);
22 changes: 13 additions & 9 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
} 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.");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading