* [PATCH] ASoC: codecs: wcd934x: drop the MCLK on every disable
@ 2026-11-09 22:33 Ivan Verbovoy via B4 Relay
2026-11-19 14:07 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Ivan Verbovoy via B4 Relay @ 2026-11-09 22:33 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Pierre-Louis Bossart
Cc: linux-sound, linux-arm-msm, linux-kernel, Ivan Verbovoy
From: Ivan Verbovoy <ivanverbovoy@gmail.com>
__wcd934x_cdc_mclk_enable() takes a reference on every enable: it
prepares and enables the external clock and counts a user of the
analog bias and system clock (sysclk_users). On disable it returns
early while the SoundWire controller's clock is enabled, so neither is
dropped. Each DAPM MCLK power-down or MBHC micbias release during
SoundWire activity therefore leaks one reference, and the MCLK stays on
for good.
The early return is not needed: wcd934x_swrm_clock() takes its own
reference before it enables the SoundWire clock and clears that clock
before it drops the reference, and sysclk_users keeps the bias and the
system clock on while any user remains. Drop the check.
On a Surface Duo (SM8150, WCD9340) the codec's external clock,
ln_bb_clk2 (an RPMh XO buffer vote), was found prepared five times at
suspend, which kept the SoC's XO on. With the check dropped, its enable
and prepare counts are back to zero once playback stops.
Fixes: a61f3b4f476e ("ASoC: wcd934x: add support to wcd9340/wcd9341 codec")
Signed-off-by: Ivan Verbovoy <ivanverbovoy@gmail.com>
---
sound/soc/codecs/wcd934x.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 5cd30a5ed69c..043061558225 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -1355,15 +1355,6 @@ static int __wcd934x_cdc_mclk_enable(struct wcd934x_codec *wcd, bool enable)
}
ret = wcd934x_enable_ana_bias_and_sysclk(wcd);
} else {
- int val;
-
- regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL,
- &val);
-
- /* Don't disable clock if soundwire using it.*/
- if (val & WCD934X_CDC_SWR_CLK_EN_MASK)
- return 0;
-
wcd934x_disable_ana_bias_and_syclk(wcd);
clk_disable_unprepare(wcd->extclk);
}
---
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
change-id: 20261109-wcd934x-mclk-2121fa04731a
Best regards,
--
Ivan Verbovoy <ivanverbovoy@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: codecs: wcd934x: drop the MCLK on every disable
2026-11-09 22:33 [PATCH] ASoC: codecs: wcd934x: drop the MCLK on every disable Ivan Verbovoy via B4 Relay
@ 2026-11-19 14:07 ` Mark Brown
2026-11-19 14:51 ` Ivan Verbovoy
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-11-19 14:07 UTC (permalink / raw)
To: Ivan Verbovoy
Cc: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Pierre-Louis Bossart, linux-sound, linux-arm-msm,
linux-kernel
> __wcd934x_cdc_mclk_enable() takes a reference on every enable: it
> prepares and enables the external clock and counts a user of the
> analog bias and system clock (sysclk_users). On disable it returns
> early while the SoundWire controller's clock is enabled, so neither is
> dropped. Each DAPM MCLK power-down or MBHC micbias release during
> SoundWire activity therefore leaks one reference, and the MCLK stays on
> for good.
> The early return is not needed: wcd934x_swrm_clock() takes its own
> reference before it enables the SoundWire clock and clears that clock
> before it drops the reference, and sysclk_users keeps the bias and the
> system clock on while any user remains. Drop the check.
Are you absolutely sure there are no other paths that could do this, for
example take a look at wcd_mbhc_adc_detect_plug_type() and the rest of
the jack detection code?
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: codecs: wcd934x: drop the MCLK on every disable
2026-11-19 14:07 ` Mark Brown
@ 2026-11-19 14:51 ` Ivan Verbovoy
0 siblings, 0 replies; 3+ messages in thread
From: Ivan Verbovoy @ 2026-11-19 14:51 UTC (permalink / raw)
To: Mark Brown
Cc: Srinivas Kandagatla, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, Pierre-Louis Bossart, linux-sound, linux-arm-msm,
linux-kernel
On Thu, Nov 19, 2026 at 02:07:26PM +0000, Mark Brown wrote:
> Are you absolutely sure there are no other paths that could do this, for
> example take a look at wcd_mbhc_adc_detect_plug_type() and the rest of
> the jack detection code?
No, and you are right to point there: the jack detection does not
balance its calls.
wcd_mbhc_adc_detect_plug_type() requests the micbias once per insertion,
and wcd934x_mbhc_request_micbias() takes an MCLK reference with it. The
releases are more: wcd_correct_swch_plug() releases at its exit, once
more for a headphone or when the work is stopped, and
wcd_mbhc_report_plug_removal() releases again on every removal. micb_ref
is clamped at zero, but the MCLK reference next to it is dropped every
time.
So with this patch alone, a removal while SoundWire is running would
drop a reference the jack detection does not hold. The early return is
what hides that today.
I will send a v2 that first makes the jack detection drop only the
references it took, and then removes the check. The board I test on has
no jack, so that part will be build-tested only; I will say so there.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-19 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 22:33 [PATCH] ASoC: codecs: wcd934x: drop the MCLK on every disable Ivan Verbovoy via B4 Relay
2026-11-19 14:07 ` Mark Brown
2026-11-19 14:51 ` Ivan Verbovoy
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®