Skip to contentSkip to conversation

ASoC: Intel: Skylake: Move i915 registration to worker thread

PATCH Superseded Subhransu S. Prusty 3 participants 6 messages May 3, 2017 – May 15, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: Intel: Skylake: Move i915 registration to worker thread

From: Vinod Koul <[email protected]>

The i915 component framework expects the caller to be invoking snd_hdac_i915_init() from a thread context. Otherwise it results in lockups on drm side.

So move the registering of component interface and probing of codecs on this bus to a worker thread.

init_failed in skl structure is not used currently, so renamed to init_done and used to track the initialization done in worker thread.

---
 sound/soc/intel/skylake/skl.c | 162 +++++++++++++++++++++++-------------------
 sound/soc/intel/skylake/skl.h |   4 +-
 2 files changed, 91 insertions(+), 75 deletions(-)
sound/soc/intel/skylake/skl.c +88 -74
index 6df3b317a476..4c9b5781282b 100644
@@ -410,7 +410,7 @@ static int skl_free(struct hdac_ext_bus *ebus)
 	struct skl *skl  = ebus_to_skl(ebus);
 	struct hdac_bus *bus = ebus_to_hbus(ebus);
 
-	skl->init_failed = 1; /* to be sure */
+	skl->init_done = 0; /* to be sure */
 
 	snd_hdac_ext_stop_streams(ebus);
 
@@ -428,8 +428,10 @@ static int skl_free(struct hdac_ext_bus *ebus)
 
 	snd_hdac_ext_bus_exit(ebus);
 
+	cancel_work_sync(&skl->probe_work);
 	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
 		snd_hdac_i915_exit(&ebus->bus);
+
 	return 0;
 }
 
@@ -566,6 +568,84 @@ static int skl_codec_create(struct hdac_ext_bus *ebus)
 	.get_response = snd_hdac_bus_get_response,
 };
 
+static int skl_i915_init(struct hdac_bus *bus)
+{
+	int err;
+
+	/*
+	 * The HDMI codec is in GPU so we need to ensure that it is powered
+	 * up and ready for probe
+	 */
+	err = snd_hdac_i915_init(bus);
+	if (err < 0)
+		return err;
+
+	err = snd_hdac_display_power(bus, true);
+	if (err < 0)
+		dev_err(bus->dev, "Cannot turn on display power on i915\n");
+
+	return err;
+}
+
+static void skl_probe_work(struct work_struct *work)
+{
+	struct skl *skl = container_of(work, struct skl, probe_work);
+	struct hdac_ext_bus *ebus = &skl->ebus;
+	struct hdac_bus *bus = ebus_to_hbus(ebus);
+	struct hdac_ext_link *hlink = NULL;
+	int err;
+
+	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
+		err = skl_i915_init(bus);
+		if (err < 0)
+			return;
+	}
+
+	err = skl_init_chip(bus, true);
+	if (err < 0) {
+		dev_err(bus->dev, "Init chip failed with err: %d\n", err);
+		goto out_err;
+	}
+
+	/* codec detection */
+	if (!bus->codec_mask)
+		dev_info(bus->dev, "no hda codecs found!\n");
+
+	/* create codec instances */
+	err = skl_codec_create(ebus);
+	if (err < 0)
+		goto out_err;
+
+	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
+		err = snd_hdac_display_power(bus, false);
+		if (err < 0) {
+			dev_err(bus->dev, "Cannot turn off display power on i915\n");
+			return;
+		}
+	}
+
+	/* register platform dai and controls */
+	err = skl_platform_register(bus->dev);
+	if (err < 0)
+		return;
+	/*
+	 * we are done probing so decrement link counts
+	 */
+	list_for_each_entry(hlink, &ebus->hlink_list, list)
+		snd_hdac_ext_bus_link_put(ebus, hlink);
+
+	/* configure PM */
+	pm_runtime_put_noidle(bus->dev);
+	pm_runtime_allow(bus->dev);
+	skl->init_done = 1;
+
+	return;
+
+out_err:
+	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
+		err = snd_hdac_display_power(bus, false);
+}
+
 /*
  * constructor
  */
@@ -593,6 +673,7 @@ static int skl_create(struct pci_dev *pci,
 	snd_hdac_ext_bus_init(ebus, &pci->dev, &bus_core_ops, io_ops);
 	ebus->bus.use_posbuf = 1;
 	skl->pci = pci;
+	INIT_WORK(&skl->probe_work, skl_probe_work);
 
 	ebus->bus.bdl_pos_adj = 0;
 
@@ -601,27 +682,6 @@ static int skl_create(struct pci_dev *pci,
 	return 0;
 }
 
-static int skl_i915_init(struct hdac_bus *bus)
-{
-	int err;
-
-	/*
-	 * The HDMI codec is in GPU so we need to ensure that it is powered
-	 * up and ready for probe
-	 */
-	err = snd_hdac_i915_init(bus);
-	if (err < 0)
-		return err;
-
-	err = snd_hdac_display_power(bus, true);
-	if (err < 0) {
-		dev_err(bus->dev, "Cannot turn on display power on i915\n");
-		return err;
-	}
-
-	return err;
-}
-
 static int skl_first_init(struct hdac_ext_bus *ebus)
 {
 	struct skl *skl = ebus_to_skl(ebus);
@@ -684,20 +744,7 @@ static int skl_first_init(struct hdac_ext_bus *ebus)
 	/* initialize chip */
 	skl_init_pci(skl);
 
-	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-		err = skl_i915_init(bus);
-		if (err < 0)
-			return err;
-	}
-
-	skl_init_chip(bus, true);
-
-	/* codec detection */
-	if (!bus->codec_mask) {
-		dev_info(bus->dev, "no hda codecs found!\n");
-	}
-
-	return 0;
+	return skl_init_chip(bus, true);
 }
 
 static int skl_probe(struct pci_dev *pci,
@@ -706,7 +753,6 @@ static int skl_probe(struct pci_dev *pci,
 	struct skl *skl;
 	struct hdac_ext_bus *ebus = NULL;
 	struct hdac_bus *bus = NULL;
-	struct hdac_ext_link *hlink = NULL;
 	int err;
 
 	/* we use ext core ops, so provide NULL for ops here */
@@ -729,7 +775,7 @@ static int skl_probe(struct pci_dev *pci,
 
 	if (skl->nhlt == NULL) {
 		err = -ENODEV;
-		goto out_display_power_off;
+		goto out_free;
 	}
 
 	err = skl_nhlt_create_sysfs(skl);
@@ -760,56 +806,24 @@ static int skl_probe(struct pci_dev *pci,
 	if (bus->mlcap)
 		snd_hdac_ext_bus_get_ml_capabilities(ebus);
 
+	snd_hdac_bus_stop_chip(bus);
+
 	/* create device for soc dmic */
 	err = skl_dmic_device_register(skl);
 	if (err < 0)
 		goto out_dsp_free;
 
-	/* register platform dai and controls */
-	err = skl_platform_register(bus->dev);
-	if (err < 0)
-		goto out_dmic_free;
-
-	/* create codec instances */
-	err = skl_codec_create(ebus);
-	if (err < 0)
-		goto out_unregister;
-
-	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-		err = snd_hdac_display_power(bus, false);
-		if (err < 0) {
-			dev_err(bus->dev, "Cannot turn off display power on i915\n");
-			return err;
-		}
-	}
-
-	/*
-	 * we are done probling so decrement link counts
-	 */
-	list_for_each_entry(hlink, &ebus->hlink_list, list)
-		snd_hdac_ext_bus_link_put(ebus, hlink);
-
-	/* configure PM */
-	pm_runtime_put_noidle(bus->dev);
-	pm_runtime_allow(bus->dev);
+	schedule_work(&skl->probe_work);
 
 	return 0;
 
-out_unregister:
-	skl_platform_unregister(bus->dev);
-out_dmic_free:
-	skl_dmic_device_unregister(skl);
 out_dsp_free:
 	skl_free_dsp(skl);
 out_mach_free:
 	skl_machine_device_unregister(skl);
 out_nhlt_free:
 	skl_nhlt_free(skl->nhlt);
-out_display_power_off:
-	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
-		snd_hdac_display_power(bus, false);
 out_free:
-	skl->init_failed = 1;
 	skl_free(ebus);
 
 	return err;
@@ -828,7 +842,7 @@ static void skl_shutdown(struct pci_dev *pci)
 
 	skl = ebus_to_skl(ebus);
 
-	if (skl->init_failed)
+	if (!skl->init_done)
 		return;
 
 	snd_hdac_ext_stop_streams(ebus);
sound/soc/intel/skylake/skl.h +3 -1
index 5b3fa4b91691..c1968a06174a 100644
@@ -67,7 +67,7 @@ struct skl {
 	struct hdac_ext_bus ebus;
 	struct pci_dev *pci;
 
-	unsigned int init_failed:1; /* delayed init failed */
+	unsigned int init_done:1; /* delayed init status */
 	struct platform_device *dmic_dev;
 	struct platform_device *i2s_dev;
 	struct snd_soc_platform *platform;
@@ -85,6 +85,8 @@ struct skl {
 	const struct firmware *tplg;
 
 	int supend_active;
+
+	struct work_struct probe_work;
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 ASoC: Intel: Skylake: Fix typo for token d0i3 caps

---
 include/uapi/sound/snd_sst_tokens.h    | 4 ++--
 sound/soc/intel/skylake/skl-topology.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/snd_sst_tokens.h +2 -2
index 93392bedcc58..685149dda66b 100644
@@ -213,8 +213,8 @@ enum SKL_TKNS {
 	SKL_TKN_U32_LIB_COUNT,
 	SKL_TKN_STR_LIB_NAME,
 	SKL_TKN_U32_PMODE,
-	SKL_TKL_U32_D0I3_CAPS,
-	SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
+	SKL_TKN_U32_D0I3_CAPS,
+	SKL_TKN_MAX = SKL_TKN_U32_D0I3_CAPS,
 };
 
 #endif
sound/soc/intel/skylake/skl-topology.c +1 -1
index 3a99712e44a8..b28199a5348c 100644
@@ -1995,7 +1995,7 @@ static int skl_tplg_get_token(struct device *dev,
 		mconfig->converter = tkn_elem->value;
 		break;
 
-	case SKL_TKL_U32_D0I3_CAPS:
+	case SKL_TKN_U32_D0I3_CAPS:
 		mconfig->d0i3_caps = tkn_elem->value;
 		break;
 
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 2/2] ASoC: Intel: Skylake: Fix typo for token d0i3 caps

Hi,

Quoted 26 lines · Subhransu S. Prusty
---
 include/uapi/sound/snd_sst_tokens.h    | 4 ++--
 sound/soc/intel/skylake/skl-topology.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/snd_sst_tokens.h +2 -2
index 93392bedcc58..685149dda66b 100644
@@ -213,8 +213,8 @@ enum SKL_TKNS {
 	SKL_TKN_U32_LIB_COUNT,
 	SKL_TKN_STR_LIB_NAME,
 	SKL_TKN_U32_PMODE,
-	SKL_TKL_U32_D0I3_CAPS,
-	SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
+	SKL_TKN_U32_D0I3_CAPS,
+	SKL_TKN_MAX = SKL_TKN_U32_D0I3_CAPS,
 };
 
 #endif
sound/soc/intel/skylake/skl-topology.c +0 -0
index 3a99712e44a8..b28199a5348c 100644

sound/soc/intel/skylake/skl-topology.c static int skl_tplg_get_token(struct device *dev, · line 2000

Quoted 7 lines
sound/soc/intel/skylake/skl-topology.c +1 -1
@@ -1995,7 +1995,7 @@ static int skl_tplg_get_token(struct device *dev,
 		mconfig->converter = tkn_elem->value;
 		break;
 
-	case SKL_TKL_U32_D0I3_CAPS:
+	case SKL_TKN_U32_D0I3_CAPS:
 		mconfig->d0i3_caps = tkn_elem->value;
 		break;
$ git annotate include/uapi/sound/snd_sst_tokens.h
8a0cb2360ddb9   (Vinod Koul     2016-11-03 17:07:18 +0530       215)
SKL_TKN_U32_PMODE,
6bd9dcf339ebb   (Vinod Koul     2016-11-03 17:07:19 +0530       216)
SKL_TKL_U32_D0I3_CAPS,
6bd9dcf339ebb   (Vinod Koul     2016-11-03 17:07:19 +0530       217)
SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
15f0d4f531d84   (Shreyas NC     2016-08-12 12:29:50 +0530       218)};
$ git name-rev --tags 6bd9dcf339ebb
6bd9dcf339ebb tags/sound-4.10-rc1~3^2~15^2~17

The typo was already included in Linux kernel v4.10 and exposed to userland. In general of kernel development, it's the worst idea to change it, because it can break userland.

Regards

Takashi Sakamoto

#3 lore raw

Re: [PATCH 2/2] ASoC: Intel: Skylake: Fix typo for token d0i3 caps

Quoted 46 lines · Takashi Sakamoto
Quoted 26 lines · Subhransu S. Prusty
---
 include/uapi/sound/snd_sst_tokens.h    | 4 ++--
 sound/soc/intel/skylake/skl-topology.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/snd_sst_tokens.h +2 -2
index 93392bedcc58..685149dda66b 100644
@@ -213,8 +213,8 @@ enum SKL_TKNS {
 	SKL_TKN_U32_LIB_COUNT,
 	SKL_TKN_STR_LIB_NAME,
 	SKL_TKN_U32_PMODE,
-	SKL_TKL_U32_D0I3_CAPS,
-	SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
+	SKL_TKN_U32_D0I3_CAPS,
+	SKL_TKN_MAX = SKL_TKN_U32_D0I3_CAPS,
 };
 
 #endif
sound/soc/intel/skylake/skl-topology.c +0 -0
index 3a99712e44a8..b28199a5348c 100644

sound/soc/intel/skylake/skl-topology.c static int skl_tplg_get_token(struct device *dev, · line 2000

Quoted 7 lines
sound/soc/intel/skylake/skl-topology.c +1 -1
@@ -1995,7 +1995,7 @@ static int skl_tplg_get_token(struct device *dev,
 		mconfig->converter = tkn_elem->value;
 		break;
 
-	case SKL_TKL_U32_D0I3_CAPS:
+	case SKL_TKN_U32_D0I3_CAPS:
 		mconfig->d0i3_caps = tkn_elem->value;
 		break;
$ git annotate include/uapi/sound/snd_sst_tokens.h
8a0cb2360ddb9   (Vinod Koul     2016-11-03 17:07:18 +0530       215)
SKL_TKN_U32_PMODE,
6bd9dcf339ebb   (Vinod Koul     2016-11-03 17:07:19 +0530       216)
SKL_TKL_U32_D0I3_CAPS,
6bd9dcf339ebb   (Vinod Koul     2016-11-03 17:07:19 +0530       217)
SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
15f0d4f531d84   (Shreyas NC     2016-08-12 12:29:50 +0530       218)};
$ git name-rev --tags 6bd9dcf339ebb
6bd9dcf339ebb tags/sound-4.10-rc1~3^2~15^2~17
Quoted 3 lines

The typo was already included in Linux kernel v4.10 and exposed to userland. In general of kernel development, it's the worst idea to change it, because it can break userland.

Instead of rename, it's better for you to keep the typo and add the correct entry with the same value, like:

$ git diff
(quoted diff) +0 -0

b/include/uapi/sound/snd_sst_tokens.h
index 93392bedcc58..b7cc95d04928 100644

include/uapi/sound/snd_sst_tokens.h +3 -2
@@ -213,8 +213,9 @@ enum SKL_TKNS {
        SKL_TKN_U32_LIB_COUNT,
        SKL_TKN_STR_LIB_NAME,
        SKL_TKN_U32_PMODE,
-       SKL_TKL_U32_D0I3_CAPS,
-       SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
+       SKL_TKL_U32_D0I3_CAPS,  /* Typo, added at v4.10. */
+       SKL_TKN_U32_D0I3_CAPS = SKN_TKL_U32_D0I3_CAPS,
+       SKL_TKN_MAX = SKL_TKN_U32_D0I3_CAPS,
 };
 
 #endif

Regards

Takashi Sakamoto

#4 lore raw

Re: [PATCH 2/2] ASoC: Intel: Skylake: Fix typo for token d0i3 caps

Quoted 61 lines · Takashi Sakamoto
Quoted 46 lines · Takashi Sakamoto
Quoted 26 lines · Subhransu S. Prusty
---
 include/uapi/sound/snd_sst_tokens.h    | 4 ++--
 sound/soc/intel/skylake/skl-topology.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/sound/snd_sst_tokens.h +2 -2
index 93392bedcc58..685149dda66b 100644
@@ -213,8 +213,8 @@ enum SKL_TKNS {
 	SKL_TKN_U32_LIB_COUNT,
 	SKL_TKN_STR_LIB_NAME,
 	SKL_TKN_U32_PMODE,
-	SKL_TKL_U32_D0I3_CAPS,
-	SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
+	SKL_TKN_U32_D0I3_CAPS,
+	SKL_TKN_MAX = SKL_TKN_U32_D0I3_CAPS,
 };
 
 #endif
sound/soc/intel/skylake/skl-topology.c +0 -0
index 3a99712e44a8..b28199a5348c 100644

sound/soc/intel/skylake/skl-topology.c static int skl_tplg_get_token(struct device *dev, · line 2000

Quoted 7 lines
sound/soc/intel/skylake/skl-topology.c +1 -1
@@ -1995,7 +1995,7 @@ static int skl_tplg_get_token(struct device *dev,
 		mconfig->converter = tkn_elem->value;
 		break;
 
-	case SKL_TKL_U32_D0I3_CAPS:
+	case SKL_TKN_U32_D0I3_CAPS:
 		mconfig->d0i3_caps = tkn_elem->value;
 		break;
$ git annotate include/uapi/sound/snd_sst_tokens.h
8a0cb2360ddb9   (Vinod Koul     2016-11-03 17:07:18 +0530       215)
SKL_TKN_U32_PMODE,
6bd9dcf339ebb   (Vinod Koul     2016-11-03 17:07:19 +0530       216)
SKL_TKL_U32_D0I3_CAPS,
6bd9dcf339ebb   (Vinod Koul     2016-11-03 17:07:19 +0530       217)
SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
15f0d4f531d84   (Shreyas NC     2016-08-12 12:29:50 +0530       218)};
$ git name-rev --tags 6bd9dcf339ebb
6bd9dcf339ebb tags/sound-4.10-rc1~3^2~15^2~17
Quoted 3 lines

The typo was already included in Linux kernel v4.10 and exposed to userland. In general of kernel development, it's the worst idea to change it, because it can break userland.

Instead of rename, it's better for you to keep the typo and add the correct entry with the same value, like:

$ git diff
include/uapi/sound/snd_sst_tokens.h +0 -0
index 93392bedcc58..b7cc95d04928 100644

include/uapi/sound/snd_sst_tokens.h enum SKL_TKNS { · line 217

Quoted 7 lines
include/uapi/sound/snd_sst_tokens.h +2 -2
@@ -213,8 +213,9 @@ enum SKL_TKNS {
        SKL_TKN_U32_LIB_COUNT,
        SKL_TKN_STR_LIB_NAME,
        SKL_TKN_U32_PMODE,
-       SKL_TKL_U32_D0I3_CAPS,
-       SKL_TKN_MAX = SKL_TKL_U32_D0I3_CAPS,
+       SKL_TKL_U32_D0I3_CAPS,  /* Typo, added at v4.10. */
+       SKL_TKN_U32_D0I3_CAPS = SKN_TKL_U32_D0I3_CAPS,

Hi Takashi,

Thanks for the suggestion. I will resubmit the patch with the change.

Regards,
Subhransu

Quoted 9 lines
include/uapi/sound/snd_sst_tokens.h +1 -0
+       SKL_TKN_MAX = SKL_TKN_U32_D0I3_CAPS,
 };
 
 #endif

Regards

Takashi Sakamoto

maintainer
#5 lore raw

Applied "ASoC: Intel: Skylake: Move i915 registration to worker thread" to the asoc tree

In reply to Subhransu S. Prusty

The patch

ASoC: Intel: Skylake: Move i915 registration to worker thread

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From ab1b732d53c18f26f51cad49371be3244fe67504 Mon Sep 17 00:00:00 2001

From: Vinod Koul <[email protected]>
Date: Thu, 4 May 2017 14:09:10 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Move i915 registration to worker thread

The i915 component framework expects the caller to be invoking snd_hdac_i915_init() from a thread context. Otherwise it results in lockups on drm side.

So move the registering of component interface and probing of codecs on this bus to a worker thread.

init_failed in skl structure is not used currently, so renamed to init_done and used to track the initialization done in worker thread.

---
 sound/soc/intel/skylake/skl.c | 162 +++++++++++++++++++++++-------------------
 sound/soc/intel/skylake/skl.h |   4 +-
 2 files changed, 91 insertions(+), 75 deletions(-)
sound/soc/intel/skylake/skl.c +88 -74
index 6df3b317a476..4c9b5781282b 100644
@@ -410,7 +410,7 @@ static int skl_free(struct hdac_ext_bus *ebus)
 	struct skl *skl  = ebus_to_skl(ebus);
 	struct hdac_bus *bus = ebus_to_hbus(ebus);
 
-	skl->init_failed = 1; /* to be sure */
+	skl->init_done = 0; /* to be sure */
 
 	snd_hdac_ext_stop_streams(ebus);
 
@@ -428,8 +428,10 @@ static int skl_free(struct hdac_ext_bus *ebus)
 
 	snd_hdac_ext_bus_exit(ebus);
 
+	cancel_work_sync(&skl->probe_work);
 	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
 		snd_hdac_i915_exit(&ebus->bus);
+
 	return 0;
 }
 
@@ -566,6 +568,84 @@ static const struct hdac_bus_ops bus_core_ops = {
 	.get_response = snd_hdac_bus_get_response,
 };
 
+static int skl_i915_init(struct hdac_bus *bus)
+{
+	int err;
+
+	/*
+	 * The HDMI codec is in GPU so we need to ensure that it is powered
+	 * up and ready for probe
+	 */
+	err = snd_hdac_i915_init(bus);
+	if (err < 0)
+		return err;
+
+	err = snd_hdac_display_power(bus, true);
+	if (err < 0)
+		dev_err(bus->dev, "Cannot turn on display power on i915\n");
+
+	return err;
+}
+
+static void skl_probe_work(struct work_struct *work)
+{
+	struct skl *skl = container_of(work, struct skl, probe_work);
+	struct hdac_ext_bus *ebus = &skl->ebus;
+	struct hdac_bus *bus = ebus_to_hbus(ebus);
+	struct hdac_ext_link *hlink = NULL;
+	int err;
+
+	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
+		err = skl_i915_init(bus);
+		if (err < 0)
+			return;
+	}
+
+	err = skl_init_chip(bus, true);
+	if (err < 0) {
+		dev_err(bus->dev, "Init chip failed with err: %d\n", err);
+		goto out_err;
+	}
+
+	/* codec detection */
+	if (!bus->codec_mask)
+		dev_info(bus->dev, "no hda codecs found!\n");
+
+	/* create codec instances */
+	err = skl_codec_create(ebus);
+	if (err < 0)
+		goto out_err;
+
+	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
+		err = snd_hdac_display_power(bus, false);
+		if (err < 0) {
+			dev_err(bus->dev, "Cannot turn off display power on i915\n");
+			return;
+		}
+	}
+
+	/* register platform dai and controls */
+	err = skl_platform_register(bus->dev);
+	if (err < 0)
+		return;
+	/*
+	 * we are done probing so decrement link counts
+	 */
+	list_for_each_entry(hlink, &ebus->hlink_list, list)
+		snd_hdac_ext_bus_link_put(ebus, hlink);
+
+	/* configure PM */
+	pm_runtime_put_noidle(bus->dev);
+	pm_runtime_allow(bus->dev);
+	skl->init_done = 1;
+
+	return;
+
+out_err:
+	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
+		err = snd_hdac_display_power(bus, false);
+}
+
 /*
  * constructor
  */
@@ -593,6 +673,7 @@ static int skl_create(struct pci_dev *pci,
 	snd_hdac_ext_bus_init(ebus, &pci->dev, &bus_core_ops, io_ops);
 	ebus->bus.use_posbuf = 1;
 	skl->pci = pci;
+	INIT_WORK(&skl->probe_work, skl_probe_work);
 
 	ebus->bus.bdl_pos_adj = 0;
 
@@ -601,27 +682,6 @@ static int skl_create(struct pci_dev *pci,
 	return 0;
 }
 
-static int skl_i915_init(struct hdac_bus *bus)
-{
-	int err;
-
-	/*
-	 * The HDMI codec is in GPU so we need to ensure that it is powered
-	 * up and ready for probe
-	 */
-	err = snd_hdac_i915_init(bus);
-	if (err < 0)
-		return err;
-
-	err = snd_hdac_display_power(bus, true);
-	if (err < 0) {
-		dev_err(bus->dev, "Cannot turn on display power on i915\n");
-		return err;
-	}
-
-	return err;
-}
-
 static int skl_first_init(struct hdac_ext_bus *ebus)
 {
 	struct skl *skl = ebus_to_skl(ebus);
@@ -684,20 +744,7 @@ static int skl_first_init(struct hdac_ext_bus *ebus)
 	/* initialize chip */
 	skl_init_pci(skl);
 
-	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-		err = skl_i915_init(bus);
-		if (err < 0)
-			return err;
-	}
-
-	skl_init_chip(bus, true);
-
-	/* codec detection */
-	if (!bus->codec_mask) {
-		dev_info(bus->dev, "no hda codecs found!\n");
-	}
-
-	return 0;
+	return skl_init_chip(bus, true);
 }
 
 static int skl_probe(struct pci_dev *pci,
@@ -706,7 +753,6 @@ static int skl_probe(struct pci_dev *pci,
 	struct skl *skl;
 	struct hdac_ext_bus *ebus = NULL;
 	struct hdac_bus *bus = NULL;
-	struct hdac_ext_link *hlink = NULL;
 	int err;
 
 	/* we use ext core ops, so provide NULL for ops here */
@@ -729,7 +775,7 @@ static int skl_probe(struct pci_dev *pci,
 
 	if (skl->nhlt == NULL) {
 		err = -ENODEV;
-		goto out_display_power_off;
+		goto out_free;
 	}
 
 	err = skl_nhlt_create_sysfs(skl);
@@ -760,56 +806,24 @@ static int skl_probe(struct pci_dev *pci,
 	if (bus->mlcap)
 		snd_hdac_ext_bus_get_ml_capabilities(ebus);
 
+	snd_hdac_bus_stop_chip(bus);
+
 	/* create device for soc dmic */
 	err = skl_dmic_device_register(skl);
 	if (err < 0)
 		goto out_dsp_free;
 
-	/* register platform dai and controls */
-	err = skl_platform_register(bus->dev);
-	if (err < 0)
-		goto out_dmic_free;
-
-	/* create codec instances */
-	err = skl_codec_create(ebus);
-	if (err < 0)
-		goto out_unregister;
-
-	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
-		err = snd_hdac_display_power(bus, false);
-		if (err < 0) {
-			dev_err(bus->dev, "Cannot turn off display power on i915\n");
-			return err;
-		}
-	}
-
-	/*
-	 * we are done probling so decrement link counts
-	 */
-	list_for_each_entry(hlink, &ebus->hlink_list, list)
-		snd_hdac_ext_bus_link_put(ebus, hlink);
-
-	/* configure PM */
-	pm_runtime_put_noidle(bus->dev);
-	pm_runtime_allow(bus->dev);
+	schedule_work(&skl->probe_work);
 
 	return 0;
 
-out_unregister:
-	skl_platform_unregister(bus->dev);
-out_dmic_free:
-	skl_dmic_device_unregister(skl);
 out_dsp_free:
 	skl_free_dsp(skl);
 out_mach_free:
 	skl_machine_device_unregister(skl);
 out_nhlt_free:
 	skl_nhlt_free(skl->nhlt);
-out_display_power_off:
-	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
-		snd_hdac_display_power(bus, false);
 out_free:
-	skl->init_failed = 1;
 	skl_free(ebus);
 
 	return err;
@@ -828,7 +842,7 @@ static void skl_shutdown(struct pci_dev *pci)
 
 	skl = ebus_to_skl(ebus);
 
-	if (skl->init_failed)
+	if (!skl->init_done)
 		return;
 
 	snd_hdac_ext_stop_streams(ebus);
sound/soc/intel/skylake/skl.h +3 -1
index a454f6035f3e..2a630fcb7f08 100644
@@ -46,7 +46,7 @@ struct skl {
 	struct hdac_ext_bus ebus;
 	struct pci_dev *pci;
 
-	unsigned int init_failed:1; /* delayed init failed */
+	unsigned int init_done:1; /* delayed init status */
 	struct platform_device *dmic_dev;
 	struct platform_device *i2s_dev;
 	struct snd_soc_platform *platform;
@@ -64,6 +64,8 @@ struct skl {
 	const struct firmware *tplg;
 
 	int supend_active;
+
+	struct work_struct probe_work;
 };
 
 #define skl_to_ebus(s)	(&(s)->ebus)
Signature · 1 line
2.11.0