[alsa-devel] [PATCH 0/2] ASoC: snd_soc_disconnect_sync()
Hi Mark, Takashi-san
ALSA is now have snd_card_disconnect_sync() on Takashi-san's topic/card-disconnect branch.
These are ASoC version of it, and Renesas sound driver uses it. Otherwise, kernel will be Oops if unbinded during playback.
Kuninori Morimoto (2): ASoC: add snd_soc_disconnect_sync() ASoC: rsnd: call snd_soc_disconnect_sync() when remove
include/sound/soc.h | 2 ++ sound/soc/sh/rcar/core.c | 2 ++ sound/soc/soc-core.c | 10 ++++++++++ 3 files changed, 14 insertions(+)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now, we have snd_card_disconnect_sync() on ALSA framwork. snd_soc_disconnect_sync() is ASoC version of it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 3a15cce..7b9b615 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -494,6 +494,8 @@ int snd_soc_platform_write(struct snd_soc_platform *platform, int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num); #endif
+void snd_soc_disconnect_sync(struct device *dev); + struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, const char *dai_link, int stream); struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c0edac8..9047046 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1392,6 +1392,16 @@ static int soc_init_dai_link(struct snd_soc_card *card, return 0; }
+void snd_soc_disconnect_sync(struct device *dev) +{ + struct snd_soc_component *component = snd_soc_lookup_component(dev, NULL); + + if (!component || !component->card) + return; + + snd_card_disconnect_sync(component->card->snd_card); +} + /** * snd_soc_add_dai_link - Add a DAI link dynamically * @card: The ASoC card to which the DAI link is added
The patch
ASoC: add snd_soc_disconnect_sync()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From ef2e8175eb19011f756469d4d14f4207bf7f289c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 28 Nov 2017 06:27:09 +0000 Subject: [PATCH] ASoC: add snd_soc_disconnect_sync()
Now, we have snd_card_disconnect_sync() on ALSA framework. snd_soc_disconnect_sync() is ASoC version of it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 1a7323238c49..22f479e1da0a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -494,6 +494,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num); #endif
+void snd_soc_disconnect_sync(struct device *dev); + struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, const char *dai_link, int stream); struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c0edac80df34..9047046c749c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1392,6 +1392,16 @@ static int soc_init_dai_link(struct snd_soc_card *card, return 0; }
+void snd_soc_disconnect_sync(struct device *dev) +{ + struct snd_soc_component *component = snd_soc_lookup_component(dev, NULL); + + if (!component || !component->card) + return; + + snd_card_disconnect_sync(component->card->snd_card); +} + /** * snd_soc_add_dai_link - Add a DAI link dynamically * @card: The ASoC card to which the DAI link is added
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Renesas R-Car sound driver should be stopped if unbinded during playbacking/capturing. Otherwise clock open/close counter mismatch happen.
One note is that we can't skip from remove function (= return -Exxx) in such case if user used unbind. Because unbind function doesn't check return value from each driver's remove function. This means we must to stop and remove driver in remove function.
Now ASoC has snd_soc_disconnect_sync() for this purpose. Let's use it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/core.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index c70eb20..7f1ffdc 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1496,6 +1496,8 @@ static int rsnd_remove(struct platform_device *pdev) }; int ret = 0, i;
+ snd_soc_disconnect_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev);
for_each_rsnd_dai(rdai, priv, i) {
The patch
ASoC: rsnd: call snd_soc_disconnect_sync() when remove
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 180d9ef58104dfae78622d01910b9b7756701134 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 6 Nov 2017 08:41:37 +0000 Subject: [PATCH] ASoC: rsnd: call snd_soc_disconnect_sync() when remove
Renesas R-Car sound driver should be stopped if unbinded during playbacking/capturing. Otherwise clock open/close counter mismatch happen.
One note is that we can't skip from remove function (= return -Exxx) in such case if user used unbind. Because unbind function doesn't check return value from each driver's remove function. This means we must to stop and remove driver in remove function.
Now ASoC has snd_soc_disconnect_sync() for this purpose. Let's use it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/sh/rcar/core.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index f12a88a21dfa..bd64dc6ec1c3 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1496,6 +1496,8 @@ static int rsnd_remove(struct platform_device *pdev) }; int ret = 0, i;
+ snd_soc_disconnect_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev);
for_each_rsnd_dai(rdai, priv, i) {
participants (2)
-
Kuninori Morimoto
-
Mark Brown