linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] ASoC: dai playback_active and capture_active may be greater than 1
@ 2018-04-19 14:06 Jerome Brunet
  2018-04-30 15:10 ` [alsa-devel] " Charles Keepax
  2018-05-01 21:07 ` Applied "ASoC: dai playback and capture active may be greater than 1" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Jerome Brunet @ 2018-04-19 14:06 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Kevin Hilman

At the moment playback_active and capture_active are using only 1 bit so
the maximum active count is 1.

However, snd_soc_runtime_activate() may be called several time on the
same dai. This happens when a dai is part of several dai_links. It is
often the case for "snd-soc-dummy-dai".

This is a problem if snd_soc_runtime_activate() is called an even number
of times on a dai. In this case the active count overflow back to 0. As
consequence, ASoC functions, such as soc_dpcm_runtime_update(), won't run
correctly.

Storing these usage counts on plain 'unsigned int' solves the problem.

Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---

Hi,

I found this problem while working on ASoC support for a new platform.
During a playback, using DPCM, if I changed the backend dai, nothing
happened, old backend path was not pruned, new backend path was not added.

Here is how it goes:
1 FE and 2 BE, all 3 using snd-soc-dummy-dai for the codec_dai (ATM).

On playback start:
 - BE #1 activates and increments snd-soc-dummy-dai's playback_active
 - FE activates and increments snd-soc-dummy-dai's playback_active

The playback works but snd-soc-dummy-dai's playback_active value is now 0.

Through a mux kcontrol, change BE client of FE, from BE #1 to BE #2.
 -> trigger soc_dpcm_runtime_update().
    -> checks fe's codec_dai playback_active which is zero so playback
    path processing is skipped, keeping the old invalid path.

 include/sound/soc-dai.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 8ad11669e4d8..35ebb0be5114 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -294,8 +294,8 @@ struct snd_soc_dai {
 	struct snd_soc_dai_driver *driver;
 
 	/* DAI runtime info */
-	unsigned int capture_active:1;		/* stream is in use */
-	unsigned int playback_active:1;		/* stream is in use */
+	unsigned int capture_active;		/* stream usage count */
+	unsigned int playback_active;		/* stream usage count */
 	unsigned int probed:1;
 
 	unsigned int active;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH RFC] ASoC: dai playback_active and capture_active may be greater than 1
  2018-04-19 14:06 [PATCH RFC] ASoC: dai playback_active and capture_active may be greater than 1 Jerome Brunet
@ 2018-04-30 15:10 ` Charles Keepax
  2018-05-01 21:07 ` Applied "ASoC: dai playback and capture active may be greater than 1" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2018-04-30 15:10 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: Mark Brown, Liam Girdwood, Kevin Hilman, alsa-devel, linux-kernel

On Thu, Apr 19, 2018 at 04:06:12PM +0200, Jerome Brunet wrote:
> At the moment playback_active and capture_active are using only 1 bit so
> the maximum active count is 1.
> 
> However, snd_soc_runtime_activate() may be called several time on the
> same dai. This happens when a dai is part of several dai_links. It is
> often the case for "snd-soc-dummy-dai".
> 
> This is a problem if snd_soc_runtime_activate() is called an even number
> of times on a dai. In this case the active count overflow back to 0. As
> consequence, ASoC functions, such as soc_dpcm_runtime_update(), won't run
> correctly.
> 
> Storing these usage counts on plain 'unsigned int' solves the problem.
> 
> Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support")
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "ASoC: dai playback and capture active may be greater than 1" to the asoc tree
  2018-04-19 14:06 [PATCH RFC] ASoC: dai playback_active and capture_active may be greater than 1 Jerome Brunet
  2018-04-30 15:10 ` [alsa-devel] " Charles Keepax
@ 2018-05-01 21:07 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2018-05-01 21:07 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: Mark Brown, Mark Brown, Liam Girdwood, Kevin Hilman, alsa-devel,
	linux-kernel, alsa-devel

The patch

   ASoC: dai playback and capture active may be greater than 1

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 40c57963789d451c26269e3bc9f9e803060fd9af Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 27 Apr 2018 13:31:51 +0200
Subject: [PATCH] ASoC: dai playback and capture active may be greater than 1

At the moment playback_active and capture_active are using only 1 bit so
the maximum active count is 1.

However, snd_soc_runtime_activate() may be called several time on the
same dai. This happens when a dai is part of several dai_links. It is
often the case for "snd-soc-dummy-dai".

This is a problem if snd_soc_runtime_activate() is called an even number
of times on a dai. In this case the active count overflow back to 0. As
consequence, ASoC functions, such as soc_dpcm_runtime_update(), won't run
correctly.

Storing these usage counts on plain 'unsigned int' solves the problem.

Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/sound/soc-dai.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 8ad11669e4d8..35ebb0be5114 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -294,8 +294,8 @@ struct snd_soc_dai {
 	struct snd_soc_dai_driver *driver;
 
 	/* DAI runtime info */
-	unsigned int capture_active:1;		/* stream is in use */
-	unsigned int playback_active:1;		/* stream is in use */
+	unsigned int capture_active;		/* stream usage count */
+	unsigned int playback_active;		/* stream usage count */
 	unsigned int probed:1;
 
 	unsigned int active;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-01 21:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19 14:06 [PATCH RFC] ASoC: dai playback_active and capture_active may be greater than 1 Jerome Brunet
2018-04-30 15:10 ` [alsa-devel] " Charles Keepax
2018-05-01 21:07 ` Applied "ASoC: dai playback and capture active may be greater than 1" to the asoc tree Mark Brown

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).