Skip to contentSkip to conversation

SOF: Fix HDMI probe errors on GLK devices

PATCH In review Kai Vehmanen 4 participants 11 messages Jan 20, 2020 – Jan 27, 2020

Subsystems (3)
lore
Share & tools
lore

Kai Vehmanen

author reviewer
#0 lore raw

v2 cover SOF: Fix HDMI probe errors on GLK devices

Hi Mark and Pierre,
here's a patch series to address an issue that popped up after SOF changed from hdac-hdmi to snd-hda-codec-hdmi:

"failed to get afg sub nodes on ChromeOS devices"
https://github.com/thesofproject/linux/issues/1642

v2 changes:
- rebased on top of broonie/for-next
- added Takashi's reviewed-by to the one HDA patch, agreed the series should go via asoc tree

This is fairly hard to hit and only occurs on some devices (most current reports are Gemini Lake based Chromebooks), but when it does, it is rather severe as the whole SOF probe fails because of this, and user is left without sound.

First fix is to optimize out one power down/up cycle from the probe process. On platforms such as GLK, each time audio driver does acomp's get_power(), graphics typically needs to do a modeset due to clocking requirements for the HDA bus. This can cause display to flash when audio is probed, plus in the reported cases on GLK, can lead to probe failures.

The above change doesn't cover all reported cases, so additionally retry logic is added to snd_hda_get_sub_nodes() calls on Intel platforms. Multiple other approaches were investigated, but a simple retry -- although less than ideal -- in the end proved to be most reliable solution. HDA dump on one affected Acer Chromebook looks like this:

# codec initialization goes as normal with multiple successful cmds
           udevd-9486  [001] ....  3910.087791: hda_send_cmd: [0000:00:0e.0:2] val=0x207f1c00
           udevd-9486  [001] ....  3910.087857: hda_get_response: [0000:00:0e.0:2] val=0x18560010
           udevd-9486  [001] ....  3910.087858: hda_send_cmd: [0000:00:0e.0:2] val=0x207f0700
           udevd-9486  [001] ....  3910.087931: hda_get_response: [0000:00:0e.0:2] val=0x00000000
           udevd-9486  [001] ....  3910.087932: hda_send_cmd: [0000:00:0e.0:2] val=0x20bf8100
           udevd-9486  [001] ....  3910.088040: hda_get_response: [0000:00:0e.0:2] val=0x00000001
           udevd-9486  [001] ....  3910.088044: hda_send_cmd: [0000:00:0e.0:2] val=0x20b78103
# here get params for AC_PAR_NODE_COUNT fails, 0xffffffff is returned
           udevd-9486  [001] ....  3910.088048: hda_send_cmd: [0000:00:0e.0:2] val=0x201f0004
           udevd-9486  [001] ....  3911.090131: hda_get_response: [0000:00:0e.0:2] val=0xffffffff
# retry is successful
           udevd-9486  [001] ....  3911.090152: hda_send_cmd: [0000:00:0e.0:2] val=0x201f0004
           udevd-9486  [001] ....  3911.090288: hda_get_response: [0000:00:0e.0:2] val=0x00020006

Kai Vehmanen (3):
ASoC: SOF: Intel: refactor i915_get/put functions
ASoC: SOF: Intel: do not disable i915 power during probe
ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

 sound/pci/hda/patch_hdmi.c      |  7 +++++--
 sound/soc/sof/intel/hda-codec.c | 21 ++++++---------------
 sound/soc/sof/intel/hda.c       |  3 ++-
 sound/soc/sof/intel/hda.h       |  7 +++----
 4 files changed, 16 insertions(+), 22 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author reviewer
#1 lore raw

PATCH v2 1/3 ASoC: SOF: Intel: refactor i915_get/put functions

The current interface to control i915 display power is misleading. The hda_codec_i915_get() and hda_codec_i915_put() names suggest a refcounting based interface. This is confusing as no refcounting is done and the underlying HDAC library interface does not support refcounts eithers.

Clarify the code by replacing the functions with a single hda_codec_i915_display_power() that is aligned with snd_hdac_display_power().

---
 sound/soc/sof/intel/hda-codec.c | 21 ++++++---------------
 sound/soc/sof/intel/hda.c       |  2 +-
 sound/soc/sof/intel/hda.h       |  7 +++----
 3 files changed, 10 insertions(+), 20 deletions(-)
sound/soc/sof/intel/hda-codec.c +6 -15
index 78dfd5f5c034..9106ab8dac6f 100644
@@ -170,23 +170,14 @@ EXPORT_SYMBOL_NS(hda_codec_probe_bus, SND_SOC_SOF_HDA_AUDIO_CODEC);
 #if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) || \
 	IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)
 
-void hda_codec_i915_get(struct snd_sof_dev *sdev)
+void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
 
-	dev_dbg(bus->dev, "Turning i915 HDAC power on\n");
-	snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true);
+	dev_dbg(bus->dev, "Turning i915 HDAC power %d\n", enable);
+	snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, enable);
 }
-EXPORT_SYMBOL_NS(hda_codec_i915_get, SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
-
-void hda_codec_i915_put(struct snd_sof_dev *sdev)
-{
-	struct hdac_bus *bus = sof_to_bus(sdev);
-
-	dev_dbg(bus->dev, "Turning i915 HDAC power off\n");
-	snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
-}
-EXPORT_SYMBOL_NS(hda_codec_i915_put, SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
+EXPORT_SYMBOL_NS(hda_codec_i915_display_power, SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
 
 int hda_codec_i915_init(struct snd_sof_dev *sdev)
 {
@@ -198,7 +189,7 @@ int hda_codec_i915_init(struct snd_sof_dev *sdev)
 	if (ret < 0)
 		return ret;
 
-	hda_codec_i915_get(sdev);
+	hda_codec_i915_display_power(sdev, true);
 
 	return 0;
 }
@@ -209,7 +200,7 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev)
 	struct hdac_bus *bus = sof_to_bus(sdev);
 	int ret;
 
-	hda_codec_i915_put(sdev);
+	hda_codec_i915_display_power(sdev, false);
 
 	ret = snd_hdac_i915_exit(bus);
 
sound/soc/sof/intel/hda.c +1 -1
index d08462f481de..54a7ba881150 100644
@@ -380,7 +380,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
 	/* create codec instances */
 	hda_codec_probe_bus(sdev, hda_codec_use_common_hdmi);
 
-	hda_codec_i915_put(sdev);
+	hda_codec_i915_display_power(sdev, false);
 
 	/*
 	 * we are done probing so decrement link counts
sound/soc/sof/intel/hda.h +3 -4
index a4d030bfeee1..6191d9192fae 100644
@@ -586,15 +586,14 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev);
 	(IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) || \
 	 IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
 
-void hda_codec_i915_get(struct snd_sof_dev *sdev);
-void hda_codec_i915_put(struct snd_sof_dev *sdev);
+void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable);
 int hda_codec_i915_init(struct snd_sof_dev *sdev);
 int hda_codec_i915_exit(struct snd_sof_dev *sdev);
 
 #else
 
-static inline void hda_codec_i915_get(struct snd_sof_dev *sdev)  { }
-static inline void hda_codec_i915_put(struct snd_sof_dev *sdev)  { }
+static inline void hda_codec_i915_display_power(struct snd_sof_dev *sdev,
+						bool enable) { }
 static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; }
 static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
 
Signature · 6 lines
2.17.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author reviewer
#2 lore raw

PATCH v2 2/3 ASoC: SOF: Intel: do not disable i915 power during probe

In reply to Kai Vehmanen

Change HDA probe behaviour slightly so that i915 power is not turned off if i915 audio codecs are found in the initial probe done by SOF Intel driver, and power is kept on until HDA codec driver probe runs.

This will reduce number of mode sets on platforms with low minimum CDCLK (like GLK) and brings the SOF probe sequence closer to legacy HDA driver in terms of i915 audio codec power management.

---
 sound/soc/sof/intel/hda.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sof/intel/hda.c +2 -1
index 54a7ba881150..65b86dd044f1 100644
@@ -380,7 +380,8 @@ static int hda_init_caps(struct snd_sof_dev *sdev)
 	/* create codec instances */
 	hda_codec_probe_bus(sdev, hda_codec_use_common_hdmi);
 
-	hda_codec_i915_display_power(sdev, false);
+	if (!HDA_IDISP_CODEC(bus->codec_mask))
+		hda_codec_i915_display_power(sdev, false);
 
 	/*
 	 * we are done probing so decrement link counts
Signature · 6 lines
2.17.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author reviewer
#3 lore raw

PATCH v2 3/3 ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

In reply to Kai Vehmanen

The initial snd_hda_get_sub_node() can fail on certain devices (e.g. some Chromebook models using Intel GLK). The failure rate is very low, but as this is is part of the probe process, end-user impact is high.

In observed cases, related hardware status registers have expected values, but the node query still fails. Retrying the node query does seem to help, so fix the problem by adding retry logic to the query. This does not impact non-Intel platforms.

---
 sound/pci/hda/patch_hdmi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/hda/patch_hdmi.c +5 -2
index 630b1f5c276d..a4b75a9dfe3b 100644
@@ -2830,9 +2830,12 @@ static int alloc_intel_hdmi(struct hda_codec *codec)
 /* parse and post-process for Intel codecs */
 static int parse_intel_hdmi(struct hda_codec *codec)
 {
-	int err;
+	int err, retries = 3;
+
+	do {
+		err = hdmi_parse_codec(codec);
+	} while (err < 0 && retries--);
 
-	err = hdmi_parse_codec(codec);
 	if (err < 0) {
 		generic_spec_free(codec);
 		return err;
Signature · 6 lines
2.17.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#4 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

Quoted 12 lines · Kai Vehmanen

The initial snd_hda_get_sub_node() can fail on certain devices (e.g. some Chromebook models using Intel GLK). The failure rate is very low, but as this is is part of the probe process, end-user impact is high.

In observed cases, related hardware status registers have expected values, but the node query still fails. Retrying the node query does seem to help, so fix the problem by adding retry logic to the query. This does not impact non-Intel platforms.

Quoted 3 lines

It seems that this felt out of Mark's hands, so I picked up now to my tree, as this doesn't seem depending on other changes.

Now applied to for-next branch.

thanks,

Takashi

Quoted 26 lines
---
 sound/pci/hda/patch_hdmi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/hda/patch_hdmi.c +5 -2
index 630b1f5c276d..a4b75a9dfe3b 100644
@@ -2830,9 +2830,12 @@ static int alloc_intel_hdmi(struct hda_codec *codec)
 /* parse and post-process for Intel codecs */
 static int parse_intel_hdmi(struct hda_codec *codec)
 {
-	int err;
+	int err, retries = 3;
+
+	do {
+		err = hdmi_parse_codec(codec);
+	} while (err < 0 && retries--);
 
-	err = hdmi_parse_codec(codec);
 	if (err < 0) {
 		generic_spec_free(codec);
 		return err;
Signature · 1 line
2.17.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#5 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

Quoted 2 lines · Takashi Iwai

It seems that this felt out of Mark's hands, so I picked up now to my tree, as this doesn't seem depending on other changes.

He only sent it on Thursday and Pierre hasn't reviewed any of this stuff yet.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author reviewer
#6 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

Hi,

Quoted 7 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

It seems that this felt out of Mark's hands, so I picked up now to my tree, as this doesn't seem depending on other changes.

He only sent it on Thursday and Pierre hasn't reviewed any of this stuff yet.

sorry for the confusion guys. I checked with Pierre and he preferred for this to be picked up by Mark directly. I noticed some rebase needed when applying on top of Mark's, so thus I resent the patches as v2.

We did have initial review at (although no approvals):
https://github.com/thesofproject/linux/pull/1713

Maybe in future, better not to combine ASoC/SOF and generic HDA patches in same series, but rather send in pieces via the proper subtrees...?

Br, Kai
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#7 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

Quoted 2 lines · Kai Vehmanen

Maybe in future, better not to combine ASoC/SOF and generic HDA patches in same series, but rather send in pieces via the proper subtrees...?

In general if there's no dependencies between patches it's best to just send them separately rather than as a series (even if they're all for the same subsystem). It stops unrelated things getting tied up in review needlessly.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#8 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

In reply to Kai Vehmanen
Quoted 16 lines · Kai Vehmanen

Hi,

Quoted 7 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

It seems that this felt out of Mark's hands, so I picked up now to my tree, as this doesn't seem depending on other changes.

He only sent it on Thursday and Pierre hasn't reviewed any of this stuff yet.

sorry for the confusion guys. I checked with Pierre and he preferred for this to be picked up by Mark directly. I noticed some rebase needed when applying on top of Mark's, so thus I resent the patches as v2.

Quoted 5 lines

We did have initial review at (although no approvals):
https://github.com/thesofproject/linux/pull/1713

Maybe in future, better not to combine ASoC/SOF and generic HDA patches in same series, but rather send in pieces via the proper subtrees...?

Sorry about the confusion, I thought Takashi took all of the 3 patches, so didn't chime in, but only this one was applied while the 2 others are still in the review queue, so for the series

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#9 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

In reply to Mark Brown
Quoted 8 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

It seems that this felt out of Mark's hands, so I picked up now to my tree, as this doesn't seem depending on other changes.

He only sent it on Thursday and Pierre hasn't reviewed any of this stuff yet.

Hm, indeed. Somehow I thought it were earlier. Unfortunately the incoming mails to my inbox have been sometimes delayed and shuffled in the last few weeks due to a problem in our server, so I missed that it's still a series.

In anyway, this fix is really independent from others and has little to do with ASoC itself, so I keep this picked through my tree.

thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#10 lore raw

Re: [alsa-devel] [PATCH v2 3/3] ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()

Quoted 2 lines · Takashi Iwai

In anyway, this fix is really independent from others and has little to do with ASoC itself, so I keep this picked through my tree.

Yeah, I don't think there's any problem with taking it separately.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel