[PATCH] ASoC: soc-compress: Reposition and add pcm_mutex
commit a385cc2614c17ba3002b263c0ca47dfbf6395c78 (HEAD -> fix_compr, master) Author: s47.kang <[1]s47.kang@samsung.com> Date: Fri Dec 2 15:45:16 2022 +0900
ASoC: soc-compress.c: Reposition and add pcm_mutex.
If panic_on_warn is set and compress stream(DPCM) is started, then kernel panic will occurs because card->pcm_mutex isn't held appropriately in soc_compr_set_params_fe, soc_compr_open_fe and soc_compr_free_fe. So, I reposition and add pcm_mutex to resolve lockdep error.
Signed-off-by: Shinhyung Kang <[2]s47.kang@samsung.com>
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 870f13e1d389..7bce5088b455 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -149,6 +149,8 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) if (ret < 0) goto be_err;
+ mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); + /* calculate valid and active FE <-> BE dpcms */ dpcm_process_paths(fe, stream, &list, 1); fe->dpcm[stream].runtime = fe_substream->runtime; @@ -184,7 +186,6 @@ 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);
@@ -215,7 +216,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
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;
@@ -234,6 +234,8 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
dpcm_be_disconnect(fe, stream);
+ mutex_unlock(&fe->card->pcm_mutex); + fe->dpcm[stream].runtime = NULL;
snd_soc_link_compr_shutdown(cstream, 0); @@ -409,8 +411,9 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, ret = snd_soc_link_compr_set_params(cstream); if (ret < 0) goto out; - + mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); + mutex_unlock(&fe->card->pcm_mutex); fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
out:
[cid:cafe_image_0@s-core.co.kr]
[update?userid=s47.kang&do=bWFpbElEPTIwMjIxMjAyMDgwMDMyZXBjbXMycDY4ZjU2 YTZiNDNkN2Q2YTRmMGQyZGU5Mjk1YzBlNGFiNCZyZWNpcGllbnRBZGRyZXNzPWFsc2EtZGV 2ZWxAYWxzYS1wcm9qZWN0Lm9yZw__]
References
1. mailto:s47.kang@samsung.com 2. mailto:s47.kang@samsung.com
On Fri, Dec 02, 2022 at 05:00:32PM +0900, 강신형 wrote:
<p>commit a385cc2614c17ba3002b263c0ca47dfbf6395c78 (HEAD -> fix_compr, master)<br /> Author: s47.kang <<a href="mailto:s47.kang@samsung.com">s47.kang@samsung.com</a>><br /> Date: Fri Dec 2 15:45:16 2022 +0900</p>
Your mail is HTML only so unfortunately I can't really read it and none of the tooling will be able to handle it.
participants (2)
-
Mark Brown
-
강신형