Commit d7e6a980 authored by Mark Brown's avatar Mark Brown

ASoC: Harden DAPM route checks and Intel fixes

Merge series from Cezary Rojewski <cezary.rojewski@intel.com>:

Set of loosely connected patches. Most impactful change is dropping any
permisiveness when snd_soc_dapm_add_routes() fails in soc-topology.c To
do it safely, disable route checks for all skylake-driver boards.

Relevant background:

Since commit daa480bd ("ASoC: soc-core: tidyup for
snd_soc_dapm_add_routes()") route checks are no longer permissive. Probe
failures for Intel boards have been partially addressed by commit
a22ae72b ("ASoC: soc-core: isable route checks for legacy devices")
and its follow up but only skl_nau88l25_ssm4567.c is patched. The rest
of the boards still need fixing.

After that, removal of copy-pastas found in ssm4567.c and redundant code
in i2s_test.c for avs-boards.

Changes in v2:
- glk_rt5682_max98357a.c and skl_hda_dsp_generic.c now disable route
  checks only for the skylake-drvier
- asoc now logs failures of snd_soc_dapm_add_routes() in soc-topology.c

Amadeusz Sławiński (1):
  ASoC: Intel: avs: i2s_test: Remove redundant dapm routes

Cezary Rojewski (4):
  ASoC: Intel: Disable route checks for Skylake boards
  ASoC: topology: Do not ignore route checks when parsing graphs
  ASoC: Intel: avs: ssm4567: Do not ignore route checks
  ASoC: Intel: avs: ssm4567: Board cleanup

 sound/soc/intel/avs/boards/i2s_test.c         | 79 -------------------
 sound/soc/intel/avs/boards/ssm4567.c          |  5 +-
 sound/soc/intel/boards/bxt_da7219_max98357a.c |  1 +
 sound/soc/intel/boards/bxt_rt298.c            |  1 +
 sound/soc/intel/boards/glk_rt5682_max98357a.c |  2 +
 sound/soc/intel/boards/kbl_da7219_max98357a.c |  1 +
 sound/soc/intel/boards/kbl_da7219_max98927.c  |  4 +
 sound/soc/intel/boards/kbl_rt5660.c           |  1 +
 sound/soc/intel/boards/kbl_rt5663_max98927.c  |  2 +
 .../intel/boards/kbl_rt5663_rt5514_max98927.c |  1 +
 sound/soc/intel/boards/skl_hda_dsp_generic.c  |  2 +
 .../soc/intel/boards/skl_nau88l25_max98357a.c |  1 +
 sound/soc/intel/boards/skl_rt286.c            |  1 +
 sound/soc/soc-topology.c                      | 11 ++-
 14 files changed, 27 insertions(+), 85 deletions(-)

--
2.25.1
parents ef71b330 60c10c67
......@@ -54,76 +54,13 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
return 0;
}
static int avs_create_dapm_routes(struct device *dev, int ssp_port, int tdm_slot,
struct snd_soc_dapm_route **routes, int *num_routes)
{
struct snd_soc_dapm_route *dr;
const int num_dr = 2;
dr = devm_kcalloc(dev, num_dr, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
dr[0].sink = devm_kasprintf(dev, GFP_KERNEL,
AVS_STRING_FMT("ssp", "pb", ssp_port, tdm_slot));
dr[0].source = devm_kasprintf(dev, GFP_KERNEL,
AVS_STRING_FMT("ssp", " Tx", ssp_port, tdm_slot));
if (!dr[0].sink || !dr[0].source)
return -ENOMEM;
dr[1].sink = devm_kasprintf(dev, GFP_KERNEL,
AVS_STRING_FMT("ssp", " Rx", ssp_port, tdm_slot));
dr[1].source = devm_kasprintf(dev, GFP_KERNEL,
AVS_STRING_FMT("ssp", "cp", ssp_port, tdm_slot));
if (!dr[1].sink || !dr[1].source)
return -ENOMEM;
*routes = dr;
*num_routes = num_dr;
return 0;
}
static int avs_create_dapm_widgets(struct device *dev, int ssp_port, int tdm_slot,
struct snd_soc_dapm_widget **widgets, int *num_widgets)
{
struct snd_soc_dapm_widget *dw;
const int num_dw = 2;
dw = devm_kcalloc(dev, num_dw, sizeof(*dw), GFP_KERNEL);
if (!dw)
return -ENOMEM;
dw[0].id = snd_soc_dapm_hp;
dw[0].reg = SND_SOC_NOPM;
dw[0].name = devm_kasprintf(dev, GFP_KERNEL,
AVS_STRING_FMT("ssp", "pb", ssp_port, tdm_slot));
if (!dw[0].name)
return -ENOMEM;
dw[1].id = snd_soc_dapm_mic;
dw[1].reg = SND_SOC_NOPM;
dw[1].name = devm_kasprintf(dev, GFP_KERNEL,
AVS_STRING_FMT("ssp", "cp", ssp_port, tdm_slot));
if (!dw[1].name)
return -ENOMEM;
*widgets = dw;
*num_widgets = num_dw;
return 0;
}
static int avs_i2s_test_probe(struct platform_device *pdev)
{
struct snd_soc_dapm_widget *widgets;
struct snd_soc_dapm_route *routes;
struct snd_soc_dai_link *dai_link;
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card;
struct device *dev = &pdev->dev;
const char *pname;
int num_routes, num_widgets;
int ssp_port, tdm_slot, ret;
mach = dev_get_platdata(dev);
......@@ -156,26 +93,10 @@ static int avs_i2s_test_probe(struct platform_device *pdev)
return ret;
}
ret = avs_create_dapm_routes(dev, ssp_port, tdm_slot, &routes, &num_routes);
if (ret) {
dev_err(dev, "Failed to create dapm routes: %d\n", ret);
return ret;
}
ret = avs_create_dapm_widgets(dev, ssp_port, tdm_slot, &widgets, &num_widgets);
if (ret) {
dev_err(dev, "Failed to create dapm widgets: %d\n", ret);
return ret;
}
card->dev = dev;
card->owner = THIS_MODULE;
card->dai_link = dai_link;
card->num_links = 1;
card->dapm_routes = routes;
card->num_dapm_routes = num_routes;
card->dapm_widgets = widgets;
card->num_dapm_widgets = num_widgets;
card->fully_routed = true;
ret = snd_soc_fixup_dai_links_platform_name(card, pname);
......
......@@ -37,8 +37,6 @@ static const struct snd_kcontrol_new card_controls[] = {
static const struct snd_soc_dapm_widget card_widgets[] = {
SND_SOC_DAPM_SPK("Left Speaker", NULL),
SND_SOC_DAPM_SPK("Right Speaker", NULL),
SND_SOC_DAPM_SPK("DP1", NULL),
SND_SOC_DAPM_SPK("DP2", NULL),
};
static const struct snd_soc_dapm_route card_base_routes[] = {
......@@ -158,7 +156,7 @@ static int avs_ssm4567_probe(struct platform_device *pdev)
if (!card)
return -ENOMEM;
card->name = "avs_ssm4567-adi";
card->name = "avs_ssm4567";
card->dev = dev;
card->owner = THIS_MODULE;
card->dai_link = dai_link;
......@@ -172,7 +170,6 @@ static int avs_ssm4567_probe(struct platform_device *pdev)
card->dapm_routes = card_base_routes;
card->num_dapm_routes = ARRAY_SIZE(card_base_routes);
card->fully_routed = true;
card->disable_route_checks = true;
ret = snd_soc_fixup_dai_links_platform_name(card, pname);
if (ret)
......
......@@ -768,6 +768,7 @@ static struct snd_soc_card broxton_audio_card = {
.dapm_routes = audio_map,
.num_dapm_routes = ARRAY_SIZE(audio_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = bxt_card_late_probe,
};
......
......@@ -574,6 +574,7 @@ static struct snd_soc_card broxton_rt298 = {
.dapm_routes = broxton_rt298_map,
.num_dapm_routes = ARRAY_SIZE(broxton_rt298_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = bxt_card_late_probe,
};
......
......@@ -649,6 +649,8 @@ static int geminilake_audio_probe(struct platform_device *pdev)
card = &glk_audio_card_rt5682_m98357a;
card->dev = &pdev->dev;
snd_soc_card_set_drvdata(card, ctx);
if (!snd_soc_acpi_sof_parent(&pdev->dev))
card->disable_route_checks = true;
/* override platform name, if required */
mach = pdev->dev.platform_data;
......
......@@ -639,6 +639,7 @@ static struct snd_soc_card kabylake_audio_card_da7219_m98357a = {
.dapm_routes = kabylake_map,
.num_dapm_routes = ARRAY_SIZE(kabylake_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......
......@@ -1036,6 +1036,7 @@ static struct snd_soc_card kbl_audio_card_da7219_m98927 = {
.codec_conf = max98927_codec_conf,
.num_configs = ARRAY_SIZE(max98927_codec_conf),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......@@ -1054,6 +1055,7 @@ static struct snd_soc_card kbl_audio_card_max98927 = {
.codec_conf = max98927_codec_conf,
.num_configs = ARRAY_SIZE(max98927_codec_conf),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......@@ -1071,6 +1073,7 @@ static struct snd_soc_card kbl_audio_card_da7219_m98373 = {
.codec_conf = max98373_codec_conf,
.num_configs = ARRAY_SIZE(max98373_codec_conf),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......@@ -1088,6 +1091,7 @@ static struct snd_soc_card kbl_audio_card_max98373 = {
.codec_conf = max98373_codec_conf,
.num_configs = ARRAY_SIZE(max98373_codec_conf),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......
......@@ -518,6 +518,7 @@ static struct snd_soc_card kabylake_audio_card_rt5660 = {
.dapm_routes = kabylake_rt5660_map,
.num_dapm_routes = ARRAY_SIZE(kabylake_rt5660_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......
......@@ -966,6 +966,7 @@ static struct snd_soc_card kabylake_audio_card_rt5663_m98927 = {
.codec_conf = max98927_codec_conf,
.num_configs = ARRAY_SIZE(max98927_codec_conf),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......@@ -982,6 +983,7 @@ static struct snd_soc_card kabylake_audio_card_rt5663 = {
.dapm_routes = kabylake_5663_map,
.num_dapm_routes = ARRAY_SIZE(kabylake_5663_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......
......@@ -791,6 +791,7 @@ static struct snd_soc_card kabylake_audio_card = {
.codec_conf = max98927_codec_conf,
.num_configs = ARRAY_SIZE(max98927_codec_conf),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = kabylake_card_late_probe,
};
......
......@@ -227,6 +227,8 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
hda_soc_card.dev = &pdev->dev;
if (!snd_soc_acpi_sof_parent(&pdev->dev))
hda_soc_card.disable_route_checks = true;
if (mach->mach_params.dmic_num > 0) {
snprintf(hda_soc_components, sizeof(hda_soc_components),
......
......@@ -654,6 +654,7 @@ static struct snd_soc_card skylake_audio_card = {
.dapm_routes = skylake_map,
.num_dapm_routes = ARRAY_SIZE(skylake_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = skylake_card_late_probe,
};
......
......@@ -523,6 +523,7 @@ static struct snd_soc_card skylake_rt286 = {
.dapm_routes = skylake_rt286_map,
.num_dapm_routes = ARRAY_SIZE(skylake_rt286_map),
.fully_routed = true,
.disable_route_checks = true,
.late_probe = skylake_card_late_probe,
};
......
......@@ -1083,8 +1083,15 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
break;
}
/* add route, but keep going if some fail */
snd_soc_dapm_add_routes(dapm, route, 1);
ret = snd_soc_dapm_add_routes(dapm, route, 1);
if (ret) {
if (!dapm->card->disable_route_checks) {
dev_err(tplg->dev, "ASoC: dapm_add_routes failed: %d\n", ret);
break;
}
dev_info(tplg->dev,
"ASoC: disable_route_checks set, ignoring dapm_add_routes errors\n");
}
}
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment