audio:add missing mutex protection to _dapm_sync call
authorShankar D K <shankar.d.kodandaram@intel.com>
Thu, 21 Jun 2012 15:32:41 +0000 (21:02 +0530)
committerbuildbot <buildbot@intel.com>
Wed, 27 Jun 2012 12:03:11 +0000 (05:03 -0700)
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 <shankar.d.kodandaram@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Reviewed-on: http://android.intel.com:8080/53642
Reviewed-by: R, Dharageswari <dharageswari.r@intel.com>
Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
Tested-by: Gupta, ArvindX K <arvindx.k.gupta@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
sound/soc/codecs/sn95031.c
sound/soc/mid-x86/mfld_machine.c

index 9f138ff..7a6802d 100644 (file)
@@ -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;
 
index cc6b527..05a7cd3 100644 (file)
@@ -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