Skip to content

Conversation

@jsarha
Copy link
Contributor

@jsarha jsarha commented Nov 17, 2025

The module API was extended to pass flags the allocation back-end [1]. With this change there is no reason not use module API also to allocate the DMA buffers.

[1] 1d170fc module: add an allocation function with flags

Copilot AI review requested due to automatic review settings November 17, 2025 22:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors memory allocation in the audio copier module to consistently use the module API (mod_alloc_ext and mod_free) instead of direct allocation functions (rzalloc and rfree), particularly for DMA buffer allocation. This change follows the extension of the module API to support allocation flags, enabling unified memory management through the module interface.

Key changes:

  • Replaced rzalloc calls with mod_alloc_ext for coherent memory allocation
  • Replaced rfree calls with mod_free for memory deallocation
  • Updated function signatures to accept processing_module instead of component-specific data structures
  • Added explicit memset calls after allocation to replace rzalloc's zero-initialization

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/include/sof/audio/module_adapter/module/generic.h Reverted mod_alloc_align to use SOF_MEM_FLAG_USER flag instead of 0
src/audio/copier/dai_copier.h Updated copier_dai_free signature to accept processing_module parameter
src/audio/copier/copier_host.c Converted FPI sync group allocation/deallocation to use module API
src/audio/copier/copier_dai.c Converted DAI data and gain data allocation/deallocation to use module API
src/audio/copier/copier.c Updated copier_dai_free call to pass mod instead of cd

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jsarha jsarha force-pushed the finnish_copier_module_api_conversion branch from 31308b5 to 2e258ce Compare November 17, 2025 22:33
{
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.

{
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
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

The module API was extended to pass flags the allocation back-end
[1]. With this change there is no reason not use module API also to
allocate the DMA buffers.

[1] 1d170fc module: add an allocation function with flags

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the finnish_copier_module_api_conversion branch from 2e258ce to 259c4a2 Compare November 21, 2025 16:00
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()

@kv2019i kv2019i merged commit ca85076 into thesofproject:main Nov 25, 2025
35 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants