ALSA: HDA: Early Forbid of runtime PM
v2 cover ALSA: HDA: Early Forbid of runtime PM
Fix a race with runtime PM enabled during codec initialization.
For snd-hda-intel, no changes are needed in controller code, but to not break ASoC controller drivers, this V2 series adds an additional change in ASoC hdac_hda to allow runtime pm again at end of probe.
Harsha Priya (1):
ALSA: HDA: Early Forbid of runtime PM
Kai Vehmanen (1):
ASoC: hdac_hda: allow runtime pm at end of probe
sound/pci/hda/hda_codec.c | 3 +++ sound/soc/codecs/hdac_hda.c | 3 +++ 2 files changed, 6 insertions(+)
Signature · 1 line
2.27.0
PATCH v2 1/2 ALSA: HDA: Early Forbid of runtime PM
From: Harsha Priya <[email protected]>
For certain codecs (like Realtek), pm_runtime_forbid() is invoked in the probe function after build_controls(). In a stress test, its observed occasionally that runtime PM calls are invoked before controls are built. This causes the codec to be runtime suspended before probe completes. Because of this, not all controls are enumerated correctly, and audio does not work until system is rebooted.
This issue being common across all codecs, pm_runtime_forbid() is called when the codec object is created to fix this issue. A codec enables or disables runtime pm in its own probe function.
Multiple stress tests of 2000+ cycles has been done to test the fix.
--- sound/pci/hda/hda_codec.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/hda_codec.c +3 -0
@@ -1000,6 +1000,9 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,if (err <0 ) goto error; +/* PM runtime needs to be enabled later after binding codec */ +pm_runtime_forbid (&codec->core.dev); +return 0 ; error:
Signature · 1 line
2.27.0
PATCH v2 2/2 ASoC: hdac_hda: allow runtime pm at end of probe
In reply to Kai VehmanenAlign with recent change to forbid runtime suspend during codec init in snd_hda_codec_device_new(), with matching call to allow suspend at end of hdac_hda_codec_probe().
In snd-hda-intel, call to snd_hda_set_power_save() at end of controller probe does the same thing, but ASoC controller drivers do not modify runtime settings for codecs, so this has to be done in codec drivers, and in this case in hdac_hda.
--- sound/soc/codecs/hdac_hda.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/hdac_hda.c +3 -0
@@ -481,6 +481,9 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)snd_hdac_display_power (hdev->bus,HDA_CODEC_IDX_CONTROLLER , false); +/* match for forbid call in snd_hda_codec_device_new() */ +pm_runtime_allow (&hdev->dev); +/* * hdac_device core already sets the state to active and calls * get_noresume. So enable runtime and set the device to suspend.
Signature · 1 line
2.27.0
Re: [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe
Quoted 3 lines · Kai Vehmanen
Align with recent change to forbid runtime suspend during codec init in
snd_hda_codec_device_new(), with matching call to allow suspend at end ofhdac_hda_codec_probe().
Hi,
Quoted 6 lines · Kai Vehmanen
Fix a race with runtime PM enabled during codec initialization.
For snd-hda-intel, no changes are needed in controller code, but to not break ASoC controller drivers, this V2 series adds an additional change in ASoC
hdac_hdato allow runtime pm again at end of probe.
this is a follow-up to:
https://mailman.alsa-project.org/pipermail/alsa-devel/2020-August/173141.html
It turns out we need to make changes both in ASoC and sound/hda at the same time, to not break anything. So again a case where either Takashi or Mark, you should take both at the same time, if code itself is ok to all.
PS And sorry, versioning is confusing, should have sent this as V3.
V1 modified only realtek codec, V2 modified hda_codec.c part and this V3 adds a patch to ASoC hdac_hdmi.c.
Br, Kai
Quoted 12 lines · Kai Vehmanen
Hi,
Quoted 6 lines · Kai Vehmanen
Fix a race with runtime PM enabled during codec initialization.
For snd-hda-intel, no changes are needed in controller code, but to not break ASoC controller drivers, this V2 series adds an additional change in ASoC
hdac_hdato allow runtime pm again at end of probe.
Quoted 6 lines
this is a follow-up to:
https://mailman.alsa-project.org/pipermail/alsa-devel/2020-August/173141.htmlIt turns out we need to make changes both in ASoC and
sound/hdaat the same time, to not break anything. So again a case where either Takashi or Mark, you should take both at the same time, if code itself is ok to all.
I'm fine to take into my tree if Mark can give an Ack.
thanks,
Takashi
Takashi Iwai
AppliedQuoted 8 lines · Kai Vehmanen
Fix a race with runtime PM enabled during codec initialization.
For snd-hda-intel, no changes are needed in controller code, but to not break ASoC controller drivers, this V2 series adds an additional change in ASoC
hdac_hdato allow runtime pm again at end of probe.
Quoted 5 lines
Harsha Priya (1):
ALSA: HDA: Early Forbid of runtime PMKai Vehmanen (1):
ASoC:hdac_hda: allow runtime pm at end of probe
Applied both patches now to for-linus branch.
I'm not sure whether I'm going to send a pull request for 5.9-final, but certainly those will be included in 5.10-rc1.
thanks,
Takashi