Skip to content

dai-zephyr: Fix the ordering of DAI and DMA triggers during - #7295

Merged
kv2019i merged 1 commit into
thesofproject:mainfrom
ranj063:fix/trigger_order
Mar 20, 2023
Merged

kv2019i merged 1 commit into
thesofproject:mainfrom
ranj063:fix/trigger_order

Conversation

@ranj063

@ranj063 ranj063 commented Mar 16, 2023

Copy link
Copy Markdown
Collaborator

pause/release

Pause the DAI before the DMA and start the DMA before starting the DAI during release.

@greg-intel

Copy link
Copy Markdown
Contributor

SOFCI TEST

1 similar comment
@ranj063

ranj063 commented Mar 17, 2023

Copy link
Copy Markdown
Collaborator Author

SOFCI TEST

@kv2019i

kv2019i commented Mar 17, 2023

Copy link
Copy Markdown
Collaborator

@abonislawski Can you check? The order was changed (compared to legacy) in the original "dma: add Zephyr native DMA support to host & dai" commit.

@abonislawski abonislawski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@kv2019i this one is correct

Comment thread src/audio/dai-zephyr.c Outdated

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.

Should not be handled like the STOP? there is this comment in that section:

/*
 * Some platforms cannot just simple disable
 * DMA channel during the transfer,
 * because it will hang the whole DMA controller.
 * Therefore, stop the DMA first and let the DAI
 * drain the FIFO in order to stop the channel
 * as soon as possible.
 */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dbaluta did NXP have this issue with ordering or am I thinking about another platform. If so, may need a Kconfig.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I remember having some issues on the NXP side with the ordering indeed. Kconfig sounds good.

@iuliana-prodan iuliana-prodan Mar 17, 2023 •

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.

I added the above comment (with this PR https://github.com/thesofproject/sof/pull/3867/files).
And I used a config (CONFIG_DMA_SUSPEND_DRAIN) to have it differently for i.MX, but it was done only on start/stop.
I believe we can do the same for pause/release.

@dbaluta dbaluta Mar 17, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@lgirdwood we did have this problem. See @iuliana-prodan comment. I think we should create a special CONFIG_ENABLE_DMA_FIRST and put everything under this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@iuliana-prodan @dbaluta using CONFIG_DMA_SUSPEND_DRAIN is a bit misleading I think. What I can do is make the default as dma_start()->dai_start for START/RELEASE and dai_stop()->dma_stop() for STOP/PAUSE.

And add a new CONFIG called CONFIG_DAI_TRIGGER_ORDER_REVERSE to reverse the order. Would that be OK for you?

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.

@ranj063 yes, that's ok for i.MX.
Thank you!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@iuliana-prodan I think i was wrong. I should only reverse the order for stop/pause right? It doesnt make sense to do dai_start before dma_start() even for IMX. I've fixed it now. have a look please

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.

It's ok now @ranj063
Thank you!

@lyakh lyakh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems reasonable: you first enable the DMA, so that later when the DAI srarts, it triggers the DMA - either to get data from it or to send data to it, so DMA should already be ready. Why did we have it in reverse odrer before? Has it always been like that or is this a recent change?

Comment thread src/audio/Kconfig Resolved
During start trigger, the DMA is be started first followed by the DAI. The
same order should also apply for the release triggers. Conversely, during
stop/pause the DAI must be stopped first before the DMA.

But some platforms cannot handle the conventional ordering during the
stop/pause triggers. Add a new config,
COMP_DAI_STOP_TRIGGER_ORDER_REVERSE, that will be used to reverse the
DMA and DAI trigger order during stop/pause. Also, fix the stop case to
use the new config to reverse the ordering instead of
COMP_DMA_SUSPEND_DRAIN.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@ranj063
ranj063 force-pushed the fix/trigger_order branch from 85a5b8d to e731fad Compare March 17, 2023 18:01
@kv2019i

kv2019i commented Mar 20, 2023

Copy link
Copy Markdown
Collaborator

Good to go @iuliana-prodan @dbaluta ?

Comment thread src/audio/Kconfig
Select if the ordering of DMA and DAI triggers during stop/pause should be reversed.
The normal order during stop/pause is to stop DAI before stopping DMA. This option will
allow reversing the order to do DMA stop before stopping DAI.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be good to align use of the Kconfigs in dai-legacy.c as well.

@iuliana-prodan

Copy link
Copy Markdown
Contributor

Good to go @iuliana-prodan @dbaluta ?

yes, it's ok. Thanks!

@dbaluta

dbaluta commented Mar 20, 2023

Copy link
Copy Markdown
Collaborator

@lyakh I think is fine. We need to update src/audio/dai-legacy.c also. Rename CONFIG_DMA_SUSPEND_DRAIN to COMP_DAI_STOP_TRIGGER_ORDER_REVERSE

@kv2019i

kv2019i commented Mar 20, 2023

Copy link
Copy Markdown
Collaborator

One fail in https://sof-ci.01.org/sofpr/PR7295/build4799/devicetest/index.html , but that seems unrelated to this PR, so proceeding with merge.

@kv2019i
kv2019i merged commit a6a80ec into thesofproject:main Mar 20, 2023
@ranj063
ranj063 deleted the fix/trigger_order branch March 20, 2023 18:22
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.