All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error
       [not found] <CGME20210407041405epcas2p10649545662a5441230a3066481755cd0@epcas2p1.samsung.com>
@ 2021-04-07  4:14 ` Gyeongtaek Lee
  2021-04-09 16:22   ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Gyeongtaek Lee @ 2021-04-07  4:14 UTC (permalink / raw)
  To: 'Kuninori Morimoto', cpgs
  Cc: alsa-devel, khw0178.kim, 'Takashi Iwai',
	broonie, 'Pierre-Louis Bossart',
	lgirdwood, kimty, donggyun.ko, hmseo, cpgs, s47.kang,
	pilsun.jang, tkjung

If panic_on_warn=1 is added in bootargs and compress offload playback with
DPCM is started, kernel panic would be occurred because rtd->card->pcm_mutex
isn't held in soc_compr_open_fe() and soc_compr_free_fe() and it generates
lockdep warning in the following code.

void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
			    int stream, int action)
{
	struct snd_soc_dai *dai;
	int i;

	lockdep_assert_held(&rtd->card->pcm_mutex);

To prevent lockdep warning but minimize side effect by adding mutex,
pcm_mutex is held just before snd_soc_runtime_activate() and
snd_soc_runtime_deactivate() and is released right after them.

Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
---
 sound/soc/soc-compress.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 246a5e32e22a..b4810266f5e5 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -153,7 +153,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
 	fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
 
+	mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass);
 	snd_soc_runtime_activate(fe, stream);
+	mutex_unlock(&fe->card->pcm_mutex);
 
 	mutex_unlock(&fe->card->mutex);
 
@@ -181,7 +183,9 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 
 	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
 
+	mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass);
 	snd_soc_runtime_deactivate(fe, stream);
+	mutex_unlock(&fe->card->pcm_mutex);
 
 	fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
 

base-commit: e49d033bddf5b565044e2abe4241353959bc9120
-- 
2.21.0



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

* Re: [PATCH] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error
  2021-04-07  4:14 ` [PATCH] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error Gyeongtaek Lee
@ 2021-04-09 16:22   ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2021-04-09 16:22 UTC (permalink / raw)
  To: 'Kuninori Morimoto', cpgs, Gyeongtaek Lee
  Cc: alsa-devel, khw0178.kim, kimty, 'Pierre-Louis Bossart',
	lgirdwood, 'Takashi Iwai',
	Mark Brown, hmseo, donggyun.ko, tkjung, pilsun.jang, s47.kang

On Wed, 7 Apr 2021 13:14:04 +0900, Gyeongtaek Lee wrote:
> If panic_on_warn=1 is added in bootargs and compress offload playback with
> DPCM is started, kernel panic would be occurred because rtd->card->pcm_mutex
> isn't held in soc_compr_open_fe() and soc_compr_free_fe() and it generates
> lockdep warning in the following code.
> 
> void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
> 			    int stream, int action)
> {
> 	struct snd_soc_dai *dai;
> 	int i;
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error
      commit: 45475bf60cc1d42da229a0aa757180c88bab8d22

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

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

end of thread, other threads:[~2021-04-09 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210407041405epcas2p10649545662a5441230a3066481755cd0@epcas2p1.samsung.com>
2021-04-07  4:14 ` [PATCH] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error Gyeongtaek Lee
2021-04-09 16:22   ` Mark Brown

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.