[PATCH] ASoC: qcom: common: setup fe dais before be dais
From: Srinivas Kandagatla
Date: Tue Sep 22 2026 - 17:21:22 EST
qcom_snd_parse_of() registers DAI links in the devicetree order of
the sound{} child nodes. q6routing wires static routes such as
"MM_DL1" -> "MultiMedia1" -> "HDMI Mixer"
which need the frontend (MultiMediaN) widgets to exist before the
backend widgets that reference them. This is a latent ordering
bug: any devicetree or overlay that lists a backend node before
its matching frontend trips it with
q6routing ...routing: ASoC: Failed to add route MM_DL1(*) ->
[MultiMedia1] -> HDMI Mixer
q6routing ...routing: ASoC: Failed to add route MM_DL2(*) ->
[MultiMedia2] -> HDMI Mixer
...
and today it is easily triggered just by reordering the sound{}
children, or by an overlay that appends a backend link.
Iterate the children twice, frontends (no codec child) first and
backends (codec child) after, so frontend PCM DAIs are always
registered before the backends. Per-node setup is moved into a
new qcom_snd_setup_dai_link() helper so both passes are identical;
cards where every child has a codec child (non-DPCM) hit only the
second pass and see no change.
Fixes: c25e295cd77b ("ASoC: qcom: Add support to parse common audio
device nodes")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxxxxxxxx>
---
sound/soc/qcom/common.c | 182 ++++++++++++++++++++++++----------------
1 file changed, 109 insertions(+), 73 deletions(-)
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index 83b745f617a8..4e0541c3db42 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -178,12 +178,104 @@ int qcom_snd_apply_dai_tdm_slots(struct
snd_soc_pcm_runtime *rtd)
}
EXPORT_SYMBOL_GPL(qcom_snd_apply_dai_tdm_slots);
+static int qcom_snd_setup_dai_link(struct snd_soc_card *card,
+ struct snd_soc_dai_link *link,
+ struct device_node *np)
+{
+ struct device *dev = card->dev;
+ struct snd_soc_dai_link_component *dlc;
+ struct of_phandle_args args;
+ int ret;
+
+ dlc = devm_kcalloc(dev, 2, sizeof(*dlc), GFP_KERNEL);
+ if (!dlc)
+ return -ENOMEM;
+
+ link->cpus = &dlc[0];
+ link->platforms = &dlc[1];
+
+ link->num_cpus = 1;
+ link->num_platforms = 1;
+
+ ret = of_property_read_string(np, "link-name", &link->name);
+ if (ret) {
+ dev_err(dev, "error getting codec dai_link name\n");
+ return ret;
+ }
+
+ struct device_node *cpu __free(device_node) =
+ of_get_child_by_name(np, "cpu");
+ struct device_node *platform __free(device_node) =
+ of_get_child_by_name(np, "platform");
+ struct device_node *codec __free(device_node) =
+ of_get_child_by_name(np, "codec");
+
+ if (!cpu) {
+ dev_err(dev, "%s: Can't find cpu DT node\n", link->name);
+ return -EINVAL;
+ }
+
+ ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
+ if (ret) {
+ dev_err_probe(dev, ret,
+ "%s: error getting cpu dai name\n", link->name);
+ return ret;
+ }
+
+ link->id = args.args[0];
+
+ if (link->id >= LPASS_MAX_PORT) {
+ dev_err(dev, "%s: Invalid cpu dai id %d\n", link->name, link->id);
+ return -EINVAL;
+ }
+
+ if (platform) {
+ link->platforms->of_node = of_parse_phandle(platform,
+ "sound-dai",
+ 0);
+ if (!link->platforms->of_node) {
+ dev_err(dev, "%s: platform dai not found\n", link->name);
+ return -EINVAL;
+ }
+ } else {
+ link->platforms->of_node = link->cpus->of_node;
+ }
+
+ if (codec) {
+ ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
+ if (ret < 0) {
+ dev_err_probe(dev, ret,
+ "%s: codec dai not found\n", link->name);
+ return ret;
+ }
+
+ if (platform) {
+ /* DPCM backend */
+ link->no_pcm = 1;
+ link->ignore_pmdown_time = 1;
+ }
+ } else {
+ /* DPCM frontend */
+ link->codecs = &snd_soc_dummy_dlc;
+ link->num_codecs = 1;
+ link->dynamic = 1;
+ }
+
+ if (platform || !codec) {
+ /* DPCM */
+ link->ignore_suspend = 1;
+ link->nonatomic = 1;
+ }
+
+ link->stream_name = link->name;
+
+ return 0;
+}
+
int qcom_snd_parse_of(struct snd_soc_card *card)
{
struct device *dev = card->dev;
struct snd_soc_dai_link *link;
- struct of_phandle_args args;
- struct snd_soc_dai_link_component *dlc;
int ret, num_links;
ret = snd_soc_of_parse_card_name(card, "model");
@@ -233,88 +325,32 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
card->num_links = num_links;
link = card->dai_link;
+ /* Register frontends first so q6routing can resolve BE targets. */
for_each_available_child_of_node_scoped(dev->of_node, np) {
- dlc = devm_kcalloc(dev, 2, sizeof(*dlc), GFP_KERNEL);
- if (!dlc)
- return -ENOMEM;
-
- link->cpus = &dlc[0];
- link->platforms = &dlc[1];
-
- link->num_cpus = 1;
- link->num_platforms = 1;
-
- ret = of_property_read_string(np, "link-name", &link->name);
- if (ret) {
- dev_err(dev, "error getting codec dai_link name\n");
- return ret;
- }
-
- struct device_node *cpu __free(device_node) =
- of_get_child_by_name(np, "cpu");
- struct device_node *platform __free(device_node) =
- of_get_child_by_name(np, "platform");
struct device_node *codec __free(device_node) =
of_get_child_by_name(np, "codec");
- if (!cpu) {
- dev_err(dev, "%s: Can't find cpu DT node\n", link->name);
- return -EINVAL;
- }
+ if (codec)
+ continue;
- ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
- if (ret) {
- dev_err_probe(dev, ret,
- "%s: error getting cpu dai name\n", link->name);
+ ret = qcom_snd_setup_dai_link(card, link, np);
+ if (ret)
return ret;
- }
- link->id = args.args[0];
-
- if (link->id >= LPASS_MAX_PORT) {
- dev_err(dev, "%s: Invalid cpu dai id %d\n", link->name, link->id);
- return -EINVAL;
- }
-
- if (platform) {
- link->platforms->of_node = of_parse_phandle(platform,
- "sound-dai",
- 0);
- if (!link->platforms->of_node) {
- dev_err(dev, "%s: platform dai not found\n", link->name);
- return -EINVAL;
- }
- } else {
- link->platforms->of_node = link->cpus->of_node;
- }
+ link++;
+ }
- if (codec) {
- ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
- if (ret < 0) {
- dev_err_probe(dev, ret,
- "%s: codec dai not found\n", link->name);
- return ret;
- }
+ for_each_available_child_of_node_scoped(dev->of_node, np) {
+ struct device_node *codec __free(device_node) =
+ of_get_child_by_name(np, "codec");
- if (platform) {
- /* DPCM backend */
- link->no_pcm = 1;
- link->ignore_pmdown_time = 1;
- }
- } else {
- /* DPCM frontend */
- link->codecs = &snd_soc_dummy_dlc;
- link->num_codecs = 1;
- link->dynamic = 1;
- }
+ if (!codec)
+ continue;
- if (platform || !codec) {
- /* DPCM */
- link->ignore_suspend = 1;
- link->nonatomic = 1;
- }
+ ret = qcom_snd_setup_dai_link(card, link, np);
+ if (ret)
+ return ret;
- link->stream_name = link->name;
link++;
}
--
2.53.0
------------------------------->cut<--------------------------------
> arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts | 47 +++++++++++-----------
> 1 file changed, 24 insertions(+), 23 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts b/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts
> index e99d2a56dc28..3efd80f36c6c 100644
> --- a/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts
> +++ b/arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts
> @@ -117,6 +117,30 @@ sound {
> "IN2_HPHR", "HPHR_OUT",
> "AMIC2", "MIC BIAS2";
>
> + mm1-dai-link {
> + link-name = "MultiMedia1";
> +
> + cpu {
> + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>;
> + };
> + };
> +
> + mm2-dai-link {
> + link-name = "MultiMedia2";
> +
> + cpu {
> + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA2>;
> + };
> + };
> +
> + mm3-dai-link {
> + link-name = "MultiMedia3";
> +
> + cpu {
> + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA3>;
> + };
> + };
> +
> ear-playback-dai-link {
> link-name = "Ear Out Playback";
>
> @@ -181,29 +205,6 @@ platform {
> };
> };
>
> - mm1-dai-link {
> - link-name = "MultiMedia1";
> -
> - cpu {
> - sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>;
> - };
> - };
> -
> - mm2-dai-link {
> - link-name = "MultiMedia2";
> -
> - cpu {
> - sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA2>;
> - };
> - };
> -
> - mm3-dai-link {
> - link-name = "MultiMedia3";
> -
> - cpu {
> - sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA3>;
> - };
> - };
> };
>
> vreg_anx_30: regulator-anx-30 {
>
> ---
> base-commit: eac8f0411262ea7d156407da4baf260291cbfe32
> change-id: 20261114-imola-sound-link-order-15de4692e7ef
>
> Best regards,