[alsa-devel] Question about topology component probing

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Wed May 29 09:44:05 CEST 2019


Hi ALSA ML, again

> Hmm... it seems my brain is broken today... (not only today ?)
> Previous mail is mixing unrelated things...
> Please ignore it.

My spaghetti head becoming better, I believe.
Then, I could sorting the question, thus, I renamed the Subject.

I wonder about topology component doesn't need probing ?

(1) snd_soc_instantiate_card() binds all (normal) components
(2) And binded components will be probed.
(3) Some components with topology might be added
(4) Find new (= topology added) DAI and bind them

	static int snd_soc_instantiate_card(struct snd_soc_card *card)
	{
		...
		/* probe normal components here */
		for_each_card_prelinks(card, i, dai_link) {
(1)=>			ret = soc_bind_dai_link(card, dai_link);
			if (ret != 0)
				goto probe_end;
		}
		...
		/* add predefined DAI links to the list */
		for_each_card_prelinks(card, i, dai_link)
(A)=>			snd_soc_add_dai_link(card, dai_link);
		...
		/* probe all components used by DAI links on this card */
		for_each_comp_order(order) {
			for_each_card_rtds(card, rtd) {
(2)=>				ret = soc_probe_link_components(card, rtd, order);
				...
				}
			}
		}
		...
		/* initialise the sound card only once */
		if (card->probe) {
(3)=>			ret = card->probe(card);
			if (ret < 0)
				goto probe_end;
		}
		...

		for_each_card_links(card, dai_link) {
			...
(4)=>			ret = soc_bind_dai_link(card, dai_link);
			...
		}
		...
	}

But, In my understanding, normal components are probed,
but topology added components are not probed, because
no one calls soc_probe_link_components() after (4).
Does topology added components doesn't need probe ?

It is checking the added component is already connected to card, or not.
And it is calling try_module_get() for it.
Currently, topology added component is no check for these, I think.

This is very confusable for now
(= I have plan to post cleanup patch around here...)
so the pseudo code is like this

	(1) normal component bind
	(A) connect normal dai_link to card
	(2) normal component probe
	(3) topology might connect dai_link to card
	(4) bind all component via card connected dai_link.
	    But, the real target is topology added component.
	(x) topology component probe is not called

Here, (A) connects dai_link to card.
This it is used here and from topology (3).
This means, (1) and (4) can be merged, and all
(= both normal and topology added) component can be probed
if we can re-order like

	(A) connect normal dai_link to card
	(3) topology might connect dai_link to card
	(4) bind all component via card connected dai_link.
	(2) all component probe

It works for me, but my board doesn't use topology.
So I'm not sure topology side things.

So my questions are

	Q1 topology added component shouldn't be probed ?
	Q2 normal component should be added before card probe / topology (= (3)) ?

Or in other works, does attached patch works well under topology ?

-----------------
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2403bec..e3fce07 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2075,13 +2075,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	/* check whether any platform is ignore machine FE and using topology */
 	soc_check_tplg_fes(card);
 
-	/* bind DAIs */
-	for_each_card_prelinks(card, i, dai_link) {
-		ret = soc_bind_dai_link(card, dai_link);
-		if (ret != 0)
-			goto probe_end;
-	}
-
 	/* bind aux_devs too */
 	for (i = 0; i < card->num_aux_devs; i++) {
 		ret = soc_bind_aux_dev(card, i);
@@ -2129,6 +2122,22 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 			goto probe_end;
 	}
 
+	/*
+	 * Find new DAI links added during probing components and bind them.
+	 * Components with topology may bring new DAIs and DAI links.
+	 */
+	for_each_card_links(card, dai_link) {
+		if (soc_is_dai_link_bound(card, dai_link))
+			continue;
+
+		ret = soc_init_dai_link(card, dai_link);
+		if (ret)
+			goto probe_end;
+		ret = soc_bind_dai_link(card, dai_link);
+		if (ret)
+			goto probe_end;
+	}
+
 	/* probe all components used by DAI links on this card */
 	for_each_comp_order(order) {
 		for_each_card_rtds(card, rtd) {
@@ -2147,22 +2156,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	if (ret < 0)
 		goto probe_end;
 
-	/*
-	 * Find new DAI links added during probing components and bind them.
-	 * Components with topology may bring new DAIs and DAI links.
-	 */
-	for_each_card_links(card, dai_link) {
-		if (soc_is_dai_link_bound(card, dai_link))
-			continue;
-
-		ret = soc_init_dai_link(card, dai_link);
-		if (ret)
-			goto probe_end;
-		ret = soc_bind_dai_link(card, dai_link);
-		if (ret)
-			goto probe_end;
-	}
-
 	/* probe all DAI links on this card */
 	for_each_comp_order(order) {
 		for_each_card_rtds(card, rtd) {
-----------------

Thank you for your help !!
Best regards
---
Kuninori Morimoto


More information about the Alsa-devel mailing list