diff mbox series

[SRU,E/F/unstable,RESEND,1/1] UBUNTU: SAUCE: ASoC: intel/skl/hda - fix oops on systems without i915 audio codec

Message ID 20200430131753.7381-2-hui.wang@canonical.com
State New
Headers show
Series alsa/sof: kernel oops on the machine without Intel hdmi audio codec (a regression in the asoc machine driver) | expand

Commit Message

Hui Wang April 30, 2020, 1:17 p.m. UTC
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>

BugLink: https://bugs.launchpad.net/bugs/1874359

Recent fix for jack detection caused a regression on systems with HDA
audio codec but no HDMI/DP audio via i915 graphics, leading to a kernel
oops at device probe. On these systems, HDA bus instance lookup fails,
as the first ASoC runtime of the card is connected to a dummy codec
(as no HDMI codec is present).

Fixes: 3a24f135e6cc ("ASoC: intel/skl/hda - set autosuspend timeout for hda codecs")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200420205431.13070-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
(backported from commit 5bf73b1b1deca46c7459cb4d732ba8bad6da93c5
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 34 +++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)

Comments

Kleber Sacilotto de Souza May 12, 2020, 4:22 p.m. UTC | #1
On 30.04.20 15:17, Hui Wang wrote:
> From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1874359
> 
> Recent fix for jack detection caused a regression on systems with HDA
> audio codec but no HDMI/DP audio via i915 graphics, leading to a kernel
> oops at device probe. On these systems, HDA bus instance lookup fails,
> as the first ASoC runtime of the card is connected to a dummy codec
> (as no HDMI codec is present).
> 
> Fixes: 3a24f135e6cc ("ASoC: intel/skl/hda - set autosuspend timeout for hda codecs")
> Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
> Link: https://lore.kernel.org/r/20200420205431.13070-1-kai.vehmanen@linux.intel.com
> Signed-off-by: Mark Brown <broonie@kernel.org>
> (backported from commit 5bf73b1b1deca46c7459cb4d732ba8bad6da93c5
> git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git)
> Signed-off-by: Hui Wang <hui.wang@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>  sound/soc/intel/boards/skl_hda_dsp_generic.c | 34 +++++++++++---------
>  1 file changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
> index ab2bec029768..122f4017babf 100644
> --- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
> +++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
> @@ -151,23 +151,25 @@ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
>  
>  static void skl_set_hda_codec_autosuspend_delay(struct snd_soc_card *card)
>  {
> -	struct snd_soc_pcm_runtime *rtd =
> -		list_first_entry(&card->rtd_list,
> -				 struct snd_soc_pcm_runtime, list);
> -	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_pcm_runtime *rtd;
>  	struct hdac_hda_priv *hda_pvt;
> -
> -	if (!codec_dai)
> -		return;
> -
> -	/*
> -	 * all codecs are on the same bus, so it's sufficient
> -	 * to lookup the first runtime and its codec, and set
> -	 * power save defaults for all codecs on the bus
> -	 */
> -	hda_pvt = snd_soc_component_get_drvdata(codec_dai->component);
> -	snd_hda_set_power_save(hda_pvt->codec.bus,
> -			       HDA_CODEC_AUTOSUSPEND_DELAY_MS);
> +	struct snd_soc_dai *dai;
> +
> +	for_each_card_rtds(card, rtd) {
> +		if (!strstr(rtd->dai_link->codecs->name, "ehdaudio"))
> +			continue;
> +		dai = rtd->codec_dai;
> +		hda_pvt = snd_soc_component_get_drvdata(dai->component);
> +		if (hda_pvt) {
> +			/*
> +			 * all codecs are on the same bus, so it's sufficient
> +			 * to look up only the first one
> +			 */
> +			snd_hda_set_power_save(hda_pvt->codec.bus,
> +					       HDA_CODEC_AUTOSUSPEND_DELAY_MS);
> +			break;
> +		}
> +	}
>  }
>  
>  static int skl_hda_audio_probe(struct platform_device *pdev)
>
diff mbox series

Patch

diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
index ab2bec029768..122f4017babf 100644
--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
+++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
@@ -151,23 +151,25 @@  static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
 
 static void skl_set_hda_codec_autosuspend_delay(struct snd_soc_card *card)
 {
-	struct snd_soc_pcm_runtime *rtd =
-		list_first_entry(&card->rtd_list,
-				 struct snd_soc_pcm_runtime, list);
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_pcm_runtime *rtd;
 	struct hdac_hda_priv *hda_pvt;
-
-	if (!codec_dai)
-		return;
-
-	/*
-	 * all codecs are on the same bus, so it's sufficient
-	 * to lookup the first runtime and its codec, and set
-	 * power save defaults for all codecs on the bus
-	 */
-	hda_pvt = snd_soc_component_get_drvdata(codec_dai->component);
-	snd_hda_set_power_save(hda_pvt->codec.bus,
-			       HDA_CODEC_AUTOSUSPEND_DELAY_MS);
+	struct snd_soc_dai *dai;
+
+	for_each_card_rtds(card, rtd) {
+		if (!strstr(rtd->dai_link->codecs->name, "ehdaudio"))
+			continue;
+		dai = rtd->codec_dai;
+		hda_pvt = snd_soc_component_get_drvdata(dai->component);
+		if (hda_pvt) {
+			/*
+			 * all codecs are on the same bus, so it's sufficient
+			 * to look up only the first one
+			 */
+			snd_hda_set_power_save(hda_pvt->codec.bus,
+					       HDA_CODEC_AUTOSUSPEND_DELAY_MS);
+			break;
+		}
+	}
 }
 
 static int skl_hda_audio_probe(struct platform_device *pdev)