* [PATCH] ASoC: fsl_micfil: balance mclk enable/disable
@ 2026-08-22 11:59 Ștefan Ghețu
2026-08-26 7:39 ` Chancel Liu
2026-08-30 20:51 ` [PATCH v2] " Ștefan Ghețu
0 siblings, 2 replies; 4+ messages in thread
From: Ștefan Ghețu @ 2026-08-22 11:59 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linuxppc-dev, linux-kernel, Ștefan Ghețu
hw_params() enables mclk unconditionally and hw_free() disables it
unconditionally, but the PCM core does not guarantee 1:1 pairing:
hw_free() can run without hw_params(), and hw_params() can be called
multiple times from the SETUP state. This triggers an "already
disabled" WARN() in the first case and leaks an enable reference in
the second, leaving the clock ungateable.
Guard both sides with the existing mclk_flag, as fsl_sai.c does with
mclk_streams.
Fixes: b47024dc624b ("ASoC: fsl_micfil: Add mclk enable flag")
Signed-off-by: Ștefan Ghețu <stefanghetu9@gmail.com>
---
sound/soc/fsl/fsl_micfil.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c
index 60ac8eabab9da..5d8f0f76ab46f 100644
--- a/sound/soc/fsl/fsl_micfil.c
+++ b/sound/soc/fsl/fsl_micfil.c
@@ -953,12 +953,17 @@ static int fsl_micfil_reparent_rootclk(struct fsl_micfil *micfil, unsigned int s
/* Get root clock */
clk = micfil->mclk;
- /* Disable clock first, for it was enabled by pm_runtime */
+ /* Reparent root clock to the PLL matching this sample rate */
fsl_asoc_reparent_pll_clocks(dev, clk, micfil->pll8k_clk,
micfil->pll11k_clk, ratio);
- ret = clk_prepare_enable(clk);
- if (ret)
- return ret;
+
+ /* Enable only once; hw_params can be called multiple times */
+ if (!micfil->mclk_flag) {
+ ret = clk_prepare_enable(clk);
+ if (ret)
+ return ret;
+ micfil->mclk_flag = true;
+ }
return 0;
}
@@ -991,8 +996,6 @@ static int fsl_micfil_hw_params(struct snd_pcm_substream *substream,
if (ret)
return ret;
- micfil->mclk_flag = true;
-
/* floor(K * CLKDIV) */
switch (micfil->quality) {
case QUALITY_HIGH:
@@ -1068,8 +1071,10 @@ static int fsl_micfil_hw_free(struct snd_pcm_substream *substream,
{
struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai);
- clk_disable_unprepare(micfil->mclk);
- micfil->mclk_flag = false;
+ if (micfil->mclk_flag) {
+ clk_disable_unprepare(micfil->mclk);
+ micfil->mclk_flag = false;
+ }
return 0;
}
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: fsl_micfil: balance mclk enable/disable
2026-08-22 11:59 [PATCH] ASoC: fsl_micfil: balance mclk enable/disable Ștefan Ghețu
@ 2026-08-26 7:39 ` Chancel Liu
2026-08-30 20:51 ` [PATCH v2] " Ștefan Ghețu
1 sibling, 0 replies; 4+ messages in thread
From: Chancel Liu @ 2026-08-26 7:39 UTC (permalink / raw)
To: stefanghetu9
Cc: Xiubo.Lee, broonie, festevam, lgirdwood, linux-kernel,
linux-sound, linuxppc-dev, nicoleotsuka, perex, shengjiu.wang,
tiwai
> Fixes: b47024dc624b ("ASoC: fsl_micfil: Add mclk enable flag")
>
> Signed-off-by: Ștefan Ghețu <stefanghetu9@gmail.com>
Nit: please drop the blank line between the Fixes and Signed-off-by
tags. With that fixed:
Reviewed-by: Chancel Liu <chancel.liu@nxp.com>
Regards,
Chancel Liu
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] ASoC: fsl_micfil: balance mclk enable/disable
2026-08-22 11:59 [PATCH] ASoC: fsl_micfil: balance mclk enable/disable Ștefan Ghețu
2026-08-26 7:39 ` Chancel Liu
@ 2026-08-30 20:51 ` Ștefan Ghețu
2026-09-01 12:49 ` Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Ștefan Ghețu @ 2026-08-30 20:51 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen, Mark Brown
Cc: Chancel Liu, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
linux-sound, linuxppc-dev, linux-kernel, Ștefan Ghețu
hw_params() enables mclk unconditionally and hw_free() disables it
unconditionally, but the PCM core does not guarantee 1:1 pairing:
hw_free() can run without hw_params(), and hw_params() can be called
multiple times from the SETUP state. This triggers an "already
disabled" WARN() in the first case and leaks an enable reference in
the second, leaving the clock ungateable.
Guard both sides with the existing mclk_flag, as fsl_sai.c does with
mclk_streams.
Fixes: b47024dc624b ("ASoC: fsl_micfil: Add mclk enable flag")
Signed-off-by: Ștefan Ghețu <stefanghetu9@gmail.com>
---
sound/soc/fsl/fsl_micfil.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c
index 60ac8eabab9da..5d8f0f76ab46f 100644
--- a/sound/soc/fsl/fsl_micfil.c
+++ b/sound/soc/fsl/fsl_micfil.c
@@ -953,12 +953,17 @@ static int fsl_micfil_reparent_rootclk(struct fsl_micfil *micfil, unsigned int s
/* Get root clock */
clk = micfil->mclk;
- /* Disable clock first, for it was enabled by pm_runtime */
+ /* Reparent root clock to the PLL matching this sample rate */
fsl_asoc_reparent_pll_clocks(dev, clk, micfil->pll8k_clk,
micfil->pll11k_clk, ratio);
- ret = clk_prepare_enable(clk);
- if (ret)
- return ret;
+
+ /* Enable only once; hw_params can be called multiple times */
+ if (!micfil->mclk_flag) {
+ ret = clk_prepare_enable(clk);
+ if (ret)
+ return ret;
+ micfil->mclk_flag = true;
+ }
return 0;
}
@@ -991,8 +996,6 @@ static int fsl_micfil_hw_params(struct snd_pcm_substream *substream,
if (ret)
return ret;
- micfil->mclk_flag = true;
-
/* floor(K * CLKDIV) */
switch (micfil->quality) {
case QUALITY_HIGH:
@@ -1068,8 +1071,10 @@ static int fsl_micfil_hw_free(struct snd_pcm_substream *substream,
{
struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai);
- clk_disable_unprepare(micfil->mclk);
- micfil->mclk_flag = false;
+ if (micfil->mclk_flag) {
+ clk_disable_unprepare(micfil->mclk);
+ micfil->mclk_flag = false;
+ }
return 0;
}
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ASoC: fsl_micfil: balance mclk enable/disable
2026-08-30 20:51 ` [PATCH v2] " Ștefan Ghețu
@ 2026-09-01 12:49 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-09-01 12:49 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Ștefan Ghețu
Cc: Chancel Liu, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
linux-sound, linuxppc-dev, linux-kernel
On Sun, 30 Aug 2026 23:51:06 +0300, Ștefan Ghețu wrote:
> ASoC: fsl_micfil: balance mclk enable/disable
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: fsl_micfil: balance mclk enable/disable
https://git.kernel.org/broonie/sound/c/d3dbccfe6afa
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-09-01 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-22 11:59 [PATCH] ASoC: fsl_micfil: balance mclk enable/disable Ștefan Ghețu
2026-08-26 7:39 ` Chancel Liu
2026-08-30 20:51 ` [PATCH v2] " Ștefan Ghețu
2026-09-01 12:49 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®