]> git.hungrycats.org Git - linux/commit
ALSA: dmaengine_pcm: terminate dmaengine before synchronize
authorShengjiu Wang <shengjiu.wang@nxp.com>
Thu, 20 Jun 2024 02:40:18 +0000 (10:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:36 +0000 (09:53 +0200)
commitdeac270957db0e463a724d282e2250e352513f23
tree0cf6efb2e0a8386410f7d3d368fabc7db9917a69
parentff57edd51cac6ce8b2afc6ffac8bc5f2861a3fca
ALSA: dmaengine_pcm: terminate dmaengine before synchronize

[ Upstream commit 6a7db25aad8ce6512b366d2ce1d0e60bac00a09d ]

When dmaengine supports pause function, in suspend state,
dmaengine_pause() is called instead of dmaengine_terminate_async(),

In end of playback stream, the runtime->state will go to
SNDRV_PCM_STATE_DRAINING, if system suspend & resume happen
at this time, application will not resume playback stream, the
stream will be closed directly, the dmaengine_terminate_async()
will not be called before the dmaengine_synchronize(), which
violates the call sequence for dmaengine_synchronize().

This behavior also happens for capture streams, but there is no
SNDRV_PCM_STATE_DRAINING state for capture. So use
dmaengine_tx_status() to check the DMA status if the status is
DMA_PAUSED, then call dmaengine_terminate_async() to terminate
dmaengine before dmaengine_synchronize().

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://patch.msgid.link/1718851218-27803-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/core/pcm_dmaengine.c