From: Shankar D K Date: Thu, 21 Jun 2012 15:32:41 +0000 (+0530) Subject: audio:add missing mutex protection to _dapm_sync call X-Git-Tag: 2.1b_release~560 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=acb7cf290e5c62d9f39ecfc38bfc5c976900aabd;p=kernel%2Fkernel-mfld-blackbay.git audio:add missing mutex protection to _dapm_sync call BZ: 42423 There can be race condition if _dapm_sync() is not called without holding codec mutex. It can lead to kernel crash. This patch adds mutex locks before invoking _dapm_sync(). The _dapm_sync() needs to be called explicitely only when driver uses _force_enable_pin() or _disable_pin(). Removed a reduntant _dapm_sync() call in codec driver, where neither a enable or disable pin is used. Change-Id: I6a81572993805d3a8c1ea3dde00274638d2a0a97 Signed-off-by: Shankar D K Signed-off-by: Ramesh Babu K V Reviewed-on: http://android.intel.com:8080/53642 Reviewed-by: R, Dharageswari Reviewed-by: Koul, Vinod Tested-by: Gupta, ArvindX K Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 9f138ff..7a6802d 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c @@ -430,7 +430,6 @@ static int sn95031_set_dac_mode(struct snd_kcontrol *kcontrol, snd_soc_update_bits(codec, SN95031_SSR2, 0x10, 0x10); snd_soc_update_bits(codec, SN95031_DACCONFIG, 0x10, 0); } - snd_soc_dapm_sync(&codec->dapm); sn95031_dac_mode = ucontrol->value.integer.value[0]; return 0; diff --git a/sound/soc/mid-x86/mfld_machine.c b/sound/soc/mid-x86/mfld_machine.c index cc6b527..05a7cd3 100644 --- a/sound/soc/mid-x86/mfld_machine.c +++ b/sound/soc/mid-x86/mfld_machine.c @@ -366,9 +366,12 @@ static int mfld_speaker_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_dai *cpu_dai = runtime->cpu_dai; struct snd_soc_dapm_context *dapm = &runtime->codec->dapm; + struct snd_soc_codec *codec = runtime->codec; snd_soc_dapm_disable_pin(dapm, "IHFOUTR"); + mutex_lock(&codec->mutex); snd_soc_dapm_sync(dapm); + mutex_unlock(&codec->mutex); return cpu_dai->driver->ops->set_tdm_slot(cpu_dai, 0, 0, 1, 0); } #endif