Skip to contentSkip to conversation

ASoC: Intel: machine driver updates for 5.9

PATCH In review Pierre-Louis Bossart 2 participants 10 messages Jul 17, 2020 – Jul 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Intel: machine driver updates for 5.9

Small patchset to harden the SoundWire machine driver, change bad HIDs, update PLL settings and avoid memory leaks. Given that the SoundWire core parts are not upstream it's probably not necessary to provide the patches to stable branches.

Bard Liao (1):
ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name

Kai Vehmanen (2):
ASoC: Intel: sof_sdw: add support for systems without i915 audio
ASoC: Intel: sof_sdw: avoid crash if invalid DSP topology loaded

Libin Yang (1):
ASoC: Intel: common: change match table ehl-rt5660

Pierre-Louis Bossart (1):
ASoC: Intel: sof_sdw_rt711: remove properties in card remove

Yong Zhi (1):
ASoC: intel: board: sof_rt5682: Update rt1015 pll input clk freq

 sound/soc/intel/boards/sof_rt5682.c           |  9 +++++-
 sound/soc/intel/boards/sof_sdw.c              | 31 +++++++++++++------
 sound/soc/intel/boards/sof_sdw_common.h       |  2 ++
 sound/soc/intel/boards/sof_sdw_hdmi.c         |  6 ++++
 sound/soc/intel/boards/sof_sdw_rt711.c        | 17 +++++++++-
 .../intel/common/soc-acpi-intel-ehl-match.c   |  2 +-
 6 files changed, 54 insertions(+), 13 deletions(-)

base-commit: 22e9b54307987787efa0ee534aa9e31982ec1161

Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/6 ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name

From: Bard Liao <[email protected]>

We can get codec name from dai link.

---
 sound/soc/intel/boards/sof_sdw_rt711.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/boards/sof_sdw_rt711.c +1 -1
index d4d75c8dc6b7..c8f84e9a3e4e 100644
@@ -147,7 +147,7 @@ int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
 	if (!playback)
 		return 0;
 
-	ret = rt711_add_codec_device_props("sdw:0:25d:711:0");
+	ret = rt711_add_codec_device_props(dai_links->codecs[0].name);
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/6 ASoC: Intel: sof_sdw_rt711: remove properties in card remove

In reply to Pierre-Louis Bossart

The rt711 jack detection properties are set from the machine drivers during the card probe, as done in other ASoC examples.

KASAN reports a use-after-free error when unbinding drivers due to a confusing sequence between the ACPI core, the device core and the SoundWire device cleanups.

Rather than fixing this sequence, follow the recommendation to have the same caller add and remove properties, add an explicit device_remove_properties() in the card .remove() callback.

In future patches the use of device_add/remove_properties will be replaced by a direct handling of a swnode, but the sequence will remain the same.

---
 sound/soc/intel/boards/sof_sdw.c        |  1 +
 sound/soc/intel/boards/sof_sdw_common.h |  1 +
 sound/soc/intel/boards/sof_sdw_rt711.c  | 15 +++++++++++++++
 3 files changed, 17 insertions(+)
sound/soc/intel/boards/sof_sdw.c +1 -0
index be8eccb50450..9b6059905dbe 100644
@@ -217,6 +217,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
 		.direction = {true, true},
 		.dai_name = "rt711-aif1",
 		.init = sof_sdw_rt711_init,
+		.exit = sof_sdw_rt711_exit,
 	},
 	{
 		.id = 0x1308,
sound/soc/intel/boards/sof_sdw_common.h +1 -0
index 426017626b16..c64c5d801d26 100644
@@ -91,6 +91,7 @@ int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
 		       struct snd_soc_dai_link *dai_links,
 		       struct sof_sdw_codec_info *info,
 		       bool playback);
+int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
 
 /* RT700 support */
 int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
sound/soc/intel/boards/sof_sdw_rt711.c +15 -0
index c8f84e9a3e4e..606009fa3901 100644
@@ -133,6 +133,21 @@ static int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
+int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link)
+{
+	struct device *sdw_dev;
+
+	sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL,
+					  dai_link->codecs[0].name);
+	if (!sdw_dev)
+		return -EINVAL;
+
+	device_remove_properties(sdw_dev);
+	put_device(sdw_dev);
+
+	return 0;
+}
+
 int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
 		       struct snd_soc_dai_link *dai_links,
 		       struct sof_sdw_codec_info *info,
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/6 ASoC: Intel: sof_sdw: add support for systems without i915 audio

In reply to Pierre-Louis Bossart

From: Kai Vehmanen <[email protected]>

Extend the generic SOF Soundwire machine driver to support systems where iDisp HDMI/DP audio codec is disabled for some reason (i915 driver disabled, HDMI/DP implemented with a discrete GPU, etc). Switch codecs to SoC dummy in the affected DAI links. This allows to reuse existing topologies for this case.

---
 sound/soc/intel/boards/sof_sdw.c        | 30 ++++++++++++++++---------
 sound/soc/intel/boards/sof_sdw_common.h |  1 +
 sound/soc/intel/boards/sof_sdw_hdmi.c   |  3 +++
 3 files changed, 24 insertions(+), 10 deletions(-)
sound/soc/intel/boards/sof_sdw.c +20 -10
index 9b6059905dbe..2463d432bf4d 100644
@@ -699,11 +699,14 @@ static inline int get_next_be_id(struct snd_soc_dai_link *links,
 	return links[be_id - 1].id + 1;
 }
 
+#define IDISP_CODEC_MASK	0x4
+
 static int sof_card_dai_links_create(struct device *dev,
 				     struct snd_soc_acpi_mach *mach,
 				     struct snd_soc_card *card)
 {
 	int ssp_num, sdw_be_num = 0, hdmi_num = 0, dmic_num;
+	struct mc_private *ctx = snd_soc_card_get_drvdata(card);
 	struct snd_soc_dai_link_component *idisp_components;
 	struct snd_soc_dai_link_component *ssp_components;
 	struct snd_soc_acpi_mach_params *mach_params;
@@ -747,12 +750,15 @@ static int sof_card_dai_links_create(struct device *dev,
 		return ret;
 	}
 
+	if (mach_params->codec_mask & IDISP_CODEC_MASK)
+		ctx->idisp_codec = true;
+
 	/* enable dmic01 & dmic16k */
 	dmic_num = (sof_sdw_quirk & SOF_SDW_PCH_DMIC) ? 2 : 0;
 	comp_num += dmic_num;
 
 	dev_dbg(dev, "sdw %d, ssp %d, dmic %d, hdmi %d", sdw_be_num, ssp_num,
-		dmic_num, hdmi_num);
+		dmic_num, ctx->idisp_codec ? hdmi_num : 0);
 
 	/* allocate BE dailinks */
 	num_links = comp_num + sdw_be_num;
@@ -901,13 +907,18 @@ static int sof_card_dai_links_create(struct device *dev,
 		if (!name)
 			return -ENOMEM;
 
-		idisp_components[i].name = "ehdaudio0D2";
-		idisp_components[i].dai_name = devm_kasprintf(dev,
-							      GFP_KERNEL,
-							      "intel-hdmi-hifi%d",
-							      i + 1);
-		if (!idisp_components[i].dai_name)
-			return -ENOMEM;
+		if (ctx->idisp_codec) {
+			idisp_components[i].name = "ehdaudio0D2";
+			idisp_components[i].dai_name = devm_kasprintf(dev,
+								      GFP_KERNEL,
+								      "intel-hdmi-hifi%d",
+								      i + 1);
+			if (!idisp_components[i].dai_name)
+				return -ENOMEM;
+		} else {
+			idisp_components[i].name = "snd-soc-dummy";
+			idisp_components[i].dai_name = "snd-soc-dummy-dai";
+		}
 
 		cpu_name = devm_kasprintf(dev, GFP_KERNEL,
 					  "iDisp%d Pin", i + 1);
@@ -982,6 +993,7 @@ static int mc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
 
 	card->dev = &pdev->dev;
+	snd_soc_card_set_drvdata(card, ctx);
 
 	mach = pdev->dev.platform_data;
 	ret = sof_card_dai_links_create(&pdev->dev, mach,
@@ -991,8 +1003,6 @@ static int mc_probe(struct platform_device *pdev)
 
 	ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
 
-	snd_soc_card_set_drvdata(card, ctx);
-
 	/*
 	 * the default amp_num is zero for each codec and
 	 * amp_num will only be increased for active amp
sound/soc/intel/boards/sof_sdw_common.h +1 -0
index c64c5d801d26..12e32439ba46 100644
@@ -70,6 +70,7 @@ struct sof_sdw_codec_info {
 struct mc_private {
 	struct list_head hdmi_pcm_list;
 	bool common_hdmi_codec_drv;
+	bool idisp_codec;
 	struct snd_soc_jack sdw_headset;
 };
 
sound/soc/intel/boards/sof_sdw_hdmi.c +3 -0
index 0654b38a7e0d..72316d34eed6 100644
@@ -52,6 +52,9 @@ int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card)
 	int err, i = 0;
 	char jack_name[NAME_SIZE];
 
+	if (!ctx->idisp_codec)
+		return 0;
+
 	pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
 			       head);
 	component = pcm->codec_dai->component;
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/6 ASoC: Intel: sof_sdw: avoid crash if invalid DSP topology loaded

In reply to Pierre-Louis Bossart

From: Kai Vehmanen <[email protected]>

The mc_private->hdmi_pcm_list is populated by elements loaded during DSP topology load. Valid topologies for this machine driver will always have PCM nodes for HDMI, but driver should fail gracefully even in the case this is not true. Add a sanity check to sof_sdw_hdmi_card_late_probe() for this case. Without the fix, a null pcm handle gets dereferenced.

---
 sound/soc/intel/boards/sof_sdw_hdmi.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/intel/boards/sof_sdw_hdmi.c +3 -0
index 72316d34eed6..99b04bb2f3a0 100644
@@ -55,6 +55,9 @@ int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card)
 	if (!ctx->idisp_codec)
 		return 0;
 
+	if (list_empty(&ctx->hdmi_pcm_list))
+		return -EINVAL;
+
 	pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
 			       head);
 	component = pcm->codec_dai->component;
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/6 ASoC: intel: board: sof_rt5682: Update rt1015 pll input clk freq

In reply to Pierre-Louis Bossart

From: Yong Zhi <[email protected]>

In commit d696a61413b4 ("ASoC: rt1015: Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate."), PLL input at 50fs is no longer supported, the new recommended settings at 48Khz rate are:

PLL input SSP bclk
------------------------
64fs 3.073Mhz
100fs 4.8Mhz

(bclk update is reflected in topoplogy.)

---
 sound/soc/intel/boards/sof_rt5682.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
sound/soc/intel/boards/sof_rt5682.c +8 -1
index cc8b0f26f724..61a61dcca82a 100644
@@ -284,8 +284,15 @@ static int sof_rt1015_hw_params(struct snd_pcm_substream *substream,
 		return 0;
 
 	for_each_rtd_codec_dais(rtd, i, codec_dai) {
+		/* Set tdm/i2s1 master bclk ratio */
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64);
+		if (ret < 0) {
+			dev_err(card->dev, "failed to set bclk ratio\n");
+			return ret;
+		}
+
 		ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK,
-					  params_rate(params) * 50,
+					  params_rate(params) * 64,
 					  params_rate(params) * 256);
 		if (ret < 0) {
 			dev_err(card->dev, "failed to set pll\n");
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/6 ASoC: Intel: common: change match table ehl-rt5660

In reply to Pierre-Louis Bossart

From: Libin Yang <[email protected]>

This configuration is for EHL with the RT5660 codec. RT5660 should use "10EC5660" ID instead of "INTC1027".

---
 sound/soc/intel/common/soc-acpi-intel-ehl-match.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/common/soc-acpi-intel-ehl-match.c +1 -1
index 45e07d886013..badafc1d54d2 100644
@@ -12,7 +12,7 @@
 
 struct snd_soc_acpi_mach snd_soc_acpi_intel_ehl_machines[] = {
 	{
-		.id = "INTC1027",
+		.id = "10EC5660",
 		.drv_name = "ehl_rt5660",
 		.sof_fw_filename = "sof-ehl.ri",
 		.sof_tplg_filename = "sof-ehl-rt5660.tplg",
Signature · 1 line
2.25.1
maintainer
#7 lore raw

Re: [PATCH 6/6] ASoC: Intel: common: change match table ehl-rt5660

Quoted 4 lines · Pierre-Louis Bossart

From: Libin Yang <[email protected]>

This configuration is for EHL with the RT5660 codec. RT5660 should use "10EC5660" ID instead of "INTC1027".

This seems like it should have gone out as a bug fix?

maintainer
#8 lore raw
In reply to Pierre-Louis Bossart
Quoted 9 lines · Pierre-Louis Bossart

Small patchset to harden the SoundWire machine driver, change bad HIDs, update PLL settings and avoid memory leaks. Given that the SoundWire core parts are not upstream it's probably not necessary to provide the patches to stable branches.

Bard Liao (1):
ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name
(no commit info)
[2/6] ASoC: Intel: sof_sdw_rt711: remove properties in card remove
(no commit info)
[3/6] ASoC: Intel: sof_sdw: add support for systems without i915 audio
(no commit info)
[4/6] ASoC: Intel: sof_sdw: avoid crash if invalid DSP topology loaded
(no commit info)
[5/6] ASoC: intel: board: sof_rt5682: Update rt1015 pll input clk freq
(no commit info)
[6/6] ASoC: Intel: common: change match table ehl-rt5660

      commit: 58ef60025a1263e78de01b135d05784996383611

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

maintainer
#9 lore raw
In reply to Pierre-Louis Bossart
Quoted 9 lines · Pierre-Louis Bossart

Small patchset to harden the SoundWire machine driver, change bad HIDs, update PLL settings and avoid memory leaks. Given that the SoundWire core parts are not upstream it's probably not necessary to provide the patches to stable branches.

Bard Liao (1):
ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name

      commit: 1f891055c7d0ce665247c09e97db927f2db37ce7
[2/5] ASoC: Intel: sof_sdw_rt711: remove properties in card remove
      commit: cf0418cd06ce42fcf35beb33e315b5a77e596926
[3/5] ASoC: Intel: sof_sdw: add support for systems without i915 audio
      commit: 15ef2ea035db7bcb9a9d0bf3747fbb7dde67dd97
[4/5] ASoC: Intel: sof_sdw: avoid crash if invalid DSP topology loaded
      commit: 6b540ac763e9d11506ec1eb6b0fadc70292bb4a6
[5/5] ASoC: intel: board: sof_rt5682: Update rt1015 pll input clk freq
      commit: 0d95d06a7aae38f3bd61582e00f0cc06b35ca0ab

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