All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, liam.r.girdwood@linux.intel.com,
	broonie@kernel.org, pierre-louis.bossart@linux.intel.com
Subject: [RFC PATCH 3/3] ASoC: core: remove link components before cleaning up card resources
Date: Thu,  4 Apr 2019 17:30:40 -0700	[thread overview]
Message-ID: <20190405003040.8709-4-ranjani.sridharan@linux.intel.com> (raw)
In-Reply-To: <20190405003040.8709-1-ranjani.sridharan@linux.intel.com>

When the card is registered by the machine driver,
dai link components are probed after the snd_card is
created. This is done in snd_soc_bind_card() which calls
snd_soc_instantiate_card() to first create the snd_card
and then probes the link components by calling
soc_probe_link_components(). The snd_card is used by the
component driver to add the kcontrols associated
with dapm widgets to the card.

When the machine driver is unregistered, the snd_card
is freed when the card resources are cleaned up.
But the snd_card needs to be valid while unloading the
topology dapm widgets in order to remove the kcontrols
from the card.

Since, unloading topology is done when the component
driver is removed, the link components should be removed
in snd_soc_unbind_card(). This will ensure that the kcontrols
are removed before the card resources are cleaned up and
the snd_card itself is freed.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/soc/soc-core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ffd4db97a2ee..6277b2da68b7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2831,10 +2831,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
 
 static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
 {
+	struct snd_soc_pcm_runtime *rtd;
+	int order;
+
 	if (card->instantiated) {
 		card->instantiated = false;
 		snd_soc_dapm_shutdown(card);
 		snd_soc_flush_all_delayed_work(card);
+
+		/* remove all components used by DAI links on this card */
+		for_each_comp_order(order) {
+			for_each_card_rtds(card, rtd) {
+				soc_remove_link_components(card, rtd, order);
+			}
+		}
+
 		soc_cleanup_card_resources(card);
 		if (!unregister)
 			list_add(&card->list, &unbind_card_list);
-- 
2.17.1

  parent reply	other threads:[~2019-04-05  0:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-05  0:30 [RFC PATCH 0/3] Fixes for component unregister and remove Ranjani Sridharan
2019-04-05  0:30 ` [RFC PATCH 1/3] ASoC: core: do not unload topology in unregister_component() Ranjani Sridharan
2019-04-05  2:17   ` Mark Brown
2019-04-05  2:23     ` Ranjani Sridharan
2019-04-05  2:28       ` Mark Brown
2019-04-05  2:33         ` Ranjani Sridharan
2019-04-05  2:36           ` Mark Brown
2019-04-05  0:30 ` [RFC PATCH 2/3] ASoC: intel: skylake: add remove() callback for component driver Ranjani Sridharan
2019-04-05  2:43   ` Applied "ASoC: intel: skylake: add remove() callback for component driver" to the asoc tree Mark Brown
2019-04-05  0:30 ` Ranjani Sridharan [this message]
2019-04-05  2:43   ` Applied "ASoC: core: remove link components before cleaning up card resources" " 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=20190405003040.8709-4-ranjani.sridharan@linux.intel.com \
    --to=ranjani.sridharan@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.