ASoC: soc-pcm: Use different sequence for start/stop trigger
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Fri, 27 Sep 2019 07:16:46 +0000 (10:16 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 1 Oct 2019 11:19:56 +0000 (12:19 +0100)
commit4378f1fbe924054a09ff0d4e39e1a581b9245252
tree2cc1c39f76d228987e59aad0636536b0623176a4
parent703df4413ff6cf1812922522daa7c0610f087910
ASoC: soc-pcm: Use different sequence for start/stop trigger

On stream stop currently we stop the DMA first followed by the CPU DAI.
This can cause underflow (playback) or overflow (capture) on the DAI side
as the DMA is no longer feeding data while the DAI is still active.
It can be observed easily if the DAI side does not have FIFO (or it is
disabled) to survive the time while the DMA is stopped, but still can
happen on relatively slow CPUs when relatively high sampling rate is used:
the FIFO is drained between the time the DMA is stopped and the DAI is
stopped.

It can only fixed by using different sequence within trigger for 'stop' and
'start':
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
Trigger order: dai_link, DMA, CPU DAI then the codec

case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
Trigger order: codec, CPU DAI, DMA then dai_link

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190927071646.22319-1-peter.ujfalusi@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-pcm.c