All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM
@ 2020-09-30 11:41 Kai Vehmanen
  2020-09-30 11:41 ` [PATCH v2 1/2] " Kai Vehmanen
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Kai Vehmanen @ 2020-09-30 11:41 UTC (permalink / raw)
  To: alsa-devel, tiwai, broonie
  Cc: cezary.rojewski, kailang, kai.vehmanen, harshapriya.n,
	pierre-louis.bossart, ranjani.sridharan, emmanuel.jillela

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(+)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] ALSA: HDA: Early Forbid of runtime PM
  2020-09-30 11:41 [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
@ 2020-09-30 11:41 ` Kai Vehmanen
  2020-09-30 11:41 ` [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe Kai Vehmanen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Kai Vehmanen @ 2020-09-30 11:41 UTC (permalink / raw)
  To: alsa-devel, tiwai, broonie
  Cc: cezary.rojewski, kailang, kai.vehmanen, harshapriya.n,
	pierre-louis.bossart, ranjani.sridharan, emmanuel.jillela

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:
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe
  2020-09-30 11:41 [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
  2020-09-30 11:41 ` [PATCH v2 1/2] " Kai Vehmanen
@ 2020-09-30 11:41 ` Kai Vehmanen
  2020-09-30 14:20   ` Mark Brown
  2020-09-30 12:05 ` [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
  2020-09-30 15:06 ` Takashi Iwai
  3 siblings, 1 reply; 7+ messages in thread
From: Kai Vehmanen @ 2020-09-30 11:41 UTC (permalink / raw)
  To: alsa-devel, tiwai, broonie
  Cc: cezary.rojewski, kailang, kai.vehmanen, harshapriya.n,
	pierre-louis.bossart, ranjani.sridharan, emmanuel.jillela

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.
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM
  2020-09-30 11:41 [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
  2020-09-30 11:41 ` [PATCH v2 1/2] " Kai Vehmanen
  2020-09-30 11:41 ` [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe Kai Vehmanen
@ 2020-09-30 12:05 ` Kai Vehmanen
  2020-09-30 14:14   ` Takashi Iwai
  2020-09-30 15:06 ` Takashi Iwai
  3 siblings, 1 reply; 7+ messages in thread
From: Kai Vehmanen @ 2020-09-30 12:05 UTC (permalink / raw)
  To: Kai Vehmanen
  Cc: alsa-devel, kailang, Takashi Iwai, cezary.rojewski,
	pierre-louis.bossart, harshapriya.n, broonie, ranjani.sridharan,
	emmanuel.jillela

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.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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM
  2020-09-30 12:05 ` [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
@ 2020-09-30 14:14   ` Takashi Iwai
  0 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2020-09-30 14:14 UTC (permalink / raw)
  To: Kai Vehmanen
  Cc: alsa-devel, kailang, harshapriya.n, cezary.rojewski,
	pierre-louis.bossart, emmanuel.jillela, broonie,
	ranjani.sridharan

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.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.

I'm fine to take into my tree if Mark can give an Ack.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe
  2020-09-30 11:41 ` [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe Kai Vehmanen
@ 2020-09-30 14:20   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2020-09-30 14:20 UTC (permalink / raw)
  To: Kai Vehmanen
  Cc: cezary.rojewski, kailang, tiwai, alsa-devel,
	pierre-louis.bossart, harshapriya.n, ranjani.sridharan,
	emmanuel.jillela

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

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>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM
  2020-09-30 11:41 [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
                   ` (2 preceding siblings ...)
  2020-09-30 12:05 ` [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
@ 2020-09-30 15:06 ` Takashi Iwai
  3 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2020-09-30 15:06 UTC (permalink / raw)
  To: Kai Vehmanen
  Cc: cezary.rojewski, kailang, harshapriya.n, alsa-devel,
	pierre-louis.bossart, emmanuel.jillela, broonie,
	ranjani.sridharan

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-30 15:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 11:41 [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
2020-09-30 11:41 ` [PATCH v2 1/2] " Kai Vehmanen
2020-09-30 11:41 ` [PATCH v2 2/2] ASoC: hdac_hda: allow runtime pm at end of probe Kai Vehmanen
2020-09-30 14:20   ` Mark Brown
2020-09-30 12:05 ` [PATCH v2 0/2] ALSA: HDA: Early Forbid of runtime PM Kai Vehmanen
2020-09-30 14:14   ` Takashi Iwai
2020-09-30 15:06 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.