aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/emu10k1
diff options
context:
space:
mode:
authorMichael Gernoth <michael@gernoth.net>2015-04-09 17:42:15 -0400
committerTakashi Iwai <tiwai@suse.de>2015-04-10 07:02:23 -0400
commit91bf0c2dcb935a87e5c0795f5047456b965fd143 (patch)
treeec91242a6c5756eb131a9cd6ecc4252a4b8185b8 /sound/pci/emu10k1
parent3dc8523fa7412e731441c01fb33f003eb3cfece1 (diff)
ALSA: emu10k1: don't deadlock in proc-functions
The functions snd_emu10k1_proc_spdif_read and snd_emu1010_fpga_read acquire the emu_lock before accessing the FPGA. The function used to access the FPGA (snd_emu1010_fpga_read) also tries to take the emu_lock which causes a deadlock. Remove the outer locking in the proc-functions (guarding only the already safe fpga read) to prevent this deadlock. [removed superfluous flags variables too -- tiwai] Signed-off-by: Michael Gernoth <michael@gernoth.net> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/emu10k1')
-rw-r--r--sound/pci/emu10k1/emuproc.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
index 2ca9f2e93139..53745f4c2bf5 100644
--- a/sound/pci/emu10k1/emuproc.c
+++ b/sound/pci/emu10k1/emuproc.c
@@ -241,31 +241,22 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
241 struct snd_emu10k1 *emu = entry->private_data; 241 struct snd_emu10k1 *emu = entry->private_data;
242 u32 value; 242 u32 value;
243 u32 value2; 243 u32 value2;
244 unsigned long flags;
245 u32 rate; 244 u32 rate;
246 245
247 if (emu->card_capabilities->emu_model) { 246 if (emu->card_capabilities->emu_model) {
248 spin_lock_irqsave(&emu->emu_lock, flags);
249 snd_emu1010_fpga_read(emu, 0x38, &value); 247 snd_emu1010_fpga_read(emu, 0x38, &value);
250 spin_unlock_irqrestore(&emu->emu_lock, flags);
251 if ((value & 0x1) == 0) { 248 if ((value & 0x1) == 0) {
252 spin_lock_irqsave(&emu->emu_lock, flags);
253 snd_emu1010_fpga_read(emu, 0x2a, &value); 249 snd_emu1010_fpga_read(emu, 0x2a, &value);
254 snd_emu1010_fpga_read(emu, 0x2b, &value2); 250 snd_emu1010_fpga_read(emu, 0x2b, &value2);
255 spin_unlock_irqrestore(&emu->emu_lock, flags);
256 rate = 0x1770000 / (((value << 5) | value2)+1); 251 rate = 0x1770000 / (((value << 5) | value2)+1);
257 snd_iprintf(buffer, "ADAT Locked : %u\n", rate); 252 snd_iprintf(buffer, "ADAT Locked : %u\n", rate);
258 } else { 253 } else {
259 snd_iprintf(buffer, "ADAT Unlocked\n"); 254 snd_iprintf(buffer, "ADAT Unlocked\n");
260 } 255 }
261 spin_lock_irqsave(&emu->emu_lock, flags);
262 snd_emu1010_fpga_read(emu, 0x20, &value); 256 snd_emu1010_fpga_read(emu, 0x20, &value);
263 spin_unlock_irqrestore(&emu->emu_lock, flags);
264 if ((value & 0x4) == 0) { 257 if ((value & 0x4) == 0) {
265 spin_lock_irqsave(&emu->emu_lock, flags);
266 snd_emu1010_fpga_read(emu, 0x28, &value); 258 snd_emu1010_fpga_read(emu, 0x28, &value);
267 snd_emu1010_fpga_read(emu, 0x29, &value2); 259 snd_emu1010_fpga_read(emu, 0x29, &value2);
268 spin_unlock_irqrestore(&emu->emu_lock, flags);
269 rate = 0x1770000 / (((value << 5) | value2)+1); 260 rate = 0x1770000 / (((value << 5) | value2)+1);
270 snd_iprintf(buffer, "SPDIF Locked : %d\n", rate); 261 snd_iprintf(buffer, "SPDIF Locked : %d\n", rate);
271 } else { 262 } else {
@@ -410,14 +401,11 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
410{ 401{
411 struct snd_emu10k1 *emu = entry->private_data; 402 struct snd_emu10k1 *emu = entry->private_data;
412 u32 value; 403 u32 value;
413 unsigned long flags;
414 int i; 404 int i;
415 snd_iprintf(buffer, "EMU1010 Registers:\n\n"); 405 snd_iprintf(buffer, "EMU1010 Registers:\n\n");
416 406
417 for(i = 0; i < 0x40; i+=1) { 407 for(i = 0; i < 0x40; i+=1) {
418 spin_lock_irqsave(&emu->emu_lock, flags);
419 snd_emu1010_fpga_read(emu, i, &value); 408 snd_emu1010_fpga_read(emu, i, &value);
420 spin_unlock_irqrestore(&emu->emu_lock, flags);
421 snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f); 409 snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
422 } 410 }
423} 411}