[PATCH v2 0/2] 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(+)
From: Harsha Priya harshapriya.n@intel.com
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.
Signed-off-by: Harsha Priya harshapriya.n@intel.com Signed-off-by: Emmanuel Jillela emmanuel.jillela@intel.com Reviewed-by: Kailang Yang kailang@realtek.com Signed-off-by: Kai Vehmanen kai.vehmanen@linux.intel.com --- sound/pci/hda/hda_codec.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e96a87f1b611..a356c21edb90 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -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:
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 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.
Signed-off-by: Kai Vehmanen kai.vehmanen@linux.intel.com --- sound/soc/codecs/hdac_hda.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index 49e6f23fc766..390dd6c7f6a5 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -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.
On Wed, Sep 30, 2020 at 02:41:40PM +0300, Kai Vehmanen wrote:
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 of hdac_hda_codec_probe().
Acked-by: Mark Brown broonie@kernel.org
Hi,
On Wed, 30 Sep 2020, Kai Vehmanen wrote:
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.
this is a follow-up to: https://mailman.alsa-project.org/pipermail/alsa-devel/2020-August/173141.htm...
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
On Wed, 30 Sep 2020 14:05:01 +0200, Kai Vehmanen wrote:
Hi,
On Wed, 30 Sep 2020, Kai Vehmanen wrote:
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.
this is a follow-up to: https://mailman.alsa-project.org/pipermail/alsa-devel/2020-August/173141.htm...
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.
I'm fine to take into my tree if Mark can give an Ack.
thanks,
Takashi
On Wed, 30 Sep 2020 13:41:38 +0200, Kai Vehmanen wrote:
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
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
participants (3)
-
Kai Vehmanen
-
Mark Brown
-
Takashi Iwai