Skip to content

Conversation

@RanderWang
Copy link

Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for
SOF. This means FE will be stopped before BE, so BE will consume
invalid data and this generates huge pop noise. Now set trigger
sequence to SND_SOC_DPCM_TRIGGER_PRE to let FE to be stopped after
BE to avoid this issue.

Thanks @YvonneYang2 Fully tested on Comet Lake for a few cycles. She didn't find any issue on Comet Lake U. On Comet Lake H, she found a clock stop issue when doing S3 stress test, but she can't reproduce it again. I think is not connect to this PR directly.

Fixes #1867 #1869 #1865 #1866

@ClarexZhou
Copy link

ClarexZhou commented Mar 16, 2020

Error is much improved with PR#1897. But still has very light pop via scenario "pause aplay first then Ctl+c to release aplay". Can observe this pop sound when increase speaker volume to Max via PGA3.0 3
Tested with kernel sof-dev, commit: 0f90705 + PR #1897 and FW: https://github.com/thesofproject/sof/tree/cml-010-hot-fix, commit thesofproject/sof@0ed0dba + commit thesofproject/sof@f73332e
And with same kernel sof-dev, commit: 0f90705 + PR #1897 and FW: Master, commit: thesofproject/sof@afd9770,

ClarexZhou
ClarexZhou previously approved these changes Mar 16, 2020
fe->dai_link->trigger[SNDRV_PCM_STREAM_PLAYBACK] =
SND_SOC_DPCM_TRIGGER_PRE;
fe->dai_link->trigger[SNDRV_PCM_STREAM_CAPTURE] =
SND_SOC_DPCM_TRIGGER_PRE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@RanderWang a question: this PR aims at reducing the "pop" noise for playback. Do we need to change capture too?

Copy link
Author

Choose a reason for hiding this comment

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

@lyakh I just restore the default behavior, please check (fd274c2). I will communicate with QA to get more info.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this be called multi times?

Copy link
Author

Choose a reason for hiding this comment

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

I confirmed with QA, they didn't find noise in wav data.

Copy link
Author

Choose a reason for hiding this comment

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

Will this be called multi times?

just like hw_params

Copy link
Collaborator

Choose a reason for hiding this comment

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

@RanderWang just wondering why not do this in sof_link_load()?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh I guess we dont know if this is connected to an ALH BE during link_load.

@kv2019i
Copy link
Collaborator

kv2019i commented Mar 16, 2020

Good fine @RanderWang ! Because we have been switching the orders before, I'd want to have an explicit ack from @ranj063 that this is ok. We obviously need to do something due ot the many bugs, but let's still make sure we are fixing at the right place. Also FYI @tlauda I would expect the BE to run out of data (xrun) in case FE is stopped first, but not to play out garbage, but the tests do point to different behaviour. Please comment.

@plbossart
Copy link
Member

I am also not comfortable with this change. We had a very long discussion on this in the context of HDaudio, and now we would revert the trigger order only for ALH - but what about SSP/DMIC which also use the GPDMA.
For playback I still think triggering the FE before the BE makes sense, I never really understood why for HDaudio we had to use a reverse order.

@RanderWang
Copy link
Author

I am also not comfortable with this change. We had a very long discussion on this in the context of HDaudio, and now we would revert the trigger order only for ALH - but what about SSP/DMIC which also use the GPDMA.
For playback I still think triggering the FE before the BE makes sense, I never really understood why for HDaudio we had to use a reverse order.

Last week I just reverted the commit to use PRE sequence for all and @YvonneYang2 tested the patch. She found IPC timeout and DSP panic caused by HDMI, which uses link DMA. So it seems FW require POST sequence for link dma. @tlauda can you help to explain this ?

@RanderWang
Copy link
Author

Good fine @RanderWang ! Because we have been switching the orders before, I'd want to have an explicit ack from @ranj063 that this is ok. We obviously need to do something due ot the many bugs, but let's still make sure we are fixing at the right place. Also FYI @tlauda I would expect the BE to run out of data (xrun) in case FE is stopped first, but not to play out garbage, but the tests do point to different behaviour. Please comment.

The pop noise should be caused by this case: the value of last data sample should be much bigger than zero and suddenly followed by zero-value data, so a sound like "bang"

@plbossart
Copy link
Member

@tlauda @ranj063 please chime in. We are now in the unfortunate case where what is required for the HDaudio link breaks the GPDMA/ALH case. Please don't tell me we need to have a trigger order that depends on the endpoint :-(

@ranj063
Copy link
Collaborator

ranj063 commented Mar 17, 2020

@tlauda @ranj063 please chime in. We are now in the unfortunate case where what is required for the HDaudio link breaks the GPDMA/ALH case. Please don't tell me we need to have a trigger order that depends on the endpoint :-(

@plbossart unfortunately from the results it looks like that might indeed be the case.

But I have a suggestion. Instead of setting the trigger order to POST during topology loading, I think we should we should leave it as default during topology loading and only set the trigger order to POST in the BE hw_params() ioctl for HDA link.

@plbossart
Copy link
Member

@ranj063 @tlauda rather than discussing where the order change is handled, can we please have clarity on why the HDaudio link DMA requires a specific order and SoundWire another?

That is the big question to me, and I am not willing to merge anything until we understand what the directions are. It seems like a firmware dependency that's not properly handled or documented

@ranj063
Copy link
Collaborator

ranj063 commented Mar 18, 2020

@ranj063 @tlauda rather than discussing where the order change is handled, can we please have clarity on why the HDaudio link DMA requires a specific order and SoundWire another?

That is the big question to me, and I am not willing to merge anything until we understand what the directions are. It seems like a firmware dependency that's not properly handled or documented

@plbossart I am just as much in the dark about this as you are. I was under the impression that when we made the change the last time around it was going to be blanket fix for all types of BEs. I'll have to punt this to the FW team @tlauda , please could you chime in?

@tlauda
Copy link

tlauda commented Mar 19, 2020

@plbossart @ranj063 @RanderWang I'm not very familiar with the differences between FE and BE triggers, so maybe I will just describe why the order has been changed in the first place. When you are sending TRIGGER_START/RELEASE IPC to the FW, the DSP starts the pipeline immediately. Pipelines are scheduled on timer, so ticks are happening asynchronously to the IPCs. Since you first triggered the pipeline and HDA Link was started after that, sometimes there was a race happening, where we expected to copy the data, but the data wasn't yet there. It often caused xruns. The same thing is for the STOP sequence, but for the stop it gets even worse, since the wrong sequence between FW and host can hang everything.
For DMIC and SSP there is probably no difference, since FW is controlling the majority of the interface.
I'm not an expert for SDW, but if the pop noise is at the beginning of the stream, shouldn't we just empty ALH FIFO, zero out the DMA buffer and that should fix the problem?

@ranj063
Copy link
Collaborator

ranj063 commented Mar 19, 2020

@plbossart @ranj063 @RanderWang I'm not very familiar with the differences between FE and BE triggers, so maybe I will just describe why the order has been changed in the first place. When you are sending TRIGGER_START/RELEASE IPC to the FW, the DSP starts the pipeline immediately. Pipelines are scheduled on timer, so ticks are happening asynchronously to the IPCs. Since you first triggered the pipeline and HDA Link was started after that, sometimes there was a race happening, where we expected to copy the data, but the data wasn't yet there. It often caused xruns. The same thing is for the STOP sequence, but for the stop it gets even worse, since the wrong sequence between FW and host can hang everything.
For DMIC and SSP there is probably no difference, since FW is controlling the majority of the interface.
I'm not an expert for SDW, but if the pop noise is at the beginning of the stream, shouldn't we just empty ALH FIFO, zero out the DMA buffer and that should fix the problem?

@tlauda the xruns we saw was for the capture case where starting the BE before the FE makes sense because you dont want to be in a situation where there's nothing to copy. Shouldnt the order be the reverse then for playback? But that would make it even more crazy to have 2 different trigger orders for playback and capture. Does it make sense?

@tlauda
Copy link

tlauda commented Mar 19, 2020

@ranj063 We saw underruns on playback pipes: #1160.

@ranj063
Copy link
Collaborator

ranj063 commented Mar 19, 2020

@ranj063 We saw underruns on playback pipes: #1160.

@tlauda oh yeah. dont know why I have it as capture in my mind. So in the case of HDA link DMA< even for playback the trigger order makes sense.

So now to @plbossart 's question. Why should it change for SDW?

@tlauda
Copy link

tlauda commented Mar 19, 2020

@ranj063 We saw underruns on playback pipes: #1160.

@tlauda oh yeah. dont know why I have it as capture in my mind. So in the case of HDA link DMA< even for playback the trigger order makes sense.

So now to @plbossart 's question. Why should it change for SDW?

@RanderWang Have you tried what I proposed? Emptying ALH/SDW FIFO (in kernel) and zeroing DMA buffer (in FW)? Maybe it will help for the pop without changing any order.

@RanderWang
Copy link
Author

@ranj063 We saw underruns on playback pipes: #1160.

@tlauda oh yeah. dont know why I have it as capture in my mind. So in the case of HDA link DMA< even for playback the trigger order makes sense.
So now to @plbossart 's question. Why should it change tfor SDW?

@RanderWang Have you tried what I proposed? Emptying ALH/SDW FIFO (in kernel) and zeroing DMA buffer (in FW)? Maybe it will help for the pop without changing any order.

@tlauda We have tested this solution "Emptying ALH/SDW FIFO (in kernel) and zeroing DMA buffer (in FW)"(#1887 & thesofproject/sof#2573), but still have pop noise when stop playback. And you can image when someone is climbing a ladder and the ladder is suddenly removed, what will happen.

@tlauda
Copy link

tlauda commented Mar 20, 2020

@RanderWang So the pop is also when stopping playback? How is that possible if the FW pipeline is stopped first?

@RanderWang
Copy link
Author

@RanderWang So the pop is also when stopping playback? How is that possible if the FW pipeline is stopped first?

@tlauda please check above bugs, not only start & stop, but also pulse & resume. If FW is stopped first, then the there is no data sent to sdw bus, and there is a abrupt change in data stream, just produce a big bang.
pop

@RanderWang RanderWang requested a review from singalsu as a code owner April 15, 2020 05:22
@RanderWang
Copy link
Author

@ClarexZhou Now I change the trigger sequence of playback for both SDW & I2S, can you help to validate playback on I2S platforms ? thanks!

@sinahuang
Copy link

sinahuang commented Apr 15, 2020

@ClarexZhou Now I change the trigger sequence of playback for both SDW & I2S, can you help to validate playback on I2S platforms ? thanks!

Do all sanity test and check all noise scenarios on GLK Chrome with onboard codec DA7219 in I2S mode, found no regression.

@RanderWang
Copy link
Author

@ClarexZhou Now I change the trigger sequence of playback for both SDW & I2S, can you help to validate playback on I2S platforms ? thanks!

Do all sanity test and check all noise scenarios on GLK Chrome with onboard codec DA7219 in I2S mode, found no regression.

Thanks!

jason77-wang pushed a commit to jason77-wang/linux-1 that referenced this pull request Apr 15, 2020
BugLink: https://bugs.launchpad.net/bugs/1872916

Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for
SOF. This means FE will be stopped before BE, so BE will consume
invalid data and this generates huge pop noise. Now set trigger
sequence to SND_SOC_DPCM_TRIGGER_PRE to let FE to be stopped after
BE to avoid this issue.

Fully tested on Comet Lake for a few cycles.

Signed-off-by: randerwang <rander.wang@linux.intel.com>
(backported from thesofproject#1897)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
@RanderWang
Copy link
Author

@plbossart update my PR to unify the trigger sequence with I2S & sdw.

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Please add more comments or reword them. Thanks @RanderWang

* HDA and sdw. Frontend is started before the backend
* when start playback and Frontend is stopped after the
* backend when stop playback. The tigger order is reverse
* for Capture compared to playback.
Copy link
Member

Choose a reason for hiding this comment

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

suggested edit:

set default trigger order for all links. Exceptions to the rule will be handled in sof_pcm_dai_link_fixup()
For playback, the sequence is the following:
start FE, start BE, stop BE, stop FE
For Capture the sequence is inverted
start BE, start FE, stop FE, stop BE

@ranj063 can you please review this since you modified the sequence for HDaudio. Thanks!

@plbossart plbossart changed the title ASoC: SOF: Intel: fix pop noise when stop playback on sdw platforms ASoC: SOF: change trigger sequence to fix pop noise when stopping playback on sdw platforms Apr 15, 2020
@plbossart plbossart requested review from ClarexZhou and lyakh April 15, 2020 22:33
…ing playback on sdw platforms

Now the trigger sequence is set to SND_SOC_DPCM_TRIGGER_POST for
SOF. This means FE will be stopped before BE, so BE will consume
invalid data and this generates huge pop noise. This sequence is
introduced for HDA DAI which requires SND_SOC_DPCM_TRIGGER_POST for
some reasons. Now set default trigger sequence to SND_SOC_DPCM_TRIGGER_PRE
for playback with all DAI and fix sequence only for HDA DAI.

Fully tested on Comet Lake for a few cycles.

Signed-off-by: randerwang <rander.wang@linux.intel.com>
@RanderWang
Copy link
Author

QA also tested HDMI playback. Thanks!

Copy link

@ClarexZhou ClarexZhou left a comment

Choose a reason for hiding this comment

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

Tested on GLK I2S and CML-U&H SDW. Works OK and no regression.

Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

just for my info: this means, with HDA DAIs we will still have pop noises and they are impossible to fix?

@RanderWang
Copy link
Author

just for my info: this means, with HDA DAIs we will still have pop noises and they are impossible to fix?

@lyakh It also depends on audio IP connected to codecs. Now we don't get pop noise issue with HDA link.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@RanderWang can you check if this has any impact on capture.

@plbossart
Copy link
Member

@RanderWang can you check if this has any impact on capture.

capture is not modified by this PR.

@lyakh
Copy link
Collaborator

lyakh commented Apr 17, 2020

just for my info: this means, with HDA DAIs we will still have pop noises and they are impossible to fix?

@lyakh It also depends on audio IP connected to codecs. Now we don't get pop noise issue with HDA link.

@RanderWang got it, thanks!

Copy link
Collaborator

@ranj063 ranj063 left a comment

Choose a reason for hiding this comment

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

@plbossart @RanderWang I made an interesting discovery today while trying to debug another issue with power management. Basically, what I noticed was the idle_bias_on setting for the component driver has some connection with the xruns that we saw with pause/release in capture. So, to confirm this, I set the trigger order for the DAI's in the SOF driver to the default TRIGGER_PRE and set the "idle_bias_on" in the hdac codec component driver to true.

So my suggestion is try experimenting with the idle_bias_on setting in the rt1308/rt711 codec component drivers and see if this problem can be fixed.

Copy link
Collaborator

@ranj063 ranj063 left a comment

Choose a reason for hiding this comment

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

idle_bias_off might have PM regressions. so this change is good.

@RanderWang RanderWang requested a review from kv2019i April 20, 2020 02:40
@RanderWang
Copy link
Author

@kv2019i sorry, I assumed you were reviewer for you commented it, now add you to review this PR. Thanks!

@kv2019i
Copy link
Collaborator

kv2019i commented Apr 20, 2020

@RanderWang wrote:

@kv2019i sorry, I assumed you were reviewer for you commented it, now add you to review this

It seems this patch has sufficient review approvals already. So the remaining blockers are @plbossart request-changes. Another are the CML SDW failures in CI, why are these happening:
https://sof-ci.01.org/linuxpr/PR1897/build3587/devicetest/CML_RVP_SDW/check-pause-resume-playback-10/
... ?

@plbossart
Copy link
Member

@RanderWang wrote:

@kv2019i sorry, I assumed you were reviewer for you commented it, now add you to review this

It seems this patch has sufficient review approvals already. So the remaining blockers are @plbossart request-changes. Another are the CML SDW failures in CI, why are these happening:
https://sof-ci.01.org/linuxpr/PR1897/build3587/devicetest/CML_RVP_SDW/check-pause-resume-playback-10/
... ?

SoundWire pause/resume is currently not supported, so this test should be skipped for now.

@RanderWang
Copy link
Author

@RanderWang wrote:

@kv2019i sorry, I assumed you were reviewer for you commented it, now add you to review this

It seems this patch has sufficient review approvals already. So the remaining blockers are @plbossart request-changes. Another are the CML SDW failures in CI, why are these happening:
https://sof-ci.01.org/linuxpr/PR1897/build3587/devicetest/CML_RVP_SDW/check-pause-resume-playback-10/
... ?

we need another PR to fix it thesofproject/sof#2673

@plbossart
Copy link
Member

Let's merge and see what QA reports.

@plbossart plbossart merged commit 363b960 into thesofproject:topic/sof-dev Apr 21, 2020
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.

[SDW][BUG]Pop noise occurred at the beginning of aplay0,2(RT1308) or aplay0,0(RT711)