Skip to contentSkip to conversation

removes unneeded spin_lock_irqsave()s from snd-es1968

PATCH In review Karsten Wiese 2 participants 2 messages Nov 2, 2004 – Nov 9, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 removes unneeded spin_lock_irqsave()s from snd-es1968

Found this while testing Ingo Molnars realtime patches for 2.6.9. Without the patch on a realtime enabled kernel, insmod gets stuck and never returns. Please check the assumptions made below and correct me, if I'm wrong ;-)

Karsten

=======================================================
Summary: removes unneeded spin_lock_irqsave()s from snd-es1968

spin_lock_irqsave(&chip->reg_lock) was called a second time in sequence from snd_es1968_bob_start() called from es1968_measure_clock().
While this didn't cause harm on my UP laptop with mainline kernels,
it made "insmod snd-es1968" hang on kernel 2.6.9-mm1-RT-V0.6.9.
The patch assumes that 2 callpaths don't need explicit spinlock protection:
1: The trigger callback, because it is called with IRQs disabled.
2. PM's suspend/resume callbacks, because those are called while ortdinary user processes are frozen. Thus the spin_lock_irqsave(&chip->reg_lock) calls in snd_es1968_bob_start() / snd_es1968_bob_stop() are not needed.

=======================================================

pci/es1968.c renamed from pci/es1968.c~ +0 -6
@@ -837,23 +837,19 @@
 static void snd_es1968_bob_stop(es1968_t *chip)
 {
 	u16 reg;
-	unsigned long flags;
 
-	spin_lock_irqsave(&chip->reg_lock, flags);
 	reg = __maestro_read(chip, 0x11);
 	reg &= ~ESM_BOB_ENABLE;
 	__maestro_write(chip, 0x11, reg);
 	reg = __maestro_read(chip, 0x17);
 	reg &= ~ESM_BOB_START;
 	__maestro_write(chip, 0x17, reg);
-	spin_unlock_irqrestore(&chip->reg_lock, flags);
 }
 
 static void snd_es1968_bob_start(es1968_t *chip)
 {
 	int prescale;
 	int divide;
-	unsigned long flags;
 
 	/* compute ideal interrupt frequency for buffer size & play rate */
 	/* first, find best prescaler value to match freq */
@@ -882,13 +878,11 @@
 	} else if (divide > 1)
 		divide--;
 
-	spin_lock_irqsave(&chip->reg_lock, flags);
 	__maestro_write(chip, 6, 0x9000 | (prescale << 5) | divide);	/* set reg */
 
 	/* Now set IDR 11/17 */
 	__maestro_write(chip, 0x11, __maestro_read(chip, 0x11) | 1);
 	__maestro_write(chip, 0x17, __maestro_read(chip, 0x17) | 1);
-	spin_unlock_irqrestore(&chip->reg_lock, flags);
 }
 
 /* call with substream spinlock */
#1 lore raw

At Wed, 3 Nov 2004 00:50:43 +0100,

Quoted 4 lines · Karsten Wiese

Found this while testing Ingo Molnars realtime patches for 2.6.9. Without the patch on a realtime enabled kernel, insmod gets stuck and never returns. Please check the assumptions made below and correct me, if I'm wrong ;-)

The patch is applied to CVS. Thanks!

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click