ASoC: core/topology/Intel:
Subsystems (3)
Peter Ujfalusi
maintainercover ASoC: core/topology/Intel:
Hi,
There are devices where the iDisp HDA codec for HDMI is disconnected and it is not present on the HDA bus.
This usually happens on systems with dGPU, but not limited to them.
How SOF tried to deal with this is to drop in a dummy codec in place of the iDisp to allow the topology to be loaded, but these PCM devices are unusable, they fail when user tries to use them.
PA/PW is probing the PCM devices on probe and that causes the kernel log to fill up with errors, which is harmless but disturbing.
This series will use the filter function to prevent the creation of the HDMI PCM devices in the first place (like HDA legacy stack will not present HDMI devices if the codec is not visible).
The topology still loads, we still use dummy codec to satisfy it, but there will be no dummy PCM devices created.
The first two patch handles the same issue that was discovered by the ignored link: a NULL dereference.
I'm not sure if both is needed, but I felt that fixing it in one place and leaving the other open might not be future proof.
If I would to pick one, I would likely go with the patch for the soc-core.
Regards,
Peter
---
Peter Ujfalusi (4):
ASoC: topology: Do not call snd_soc_remove_pcm_runtime() for ignored
links
ASoC: core: Check for rtd == NULL in snd_soc_remove_pcm_runtime()
ASoC: Intel: skl_hda_dsp_generic: Implement add_dai_link to filter
HDMI PCMs
ASoC: Intel: sof_sdw: Implement add_dai_link to filter HDMI PCMs
sound/soc/intel/boards/skl_hda_dsp_generic.c | 13 +++++++++++++ sound/soc/intel/boards/sof_sdw.c | 14 ++++++++++++++ sound/soc/soc-core.c | 3 +++ sound/soc/soc-topology.c | 7 +++++-- 4 files changed, 35 insertions(+), 2 deletions(-)
Signature · 1 line
2.49.0
Peter Ujfalusi
maintainerPATCH 1/4 ASoC: topology: Do not call snd_soc_remove_pcm_runtime() for ignored links
If a link has been ignored then it is not even added.
The snd_soc_get_pcm_runtime() will return NULL as the runtime will does not exist.
We can just skip this step to avoid performing a lookup to do nothing.
--- sound/soc/soc-topology.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/soc-topology.c +5 -2
@@ -429,8 +429,11 @@ static void soc_tplg_remove_link(struct snd_soc_component *comp, dobj->unload (comp, dobj);list_del (&dobj->list); -snd_soc_remove_pcm_runtime (comp->card, -snd_soc_get_pcm_runtime (comp->card, link)); + +/* Ignored links do not need to be removed, they are not added */ +if (!link->ignore) +snd_soc_remove_pcm_runtime (comp->card, +snd_soc_get_pcm_runtime (comp->card, link)); }/* unload dai link */
Signature · 1 line
2.49.0
Peter Ujfalusi
maintainerPATCH 2/4 ASoC: core: Check for rtd == NULL in snd_soc_remove_pcm_runtime()
In reply to Peter Ujfalusisnd_soc_remove_pcm_runtime() might be called with rtd == NULL which will leads to null pointer dereference.
This was reproduced with topology loading and marking a link as ignore due to missing hardware component on the system.
On module removal the soc_tplg_remove_link() would call snd_soc_remove_pcm_runtime() with rtd == NULL since the link was ignored, no runtime was created.
--- sound/soc/soc-core.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/soc-core.c +3 -0
@@ -1139,6 +1139,9 @@ static int snd_soc_compensate_channel_connection_map(struct snd_soc_card *card,void snd_soc_remove_pcm_runtime (struct snd_soc_card *card,struct snd_soc_pcm_runtime *rtd) { +if (!rtd) +return ; +lockdep_assert_held (&client_mutex);/*
Signature · 1 line
2.49.0
Peter Ujfalusi
maintainerPATCH 3/4 ASoC: Intel: skl_hda_dsp_generic: Implement add_dai_link to filter HDMI PCMs
In reply to Peter UjfalusiIf the system does not have iDisp codec then mark the HDMI PCM link as ignore.
This ensures that HDMI PCMs will not be created when there is no iDisp codec available.
When iDisp codec is not present and the HDMI PCMs were created they were not operational, all operations would fail on them.
With this patch it is possible to load the topology with HDMI links, but gives the ability to ignore them and thus prevent the creation of the nonworking PCM devices.
--- sound/soc/intel/boards/skl_hda_dsp_generic.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
sound/soc/intel/boards/skl_hda_dsp_generic.c +13 -0
@@ -85,6 +85,18 @@ skl_hda_get_board_quirk(struct snd_soc_acpi_mach_params *mach_params)return board_quirk; } +static int skl_hda_add_dai_link (struct snd_soc_card *card, +struct snd_soc_dai_link *link) +{ +struct sof_card_private *ctx =snd_soc_card_get_drvdata (card); + +/* Ignore the HDMI PCM link if iDisp is not present */ +if (strstr (link->stream_name,"HDMI" ) && !ctx->hdmi.idisp_codec) + link->ignore = true; + +return 0 ; +} +static int skl_hda_audio_probe (struct platform_device *pdev) {struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
@@ -101,6 +113,7 @@ static int skl_hda_audio_probe(struct platform_device *pdev) card->owner =THIS_MODULE ; card->fully_routed = true; card->late_probe = skl_hda_card_late_probe; + card->add_dai_link = skl_hda_add_dai_link;dev_dbg (&pdev->dev,"board_quirk = %lx\n" , board_quirk);
Signature · 1 line
2.49.0
Peter Ujfalusi
maintainerPATCH 4/4 ASoC: Intel: sof_sdw: Implement add_dai_link to filter HDMI PCMs
In reply to Peter UjfalusiIf the system does not have iDisp codec then mark the HDMI PCM link as ignore.
This ensures that HDMI PCMs will not be created when there is no iDisp codec available.
When iDisp codec is not present and the HDMI PCMs were created they were not operational, all operations would fail on them.
With this patch it is possible to load the topology with HDMI links, but gives the ability to ignore them and thus prevent the creation of the nonworking PCM devices.
--- sound/soc/intel/boards/sof_sdw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
sound/soc/intel/boards/sof_sdw.c +14 -0
@@ -1295,6 +1295,19 @@ static int sof_sdw_card_late_probe(struct snd_soc_card *card)return ret; } +static int sof_sdw_add_dai_link (struct snd_soc_card *card, +struct snd_soc_dai_link *link) +{ +struct asoc_sdw_mc_private *ctx =snd_soc_card_get_drvdata (card); +struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private; + +/* Ignore the HDMI PCM link if iDisp is not present */ +if (strstr (link->stream_name,"HDMI" ) && !intel_ctx->hdmi.idisp_codec) + link->ignore = true; + +return 0 ; +} +static int mc_probe (struct platform_device *pdev) {struct snd_soc_acpi_mach *mach =dev_get_platdata (&pdev->dev);
@@ -1321,6 +1334,7 @@ static int mc_probe(struct platform_device *pdev) card->name ="soundwire" ; card->owner =THIS_MODULE ; card->late_probe = sof_sdw_card_late_probe; + card->add_dai_link = sof_sdw_add_dai_link;snd_soc_card_set_drvdata (card, ctx);
Signature · 1 line
2.49.0
Mark Brown
maintainerQuoted 11 lines · Peter Ujfalusi
There are devices where the iDisp HDA codec for HDMI is disconnected and it is not present on the HDA bus.
This usually happens on systems with dGPU, but not limited to them.How SOF tried to deal with this is to drop in a dummy codec in place of the iDisp to allow the topology to be loaded, but these PCM devices are unusable, they fail when user tries to use them.
PA/PW is probing the PCM devices on probe and that causes the kernel log to fill up with errors, which is harmless but disturbing.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: topology: Do not call snd_soc_remove_pcm_runtime() for ignored links
commit: cbf4e0fac347b78f1bcd29350b78184665ad487d
[2/4] ASoC: core: Check for rtd == NULL in snd_soc_remove_pcm_runtime()
commit: 2d91cb261cac6d885954b8f5da28b5c176c18131
[3/4] ASoC: Intel: skl_hda_dsp_generic: Implement add_dai_link to filter HDMI PCMs
commit: 86591907527effbfd99c038ffc06ca30bb4f6b64
[4/4] ASoC: Intel: sof_sdw: Implement add_dai_link to filter HDMI PCMs
commit: bb48117b79ebc39485f7306d09dc602981fe540fAll 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