Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
	tiwai@suse.com, perex@perex.cz,
	amadeuszx.slawinski@linux.intel.com,
	pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com,
	Cezary Rojewski <cezary.rojewski@intel.com>
Subject: [PATCH v2 2/5] ASoC: topology: Do not ignore route checks when parsing graphs
Date: Fri,  8 Mar 2024 10:04:59 +0100	[thread overview]
Message-ID: <20240308090502.2136760-3-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20240308090502.2136760-1-cezary.rojewski@intel.com>

One of the framework responsibilities is to ensure that the enumerated
DPCMs are valid i.e.: a valid BE is connected to a valid FE DAI. While
the are checks in soc-core.c and soc-pcm.c that verify this, a component
driver may attempt to workaround this by loading an invalid graph
through the topology file.

Be strict and fail topology loading when invalid graph is encountered.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/soc-topology.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index d6d368837235..90ca37e008b3 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -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;
-- 
2.25.1


  parent reply	other threads:[~2024-03-08  9:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08  9:04 [PATCH v2 0/5] ASoC: Harden DAPM route checks and Intel fixes Cezary Rojewski
2024-03-08  9:04 ` [PATCH v2 1/5] ASoC: Intel: Disable route checks for Skylake boards Cezary Rojewski
2024-03-23  1:42   ` Pierre-Louis Bossart
2024-03-08  9:04 ` Cezary Rojewski [this message]
2024-03-23  1:42   ` [PATCH v2 2/5] ASoC: topology: Do not ignore route checks when parsing graphs Pierre-Louis Bossart
2024-03-08  9:05 ` [PATCH v2 3/5] ASoC: Intel: avs: ssm4567: Do not ignore route checks Cezary Rojewski
2024-03-08  9:05 ` [PATCH v2 4/5] ASoC: Intel: avs: ssm4567: Board cleanup Cezary Rojewski
2024-03-08  9:05 ` [PATCH v2 5/5] ASoC: Intel: avs: i2s_test: Remove redundant dapm routes Cezary Rojewski
2024-03-26 15:27 ` [PATCH v2 0/5] ASoC: Harden DAPM route checks and Intel fixes 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=20240308090502.2136760-3-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    /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