Skip to content

Commit 3009796

Browse files
Srinivas-Kandagatlabroonie
authored andcommitted
ASoC: codecs: va-macro: use fsgen as clock
VA Macro fsgen clock is supplied to other LPASS Macros using proper clock apis, however the internal user uses the registers directly without clk apis. This approch has race condition where in external users of the clock might cut the clock while VA macro is actively using this. Moving the internal usage to clk apis would provide a proper refcounting and avoid such race conditions. This issue was noticed while headset was pulled out while recording is in progress and shifting record patch to DMIC. Reported-by: Srinivasa Rao Mandadapu <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Tested-by: Srinivasa Rao Mandadapu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent bd1963d commit 3009796

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sound/soc/codecs/lpass-va-macro.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ struct va_macro {
199199
struct clk *mclk;
200200
struct clk *macro;
201201
struct clk *dcodec;
202+
struct clk *fsgen;
202203
struct clk_hw hw;
203204
struct lpass_macro *pds;
204205

@@ -467,9 +468,9 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
467468

468469
switch (event) {
469470
case SND_SOC_DAPM_PRE_PMU:
470-
return va_macro_mclk_enable(va, true);
471+
return clk_prepare_enable(va->fsgen);
471472
case SND_SOC_DAPM_POST_PMD:
472-
return va_macro_mclk_enable(va, false);
473+
clk_disable_unprepare(va->fsgen);
473474
}
474475

475476
return 0;
@@ -1473,6 +1474,12 @@ static int va_macro_probe(struct platform_device *pdev)
14731474
if (ret)
14741475
goto err_clkout;
14751476

1477+
va->fsgen = clk_hw_get_clk(&va->hw, "fsgen");
1478+
if (IS_ERR(va->fsgen)) {
1479+
ret = PTR_ERR(va->fsgen);
1480+
goto err_clkout;
1481+
}
1482+
14761483
ret = devm_snd_soc_register_component(dev, &va_macro_component_drv,
14771484
va_macro_dais,
14781485
ARRAY_SIZE(va_macro_dais));

0 commit comments

Comments
 (0)