[alsa-devel] [PATCHv2 - CA0132 HDA Codec 2/2] Change spin_lock()/unlock() to spin_lock_irqsave()/restore()

Ian Minett ian_minett at creativelabs.com
Wed Jul 25 20:01:20 CEST 2012


From: Ian Minett <ian_minett at creativelabs.com>

 in azx_pcm_trigger(). 
 This change is to prevent deadlock when an interrupt occurs,
 caused by chip->reg_lock contention.


Signed-off-by: Ian Minett <ian_minett at creativelabs.com>

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 796472d..0ccffde 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -551,6 +551,7 @@ enum {
 	(AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\
 	 AZX_DCAPS_ALIGN_BUFSIZE)
 
+/* quirks for Creative CTHDA */
 #define AZX_DCAPS_PRESET_CTHDA \
 	(AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY)
 
@@ -1930,6 +1931,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	struct snd_pcm_substream *s;
 	int rstart = 0, start, nsync = 0, sbits = 0;
 	int nwait, timeout;
+	unsigned long flags;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -1956,7 +1958,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		snd_pcm_trigger_done(s, substream);
 	}
 
-	spin_lock(&chip->reg_lock);
+	spin_lock_irqsave(&chip->reg_lock, flags);
 	if (nsync > 1) {
 		/* first, set SYNC bits of corresponding streams */
 		if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
@@ -1980,7 +1982,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		}
 		azx_dev->running = start;
 	}
-	spin_unlock(&chip->reg_lock);
+	spin_unlock_irqrestore(&chip->reg_lock, flags);
 	if (start) {
 		if (nsync == 1)
 			return 0;
-- 
1.7.4.1



More information about the Alsa-devel mailing list