Skip to contentSkip to conversation

ASoC: codecs: wcd938x: fix codec initialisation race

PATCH In review Johan Hovold 2 participants 2 messages Jun 30, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: codecs: wcd938x: fix codec initialisation race

Make sure to resume the codec and soundwire device before trying to read the codec variant and configure the device during component probe.

This specifically avoids interpreting (a masked and shifted) -EBUSY errno as the variant:

	wcd938x_codec audio-codec: ASoC: error at soc_component_read_no_lock on audio-codec for register: [0x000034b0] -16

when the soundwire device happens to be suspended, which in turn prevents some headphone controls from being registered.

Fixes 8d78602aa87a ("ASoC: codecs: wcd938x: add basic driver")
Cc Srinivas Kandagatla <[email protected]>
---
 sound/soc/codecs/wcd938x.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/codecs/wcd938x.c +6 -0
index e7d6a02cdec0..e3ae4fb2c4db 100644
@@ -3085,6 +3085,10 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
 
 	snd_soc_component_init_regmap(component, wcd938x->regmap);
 
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0)
+		return ret;
+
 	wcd938x->variant = snd_soc_component_read_field(component,
 						 WCD938X_DIGITAL_EFUSE_REG_0,
 						 WCD938X_ID_MASK);
@@ -3098,6 +3102,8 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component)
 			     (WCD938X_DIGITAL_INTR_LEVEL_0 + i), 0);
 	}
 
+	pm_runtime_put(dev);
+
 	wcd938x->hphr_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip,
 						       WCD938X_IRQ_HPHR_PDM_WD_INT);
 	wcd938x->hphl_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip,
Signature · 1 line
2.39.3
maintainer
#1 lore raw
Quoted 9 lines · Johan Hovold

Make sure to resume the codec and soundwire device before trying to read the codec variant and configure the device during component probe.

This specifically avoids interpreting (a masked and shifted) -EBUSY errno as the variant:

	wcd938x_codec audio-codec: ASoC: error at soc_component_read_no_lock on audio-codec for register: [0x000034b0] -16

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: codecs: wcd938x: fix codec initialisation race

      commit: 85a61b1ce461a3f62f1019e5e6423c393c542bff

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