Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio: dai-zephyr: Do not reset the DMA buffer cursor for HD-DMA on T… #8995

Merged

Conversation

ujfalusi
Copy link
Contributor

…RIGGER_RELEASE

During DMA stop/config/start the read/write pointer of HD-DMA is not reset unlike other DMAs (GPDMA, DMAC).

Only call the audio_stream_reset() if the link is not serviced by HD-DMA.

Link: #8986
Fixes: 9831a9d ("audio: dai-zephyr: reset DMA buffer cursors on TRIGGER_RELEASE")

…RIGGER_RELEASE

During DMA stop/config/start the read/write pointer of HD-DMA is not
reset unlike other DMAs (GPDMA, DMAC).

Only call the audio_stream_reset() if the link is not serviced by HD-DMA.

Link: thesofproject#8986
Fixes: 9831a9d ("audio: dai-zephyr: reset DMA buffer cursors on TRIGGER_RELEASE")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi
Copy link
Contributor Author

imx build fail with error: 'alias_mask' not found ?

@LaurentiuM1234
Copy link
Contributor

imx build fail with error: 'alias_mask' not found ?

Caused by zephyrproject-rtos/zephyr#70219. Fix in #8945

@marc-hb
Copy link
Collaborator

marc-hb commented Apr 1, 2024

imx build fail with error: 'alias_mask' not found ?

only with the Zephyr main branch ("zmain"). Manifest build is fine: https://github.com/thesofproject/sof/actions/runs/8468096003/job/23200277967?pr=8995

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

+1 but I do think we need to rework the interface here, this is not a scalable approach.

*/
audio_stream_reset(&dd->dma_buffer->stream);
if (!(dd->dai->dma_caps & DMA_CAP_HDA))
audio_stream_reset(&dd->dma_buffer->stream);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@LaurentiuM1234 @dbaluta With this fixup in place, this does not look like a solid design anymore. Either SOF can assume something about Zephyr DMA driver behaviour, or it cannot. It does sound like instead of audio_stream_reset, SOF should synchronize its view of DMA driver state (either at start or stop) and we could again have code that works for all (then it's upto DMA drivers how they behave for pause/reset).

Not blocking this PR as this fixes a rather nasty bug with Intel HDA devices, but I think this needs further work. The HW details should be handled on Zephyr side and SOF code should be agnostic.

Copy link
Contributor

Choose a reason for hiding this comment

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

ACK. Just curious, why do we need the dma_stop() and dma_config() operations on release? If I recall correctly, an alternative to 9831a9d was to just, well, not do those, which worked on NXP platforms at least? This would have been another way of keeping the buffers consistent with each other (i.e: SOF view and DMA view)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LaurentiuM1234, HD-DMA zephyr driver does not support dma_resume(), other than that, I don't know why we do the stop/start here.. We do clear the buffer, so it would kind of make sense to stop/start the DMA, but why we clear the buffer on pause/resume? I don't know.

Copy link
Contributor

@LaurentiuM1234 LaurentiuM1234 left a comment

Choose a reason for hiding this comment

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

Might be worth creating an issue for the stuff @kv2019i mentioned so we can come back to it later on?

@ujfalusi
Copy link
Contributor Author

ujfalusi commented Apr 3, 2024

@dbaluta, @LaurentiuM1234, should we move the call to stream_reset() where we call dma_config() ?

@LaurentiuM1234
Copy link
Contributor

@dbaluta, @LaurentiuM1234, should we move the call to stream_reset() where we call dma_config() ?

You mean do it if there's no XRUN? Not sure if I can be of much help here as I've never messed around with the XRUN stuff :(

@ujfalusi
Copy link
Contributor Author

ujfalusi commented Apr 3, 2024

@dbaluta, @LaurentiuM1234, should we move the call to stream_reset() where we call dma_config() ?

You mean do it if there's no XRUN? Not sure if I can be of much help here as I've never messed around with the XRUN stuff :(

OK, let's leave it where it is and move it if needed.

@kv2019i
Copy link
Collaborator

kv2019i commented Apr 3, 2024

#9002 filed to track the follow-up. Merging the fix.

@kv2019i kv2019i merged commit baca261 into thesofproject:main Apr 3, 2024
43 of 45 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.

[BUG] Audio become 'metallic' after few pause/resume cycle
5 participants