Skip to content

Conversation

@tobonex
Copy link
Contributor

@tobonex tobonex commented Apr 10, 2024

This patch fixes a rare crash while testing multiple-pause-resume.sh described in #8651

Explanation:
Dai copier sends data to smart_amp in lnl nocodec. Smart_amp_test uses a process function to just copy buffer contents from sources to sink. The bind between those two uses a 16bit format buffer, while other smart amp pins use 32bit. Smart_amp_test in .prepare function chooses a process callback based only on the format of the sink. This way a 32bit process function is chosen, despite one of the sources being 16bit which risks misalignment. Crash is pretty rare because the misalignment only happens when dai_copier outputs one sample less (an odd number), probably due to stress.

Pushing one of the possible fixes here, but there are other options I can write and push if you want:
- Choose 32bit only when all the sinks and sources are 32bit, else use 16bit process (I pushed this one)
- Create a new process function that always copies word by word, and copies the misaligned data that remains byte by byte. Remove the other process functions.
- Ignore the optimization and just always use process_s16 to be safe

@tobonex tobonex requested review from lyakh and singalsu April 10, 2024 10:17
@tobonex tobonex force-pushed the pauseresume_fix_pr branch from 3d4bdc1 to 70f1d5c Compare April 10, 2024 10:24
Smart amp test chooses a process function based on the sink only. Because
of this, there's a possibility that one of the sources has a 16bit format,
which can't be safely processed by the 32bit process function. The crash
only happened when dai_copier sent one less sample than usual to the
smart_amp. This makes total sample count an odd number, making the data in
the audio_stream buffer misaligned.

This patch changes the prepare function of smart_amp_test to consider all
the sources and sinks while deciding which process function to use.

Signed-off-by: Tobiasz Dryjanski <tobiaszx.dryjanski@intel.com>
@tobonex tobonex force-pushed the pauseresume_fix_pr branch from 70f1d5c to cd85971 Compare April 10, 2024 10:27
@tobonex tobonex marked this pull request as ready for review April 11, 2024 07:43
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