* [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free
@ 2026-10-19 6:58 Chancel Liu
2026-10-19 20:42 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chancel Liu @ 2026-10-19 6:58 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Frank Li, Sascha Hauer, Pengutronix Kernel Team
Cc: linux-sound, linuxppc-dev, imx, linux-arm-kernel, linux-kernel,
Chancel Liu
From: Chancel Liu <chancel.liu@nxp.com>
imx_rpmsg_terminate_all() queues the TERMINATE message to the workqueue
and returns, while the DAI hw_free() synchronously gates the audio
clock. The two can then run concurrently, and this concurrent access to
the shared audio clock path can cause a stop failure or even hang the
system.
Flush the workqueue in a new component hw_free(), which runs before the
DAI hw_free(), so TERMINATE is fully handled before the clock is gated.
CLOSE stays the last message.
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
sound/soc/fsl/imx-pcm-rpmsg.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
index 85b7c929a28a..6a0174d6c78d 100644
--- a/sound/soc/fsl/imx-pcm-rpmsg.c
+++ b/sound/soc/fsl/imx-pcm-rpmsg.c
@@ -178,6 +178,16 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component,
return 0;
}
+static int imx_rpmsg_pcm_hw_free(struct snd_soc_component *component,
+ struct snd_pcm_substream *substream)
+{
+ struct rpmsg_info *info = dev_get_drvdata(component->dev);
+
+ flush_workqueue(info->rpmsg_wq);
+
+ return 0;
+}
+
static snd_pcm_uframes_t imx_rpmsg_pcm_pointer(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
@@ -285,9 +295,6 @@ static int imx_rpmsg_pcm_close(struct snd_soc_component *component,
struct rpmsg_info *info = dev_get_drvdata(component->dev);
struct rpmsg_msg *msg;
- /* Flush work in workqueue to make TX_CLOSE is the last message */
- flush_workqueue(info->rpmsg_wq);
-
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
msg = &info->msg[TX_CLOSE];
msg->s_msg.header.cmd = TX_CLOSE;
@@ -624,6 +631,7 @@ static const struct snd_soc_component_driver imx_rpmsg_soc_component = {
.open = imx_rpmsg_pcm_open,
.close = imx_rpmsg_pcm_close,
.hw_params = imx_rpmsg_pcm_hw_params,
+ .hw_free = imx_rpmsg_pcm_hw_free,
.trigger = imx_rpmsg_pcm_trigger,
.pointer = imx_rpmsg_pcm_pointer,
.ack = imx_rpmsg_pcm_ack,
---
base-commit: 8d00cfd77ffa64477129969eec8249c8cdadc9c2
change-id: 20261019-b4-imx-pcm-rpmsg-concurrent-1522959ba768
Best regards,
--
Chancel Liu <chancel.liu@nxp.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free
2026-10-19 6:58 [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free Chancel Liu
@ 2026-10-19 20:42 ` Frank Li
2026-10-22 9:36 ` Shengjiu Wang
2026-10-28 17:04 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2026-10-19 20:42 UTC (permalink / raw)
To: Chancel Liu
Cc: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Frank Li, Sascha Hauer, Pengutronix Kernel Team, linux-sound,
linuxppc-dev, imx, linux-arm-kernel, linux-kernel, Chancel Liu
On Mon, Oct 19, 2026 at 03:58:20PM +0900, Chancel Liu wrote:
> From: Chancel Liu <chancel.liu@nxp.com>
>
> imx_rpmsg_terminate_all() queues the TERMINATE message to the workqueue
> and returns, while the DAI hw_free() synchronously gates the audio
> clock. The two can then run concurrently, and this concurrent access to
> the shared audio clock path can cause a stop failure or even hang the
> system.
>
> Flush the workqueue in a new component hw_free(), which runs before the
> DAI hw_free(), so TERMINATE is fully handled before the clock is gated.
> CLOSE stays the last message.
>
> Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> sound/soc/fsl/imx-pcm-rpmsg.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
> index 85b7c929a28a..6a0174d6c78d 100644
> --- a/sound/soc/fsl/imx-pcm-rpmsg.c
> +++ b/sound/soc/fsl/imx-pcm-rpmsg.c
> @@ -178,6 +178,16 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component,
> return 0;
> }
>
> +static int imx_rpmsg_pcm_hw_free(struct snd_soc_component *component,
> + struct snd_pcm_substream *substream)
> +{
> + struct rpmsg_info *info = dev_get_drvdata(component->dev);
> +
> + flush_workqueue(info->rpmsg_wq);
> +
> + return 0;
> +}
> +
> static snd_pcm_uframes_t imx_rpmsg_pcm_pointer(struct snd_soc_component *component,
> struct snd_pcm_substream *substream)
> {
> @@ -285,9 +295,6 @@ static int imx_rpmsg_pcm_close(struct snd_soc_component *component,
> struct rpmsg_info *info = dev_get_drvdata(component->dev);
> struct rpmsg_msg *msg;
>
> - /* Flush work in workqueue to make TX_CLOSE is the last message */
> - flush_workqueue(info->rpmsg_wq);
> -
> if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> msg = &info->msg[TX_CLOSE];
> msg->s_msg.header.cmd = TX_CLOSE;
> @@ -624,6 +631,7 @@ static const struct snd_soc_component_driver imx_rpmsg_soc_component = {
> .open = imx_rpmsg_pcm_open,
> .close = imx_rpmsg_pcm_close,
> .hw_params = imx_rpmsg_pcm_hw_params,
> + .hw_free = imx_rpmsg_pcm_hw_free,
> .trigger = imx_rpmsg_pcm_trigger,
> .pointer = imx_rpmsg_pcm_pointer,
> .ack = imx_rpmsg_pcm_ack,
>
> ---
> base-commit: 8d00cfd77ffa64477129969eec8249c8cdadc9c2
> change-id: 20261019-b4-imx-pcm-rpmsg-concurrent-1522959ba768
>
> Best regards,
> --
> Chancel Liu <chancel.liu@nxp.com>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free
2026-10-19 6:58 [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free Chancel Liu
2026-10-19 20:42 ` Frank Li
@ 2026-10-22 9:36 ` Shengjiu Wang
2026-10-28 17:04 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Shengjiu Wang @ 2026-10-22 9:36 UTC (permalink / raw)
To: Chancel Liu
Cc: Xiubo Li, Fabio Estevam, Nicolin Chen, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, linux-sound, linuxppc-dev, imx,
linux-arm-kernel, linux-kernel, Chancel Liu
On Mon, Oct 19, 2026 at 2:58 PM Chancel Liu <chancel.liu@oss.nxp.com> wrote:
>
> From: Chancel Liu <chancel.liu@nxp.com>
>
> imx_rpmsg_terminate_all() queues the TERMINATE message to the workqueue
> and returns, while the DAI hw_free() synchronously gates the audio
> clock. The two can then run concurrently, and this concurrent access to
> the shared audio clock path can cause a stop failure or even hang the
> system.
>
> Flush the workqueue in a new component hw_free(), which runs before the
> DAI hw_free(), so TERMINATE is fully handled before the clock is gated.
> CLOSE stays the last message.
>
> Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
best regards
shengjiu Wang
> ---
> sound/soc/fsl/imx-pcm-rpmsg.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c
> index 85b7c929a28a..6a0174d6c78d 100644
> --- a/sound/soc/fsl/imx-pcm-rpmsg.c
> +++ b/sound/soc/fsl/imx-pcm-rpmsg.c
> @@ -178,6 +178,16 @@ static int imx_rpmsg_pcm_hw_params(struct snd_soc_component *component,
> return 0;
> }
>
> +static int imx_rpmsg_pcm_hw_free(struct snd_soc_component *component,
> + struct snd_pcm_substream *substream)
> +{
> + struct rpmsg_info *info = dev_get_drvdata(component->dev);
> +
> + flush_workqueue(info->rpmsg_wq);
> +
> + return 0;
> +}
> +
> static snd_pcm_uframes_t imx_rpmsg_pcm_pointer(struct snd_soc_component *component,
> struct snd_pcm_substream *substream)
> {
> @@ -285,9 +295,6 @@ static int imx_rpmsg_pcm_close(struct snd_soc_component *component,
> struct rpmsg_info *info = dev_get_drvdata(component->dev);
> struct rpmsg_msg *msg;
>
> - /* Flush work in workqueue to make TX_CLOSE is the last message */
> - flush_workqueue(info->rpmsg_wq);
> -
> if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> msg = &info->msg[TX_CLOSE];
> msg->s_msg.header.cmd = TX_CLOSE;
> @@ -624,6 +631,7 @@ static const struct snd_soc_component_driver imx_rpmsg_soc_component = {
> .open = imx_rpmsg_pcm_open,
> .close = imx_rpmsg_pcm_close,
> .hw_params = imx_rpmsg_pcm_hw_params,
> + .hw_free = imx_rpmsg_pcm_hw_free,
> .trigger = imx_rpmsg_pcm_trigger,
> .pointer = imx_rpmsg_pcm_pointer,
> .ack = imx_rpmsg_pcm_ack,
>
> ---
> base-commit: 8d00cfd77ffa64477129969eec8249c8cdadc9c2
> change-id: 20261019-b4-imx-pcm-rpmsg-concurrent-1522959ba768
>
> Best regards,
> --
> Chancel Liu <chancel.liu@nxp.com>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free
2026-10-19 6:58 [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free Chancel Liu
2026-10-19 20:42 ` Frank Li
2026-10-22 9:36 ` Shengjiu Wang
@ 2026-10-28 17:04 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-10-28 17:04 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Chancel Liu
Cc: linux-sound, linuxppc-dev, imx, linux-arm-kernel, linux-kernel,
Chancel Liu
On Mon, 19 Oct 2026 15:58:20 +0900, Chancel Liu wrote:
> ASoC: imx-pcm-rpmsg: Flush pending work in hw_free
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free
https://git.kernel.org/broonie/sound/c/bbe41586cdfa
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-29 0:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 6:58 [PATCH] ASoC: imx-pcm-rpmsg: Flush pending work in hw_free Chancel Liu
2026-10-19 20:42 ` Frank Li
2026-10-22 9:36 ` Shengjiu Wang
2026-10-28 17:04 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox