Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ __cold static int copier_free(struct processing_module *mod)
copier_ipcgtw_free(mod);
break;
case SOF_COMP_DAI:
copier_dai_free(cd);
copier_dai_free(mod);
break;
default:
break;
Expand Down
21 changes: 13 additions & 8 deletions src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ __cold static int copier_dai_init(struct comp_dev *dev,
return ret;
}

dd = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, sizeof(*dd));
dd = mod_alloc_ext(mod, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, sizeof(*dd), 0);
if (!dd)
return -ENOMEM;
memset(dd, 0, sizeof(*dd));

ret = dai_common_new(dd, dev, dai);
if (ret < 0)
Expand All @@ -223,12 +224,14 @@ __cold static int copier_dai_init(struct comp_dev *dev,

/* Allocate gain data if selected for this dai type and set basic params */
if (dai->apply_gain) {
struct copier_gain_params *gain_data = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(*gain_data));
struct copier_gain_params *gain_data =
mod_alloc_ext(mod, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(*gain_data), 0);
if (!gain_data) {
ret = -ENOMEM;
goto e_zephyr_free;
}
memset(gain_data, 0, sizeof(*gain_data));
cd->dd[index]->gain_data = gain_data;

ret = copier_gain_set_params(dev, cd->dd[index]->gain_data,
Expand All @@ -244,11 +247,11 @@ __cold static int copier_dai_init(struct comp_dev *dev,

return 0;
gain_free:
rfree(dd->gain_data);
mod_free(mod, dd->gain_data);
e_zephyr_free:
dai_common_free(dd);
free_dd:
rfree(dd);
mod_free(mod, dd);
return ret;
}

Expand Down Expand Up @@ -374,14 +377,16 @@ __cold int copier_dai_create(struct comp_dev *dev, struct copier_data *cd,
return 0;
}

__cold void copier_dai_free(struct copier_data *cd)
__cold void copier_dai_free(struct processing_module *mod)
{
struct copier_data *cd = module_get_private_data(mod);

assert_can_be_cold();

for (int i = 0; i < cd->endpoint_num; i++) {
dai_common_free(cd->dd[i]);
rfree(cd->dd[i]->gain_data);
rfree(cd->dd[i]);
mod_free(mod, cd->dd[i]->gain_data);
mod_free(mod, cd->dd[i]);
}
/* only dai have multi endpoint case */
if (cd->multi_endpoint_buffer)
Expand Down
14 changes: 9 additions & 5 deletions src/audio/copier/copier_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ __cold static int add_to_fpi_sync_group(struct comp_dev *parent_dev,
struct ipc4_copier_sync_group *sync_group)
{
struct fpi_sync_group *group = find_group_by_id(sync_group->group_id);
struct processing_module *mod = comp_mod(parent_dev);

assert_can_be_cold();

Expand All @@ -62,11 +63,13 @@ __cold static int add_to_fpi_sync_group(struct comp_dev *parent_dev,

group->ref_count++;
} else {
group = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, sizeof(*group));
group = mod_alloc_ext(mod, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(*group), 0);
if (!group) {
comp_err(parent_dev, "Failed to alloc memory for new group");
return -ENOMEM;
}
memset(group, 0, sizeof(*group));

group->id = sync_group->group_id;
group->period = sync_group->fpi_update_period_usec;
Expand All @@ -81,9 +84,10 @@ __cold static int add_to_fpi_sync_group(struct comp_dev *parent_dev,
return 0;
}

__cold static void delete_from_fpi_sync_group(struct host_data *hd)
__cold static void delete_from_fpi_sync_group(struct processing_module *mod)
{
struct fpi_sync_group *group = find_group_by_id(hd->group_id);
struct copier_data *cd = module_get_private_data(mod);
struct fpi_sync_group *group = find_group_by_id(cd->hd->group_id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't see a reason to change this function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to pass in the module now

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgirdwood why? I don't see where it's needed

Copy link
Contributor Author

@jsarha jsarha Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lyakh, there is indeed a bug. Not the unnecessary change, but unconverted rfree.


assert_can_be_cold();

Expand All @@ -93,7 +97,7 @@ __cold static void delete_from_fpi_sync_group(struct host_data *hd)
group->ref_count--;
if (group->ref_count == 0) {
list_item_del(&group->item);
rfree(group);
mod_free(mod, group);
}
}
#endif
Expand Down Expand Up @@ -265,7 +269,7 @@ __cold void copier_host_free(struct processing_module *mod)

#if CONFIG_HOST_DMA_STREAM_SYNCHRONIZATION
if (cd->hd->is_grouped)
delete_from_fpi_sync_group(cd->hd);
delete_from_fpi_sync_group(mod);
#endif
host_common_free(cd->hd);
mod_free(mod, cd->hd);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/copier/dai_copier.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int copier_dai_create(struct comp_dev *dev, struct copier_data *cd,
const struct ipc4_copier_module_cfg *copier,
struct pipeline *pipeline);

void copier_dai_free(struct copier_data *cd);
void copier_dai_free(struct processing_module *mod);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: no need to change unless you have to submit a new version (e.g. there's currently a QB failure for this PR), but if you do need to update - maybe better use struct comp_dev *dev as a parameter here to match copier_dai_create()


int copier_dai_prepare(struct comp_dev *dev, struct copier_data *cd);

Expand Down
2 changes: 1 addition & 1 deletion src/include/sof/audio/module_adapter/module/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void *mod_alloc_ext(struct processing_module *mod, uint32_t flags, size_t size,
*/
static inline void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment)
{
return mod_alloc_ext(mod, 0, size, alignment);
return mod_alloc_ext(mod, SOF_MEM_FLAG_USER, size, alignment);
}

static inline void *mod_balloc(struct processing_module *mod, size_t size)
Expand Down
Loading