alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>
Subject: [alsa-devel] [PATCH 7/8] ASoC: SOF: Intel: fix HDA codec driver probe with multiple controllers
Date: Fri, 10 Jan 2020 17:57:50 -0600	[thread overview]
Message-ID: <20200110235751.3404-8-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20200110235751.3404-1-pierre-louis.bossart@linux.intel.com>

From: Kai Vehmanen <kai.vehmanen@linux.intel.com>

In case system has multiple HDA controllers, it can happen that
same HDA codec driver is used for codecs of multiple controllers.
In this case, SOF may fail to probe the HDA driver and SOF
initialization fails.

SOF HDA code currently relies that a call to request_module() will
also run device matching logic to attach driver to the codec instance.
However if driver for another HDA controller was already loaded and it
already loaded the HDA codec driver, this breaks current logic in SOF.
In this case the request_module() SOF does becomes a no-op and HDA
Codec driver is not attached to the codec instance sitting on the HDA
bus SOF is controlling. Typical scenario would be a system with both
external and internal GPUs, with driver of the external GPU loaded
first.

Fix this by adding similar logic as is used in legacy HDA driver
where an explicit device_attach() call is done after request_module().

Also add logic to propagate errors reported by device_attach() back
to caller. This also works in the case where drivers are not built
as modules.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/intel/hda-codec.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c
index 5514e6191ba4..78dfd5f5c034 100644
--- a/sound/soc/sof/intel/hda-codec.c
+++ b/sound/soc/sof/intel/hda-codec.c
@@ -24,19 +24,18 @@
 #define IDISP_VID_INTEL	0x80860000
 
 /* load the legacy HDA codec driver */
-#ifdef MODULE
-static void hda_codec_load_module(struct hda_codec *codec)
+static int hda_codec_load_module(struct hda_codec *codec)
 {
+#ifdef MODULE
 	char alias[MODULE_NAME_LEN];
 	const char *module = alias;
 
 	snd_hdac_codec_modalias(&codec->core, alias, sizeof(alias));
 	dev_dbg(&codec->core.dev, "loading codec module: %s\n", module);
 	request_module(module);
-}
-#else
-static void hda_codec_load_module(struct hda_codec *codec) {}
 #endif
+	return device_attach(hda_codec_dev(codec));
+}
 
 /* enable controller wake up event for all codecs with jack connectors */
 void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev)
@@ -124,10 +123,16 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
 	if (hda_codec_use_common_hdmi ||
 	    (resp & 0xFFFF0000) != IDISP_VID_INTEL) {
 		hdev->type = HDA_DEV_LEGACY;
-		hda_codec_load_module(&hda_priv->codec);
+		ret = hda_codec_load_module(&hda_priv->codec);
+		/*
+		 * handle ret==0 (no driver bound) as an error, but pass
+		 * other return codes without modification
+		 */
+		if (ret == 0)
+			ret = -ENOENT;
 	}
 
-	return 0;
+	return ret;
 #else
 	hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL);
 	if (!hdev)
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2020-01-11  0:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 23:57 [alsa-devel] [PATCH 0/8] ASOC: SOF: Intel: improvements for Broadwell, HDA, OSS Pierre-Louis Bossart
2020-01-10 23:57 ` [alsa-devel] [PATCH 1/8] ASoC: Intel: bdw-rt5677: fix Kconfig dependencies Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: Intel: bdw-rt5677: fix Kconfig dependencies" to the asoc tree Mark Brown
2020-01-10 23:57 ` [alsa-devel] [PATCH 2/8] ASoC: Intel: bdw-rt5677: change cpu_dai and platform components for SOF Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: Intel: bdw-rt5677: change cpu_dai and platform components for SOF" to the asoc tree Mark Brown
2020-01-10 23:57 ` [alsa-devel] [PATCH 3/8] ASoC: Intel: broadwell: change cpu_dai and platform components for SOF Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: Intel: broadwell: change cpu_dai and platform components for SOF" to the asoc tree Mark Brown
2020-01-10 23:57 ` [alsa-devel] [PATCH 4/8] ASoC: Intel: bdw-rt5650: change cpu_dai and platform components for SOF Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: Intel: bdw-rt5650: change cpu_dai and platform components for SOF" to the asoc tree Mark Brown
2020-01-10 23:57 ` [alsa-devel] [PATCH 5/8] ASoC: SOF: Intel: lower print level to dbg if we will reinit DSP Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: SOF: Intel: lower print level to dbg if we will reinit DSP" to the asoc tree Mark Brown
2020-01-10 23:57 ` [alsa-devel] [PATCH 6/8] ASoC: SOF: fix PCM playback through ALSA OSS emulation Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: SOF: fix PCM playback through ALSA OSS emulation" to the asoc tree Mark Brown
2020-01-10 23:57 ` Pierre-Louis Bossart [this message]
2020-01-10 23:57 ` [alsa-devel] [PATCH 8/8] ASoC: hdac_hda: Fix error in driver removal after failed probe Pierre-Louis Bossart
2020-01-13 15:13   ` [alsa-devel] Applied "ASoC: hdac_hda: Fix error in driver removal after failed probe" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200110235751.3404-8-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).