alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	broonie@kernel.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [RFC PATCH 1/3] ASoC: soc-core: introduce exit() callback for dailinks
Date: Thu,  5 Mar 2020 07:06:14 -0600	[thread overview]
Message-ID: <20200305130616.28658-2-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20200305130616.28658-1-pierre-louis.bossart@linux.intel.com>

Some machine drivers allocate or request resources during the init()
phase, which need to be released at some point, e.g. when rebooting or
unloading modules.

In an initial pass, we added a .remove() callback for the platform
driver, but that's not symmetrical at all and would be difficult to
handle if there are more than one dailink implementing an .init().

We looked also into using .remove_dai_link() callback, but that would
also be imlanced.

The suggested solution is to use a dual exit() phase for dailinks to
release all resources.

The exit() is invoked in soc_free_pcm_runtime(), which is not
completely symmetric with the init() invoked in soc_init_pcm_runtime()
- not soc_add_pcm_runtime(), but that's the best solution so far.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 include/sound/soc.h  | 3 +++
 sound/soc/soc-core.c | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 81e5d17be935..2beebe89ebbc 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -794,6 +794,9 @@ struct snd_soc_dai_link {
 	/* codec/machine specific init - e.g. add machine controls */
 	int (*init)(struct snd_soc_pcm_runtime *rtd);
 
+	/* codec/machine specific exit - dual of init() */
+	void (*exit)(struct snd_soc_pcm_runtime *rtd);
+
 	/* optional hw_params re-writing for BE and FE sync */
 	int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
 			struct snd_pcm_hw_params *params);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f2cfbf182f49..09a0976d6a62 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -937,8 +937,14 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card,
 void snd_soc_remove_pcm_runtime(struct snd_soc_card *card,
 				struct snd_soc_pcm_runtime *rtd)
 {
+	struct snd_soc_dai_link *dai_link = rtd->dai_link;
+
 	lockdep_assert_held(&client_mutex);
 
+	/* release machine specific resources */
+	if (dai_link->exit)
+		dai_link->exit(rtd);
+
 	/*
 	 * Notify the machine driver for extra destruction
 	 */
@@ -1069,7 +1075,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 	/* set default power off timeout */
 	rtd->pmdown_time = pmdown_time;
 
-	/* do machine specific initialization */
+	/* do machine specific allocations and initialization */
 	if (dai_link->init) {
 		ret = dai_link->init(rtd);
 		if (ret < 0) {
-- 
2.20.1


  reply	other threads:[~2020-03-05 13:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 13:06 [RFC PATCH 0/3] ASoC: add dailink .exit() callback Pierre-Louis Bossart
2020-03-05 13:06 ` Pierre-Louis Bossart [this message]
2020-03-05 18:15   ` [RFC PATCH 1/3] ASoC: soc-core: introduce exit() callback for dailinks Mark Brown
2020-03-05 13:06 ` [RFC PATCH 2/3] ASoC: Intel: bdw-rt5677: fix module load/unload issues Pierre-Louis Bossart
2020-03-05 13:25   ` Andy Shevchenko
2020-03-05 13:37     ` Pierre-Louis Bossart
2020-03-05 13:36   ` Mark Brown
2020-03-05 13:47     ` Pierre-Louis Bossart
2020-03-05 13:59       ` Mark Brown
2020-03-05 14:51         ` Pierre-Louis Bossart
2020-03-05 17:43           ` Mark Brown
2020-03-05 18:08             ` Pierre-Louis Bossart
2020-03-05 18:33               ` Mark Brown
2020-03-05 19:10                 ` Mark Brown
2020-03-05 21:00                   ` Curtis Malainey
2020-03-05 21:48                   ` Pierre-Louis Bossart
2020-03-06 13:12                     ` Mark Brown
2020-03-05 14:06       ` Amadeusz Sławiński
2020-03-05 14:11         ` Mark Brown
2020-03-05 14:27       ` Andy Shevchenko
2020-03-05 17:58         ` Mark Brown
2020-03-05 13:06 ` [RFC PATCH 3/3] ASoC: Intel: kbl-rt5660: use .exit() dailink callback to release gpiod Pierre-Louis Bossart
2020-03-05 13:27   ` Andy Shevchenko

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=20200305130616.28658-2-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).