]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ASoC: stm32: sai: manage context in set_sysclk callback
authorOlivier Moysan <olivier.moysan@foss.st.com>
Tue, 16 Sep 2025 12:31:18 +0000 (14:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:30 +0000 (15:34 -0500)
[ Upstream commit 27fa1a8b2803dfd88c39f03b0969c55f667cdc43 ]

The mclk direction now needs to be specified in endpoint node with
"system-clock-direction-out" property. However some calls to the
set_sysclk callback, related to CPU DAI clock, result in unbalanced
calls to clock API.
The set_sysclk callback in STM32 SAI driver is intended only for mclk
management. So it is relevant to ensure that calls to set_sysclk are
related to mclk only.
Since the master clock is handled only at runtime, skip the calls to
set_sysclk in the initialization phase.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://patch.msgid.link/20250916123118.84175-1-olivier.moysan@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/stm/stm32_sai_sub.c

index 5828f9dd866e4d7f7eb3c9456c25b6149062209d..5938d6361e1ec4a5b4cb2ab24c3066bc715ce6e7 100644 (file)
@@ -551,6 +551,14 @@ static int stm32_sai_set_sysclk(struct snd_soc_dai *cpu_dai,
        struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
        int ret;
 
+       /*
+        * The mclk rate is determined at runtime from the audio stream rate.
+        * Skip calls to the set_sysclk callback that are not relevant during the
+        * initialization phase.
+        */
+       if (!snd_soc_card_is_instantiated(cpu_dai->component->card))
+               return 0;
+
        if (dir == SND_SOC_CLOCK_OUT && sai->sai_mclk) {
                ret = stm32_sai_sub_reg_up(sai, STM_SAI_CR1_REGX,
                                           SAI_XCR1_NODIV,