Skip to content

fix: Hifi stack arrays#10905

Open
lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:hifi-stack-arrays
Open

fix: Hifi stack arrays#10905
lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:hifi-stack-arrays

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Some arrays of hifi objects are on the stack, these should always be vector aligned since they can be consumed directly (passed via pointer) in SIMD operations. Enforce.

lrgirdwo added 2 commits June 13, 2026 14:26
Force 8-byte alignment on abs_input_array in
drc_update_detector_average(). The HiFi4 64-bit AE load/store
intrinsics require 8-byte alignment; without it the stack buffer could
be 4-byte aligned and trigger misaligned accesses.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
downmix16bit_4ch_mono() loads its coeffs[] array with AE_L16X4_X, an
aligned 64-bit HiFi load that requires 8-byte alignment. The uint16_t
stack array is only 2-byte aligned, so the compiler may place it on a
4-byte boundary and trigger a misaligned access. Force 8-byte alignment
to match the intrinsic's requirement.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood lgirdwood requested review from a team and abonislawski as code owners June 13, 2026 13:46
Copilot AI review requested due to automatic review settings June 13, 2026 13:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 enforces stack alignment for small HiFi SIMD-consumed arrays to ensure they are safe to pass by pointer into vector load/store operations in the HiFi3/HiFi4 implementations.

Changes:

  • Align the per-call downmix coefficient array in the HiFi3 up/down mixer to 8 bytes.
  • Align the temporary per-division detector array in the HiFi4 DRC path to 8 bytes.

Reviewed changes

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

File Description
src/audio/up_down_mixer/up_down_mixer_hifi3.c Aligns a stack coefficient array used for HiFi vector loads.
src/audio/drc/drc_hifi4.c Aligns a stack working array used with HiFi vector load/store intrinsics.

uint32_t idx4 = get_channel_index(cd->in_channel_map, 3);

uint16_t coeffs[4] = {cd->downmix_coefficients[idx1],
uint16_t coeffs[4] __attribute__((aligned(8))) = {cd->downmix_coefficients[idx1],
Comment thread src/audio/drc/drc_hifi4.c
{
ae_f32 detector_average = state->detector_average; /* Q2.30 */
ae_int32 abs_input_array[DRC_DIVISION_FRAMES]; /* Q1.31 */
ae_int32 abs_input_array[DRC_DIVISION_FRAMES] __attribute__((aligned(8))); /* Q1.31 */
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