Skip to content

Conversation

@jsarha
Copy link
Contributor

@jsarha jsarha commented Nov 26, 2025

Some of the HIFI optimized versions of the volume processing callbacks require the volume vector to be suitably aligned. Cache line size should be good enough for all versions.

The ultimate over engineered solution would be some mechanism for the used implementation (HIFI3/4/5 or generic with max volume needed or not permutation) pass the information of the required alignment to the init function, but following the KISS principle this is as good as it gets.

Copilot AI review requested due to automatic review settings November 26, 2025 15:23
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 updates the volume component to use cache-line-aligned memory allocation for the volume vector, ensuring compatibility with HIFI-optimized processing callbacks that require proper alignment. This represents a pragmatic solution following the KISS principle rather than implementing a more complex architecture-specific alignment mechanism.

  • Changed volume vector allocation from mod_alloc() to mod_alloc_align() with CONFIG_DCACHE_LINE_SIZE alignment
  • Applied the change consistently across both IPC3 and IPC4 implementations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/audio/volume/volume_ipc4.c Updated volume vector allocation to use cache-line alignment
src/audio/volume/volume_ipc3.c Updated volume vector allocation to use cache-line alignment

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

@jsarha jsarha marked this pull request as draft November 26, 2025 17:00
@jsarha
Copy link
Contributor Author

jsarha commented Nov 26, 2025

Turned this to draft as cache line size is quite an overkill for HIFI5 instruction data alignment that is 16 bits. Need to come up with some elegant solution for that.

@lgirdwood
Copy link
Member

Turned this to draft as cache line size is quite an overkill for HIFI5 instruction data alignment that is 16 bits. Need to come up with some elegant solution for that.

Speaking with @singalsu the Hifi vector size being used depends on both the HiFi version, the audio format and the operation. Its safest to probably allocate with alignment on the largest vector size for the HiFi version.

@jsarha can you update to add the macros that define the correct size for each HIFI verion in common/sof.h e.g.

#define HIFI4_VECTOR_ALIGN 64

and so on for each HIFI version. @singalsu can help provide the alignments.

@jsarha
Copy link
Contributor Author

jsarha commented Nov 27, 2025

Turned this to draft as cache line size is quite an overkill for HIFI5 instruction data alignment that is 16 bits. Need to come up with some elegant solution for that.

Speaking with @singalsu the Hifi vector size being used depends on both the HiFi version, the audio format and the operation. Its safest to probably allocate with alignment on the largest vector size for the HiFi version.

@jsarha can you update to add the macros that define the correct size for each HIFI verion in common/sof.h e.g.

#define HIFI4_VECTOR_ALIGN 64

and so on for each HIFI version. @singalsu can help provide the alignments.

@lgirdwood we already have this:

# define SOF_FRAME_BYTE_ALIGN 16

shouldn't I use it, instead of creating new macros?

Some of the HIFI optimized versions of the volume processing callbacks
require the volume vector to be suitably aligned. SOF_FRAME_BYTE_ALIGN
is created exactly for this purpose.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the fix_volume_vector_alignment branch from 1d7436b to b873c82 Compare November 27, 2025 20:04
@jsarha jsarha marked this pull request as ready for review November 28, 2025 08:48
@lgirdwood lgirdwood merged commit d3878f4 into thesofproject:main Nov 28, 2025
36 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.

3 participants