2.5.39 oss cli cleanup
the following make the rest of the OSS modules SMP ready it also includes a correction by Mika Liljeberg in audio.c
sound/oss/audio.c +40 -29
@@ -826,37 +826,48 @@if (!(audio_devs[dev]->flags &DMA_DUPLEX ) && (bits &PCM_ENABLE_INPUT ) && (bits &PCM_ENABLE_OUTPUT ))return -EINVAL ; -spin_lock_irqsave (&dmap->lock,flags); - changed = audio_devs[dev]->enable_bits ^ bits; -if ((changed & bits) &PCM_ENABLE_INPUT && audio_devs[dev]->go) + +if (bits &PCM_ENABLE_INPUT ) { -reorganize_buffers (dev, dmap_in,1 ); -if ((err = audio_devs[dev]->d->prepare_for_input (dev, - dmap_in->fragment_size, dmap_in->nbufs)) <0 ) { -spin_unlock_irqrestore (&dmap->lock,flags); -return -err; - } - dmap_in->dma_mode =DMODE_INPUT ; - audio_devs[dev]->enable_bits = bits; -DMAbuf_activate_recording (dev, dmap_in); +spin_lock_irqsave (&dmap_in->lock,flags); + changed = (audio_devs[dev]->enable_bits ^ bits) &PCM_ENABLE_INPUT ; +if (changed && audio_devs[dev]->go) + { +reorganize_buffers (dev, dmap_in,1 ); +if ((err = audio_devs[dev]->d->prepare_for_input (dev, + dmap_in->fragment_size, dmap_in->nbufs)) <0 ) { +spin_unlock_irqrestore (&dmap_in->lock,flags); +return -err; + } + dmap_in->dma_mode =DMODE_INPUT ; + audio_devs[dev]->enable_bits |=PCM_ENABLE_INPUT ; +DMAbuf_activate_recording (dev, dmap_in); + }else + audio_devs[dev]->enable_bits &= ~PCM_ENABLE_INPUT ; +spin_unlock_irqrestore (&dmap_in->lock,flags); } -if ((changed & bits) &PCM_ENABLE_OUTPUT && - (dmap_out->mapping_flags &DMA_MAP_MAPPED || dmap_out->qlen >0 ) && - audio_devs[dev]->go) +if (bits &PCM_ENABLE_OUTPUT ) { -if (!(dmap_out->flags &DMA_ALLOC_DONE )) -reorganize_buffers (dev, dmap_out,0 ); - dmap_out->dma_mode =DMODE_OUTPUT ; - audio_devs[dev]->enable_bits = bits; - dmap_out->counts[dmap_out->qhead] = dmap_out->fragment_size; -DMAbuf_launch_output (dev, dmap_out); +spin_lock_irqsave (&dmap_out->lock,flags); + changed = (audio_devs[dev]->enable_bits ^ bits) &PCM_ENABLE_OUTPUT ; +if (changed && + (dmap_out->mapping_flags &DMA_MAP_MAPPED || dmap_out->qlen >0 ) && + audio_devs[dev]->go) + { +if (!(dmap_out->flags &DMA_ALLOC_DONE )) +reorganize_buffers (dev, dmap_out,0 ); + dmap_out->dma_mode =DMODE_OUTPUT ; + audio_devs[dev]->enable_bits |=PCM_ENABLE_OUTPUT ; + dmap_out->counts[dmap_out->qhead] = dmap_out->fragment_size; +DMAbuf_launch_output (dev, dmap_out); + }else + audio_devs[dev]->enable_bits &= ~PCM_ENABLE_OUTPUT ; +spin_unlock_irqrestore (&dmap_out->lock,flags); } - audio_devs[dev]->enable_bits = bits;#if 0 if (changed && audio_devs[dev]->d->trigger) audio_devs[dev]->d->trigger (dev, bits * audio_devs[dev]->go);#endif -spin_unlock_irqrestore (&dmap->lock,flags);/* Falls through... */ case SNDCTL_DSP_GETTRIGGER :
@@ -873,7 +884,7 @@case SNDCTL_DSP_GETIPTR :if (!(audio_devs[dev]->open_mode &OPEN_READ ))return -EINVAL ; -spin_lock_irqsave (&dmap->lock,flags); +spin_lock_irqsave (&dmap_in->lock,flags); cinfo.bytes = dmap_in->byte_counter; cinfo.ptr =DMAbuf_get_buffer_pointer (dev, dmap_in,DMODE_INPUT ) & ~3 ;if (cinfo.ptr < dmap_in->fragment_size && dmap_in->qtail !=0 )
@@ -882,7 +893,7 @@ cinfo.bytes += cinfo.ptr;if (dmap_in->mapping_flags &DMA_MAP_MAPPED ) dmap_in->qlen =0 ;/* Reset interrupt counter */ -spin_unlock_irqrestore (&dmap->lock,flags); +spin_unlock_irqrestore (&dmap_in->lock,flags);if (copy_to_user (arg, &cinfo,sizeof (cinfo)))return -EFAULT ;return 0 ;
@@ -891,7 +902,7 @@if (!(audio_devs[dev]->open_mode &OPEN_WRITE ))return -EINVAL ; -spin_lock_irqsave (&dmap->lock,flags); +spin_lock_irqsave (&dmap_out->lock,flags); cinfo.bytes = dmap_out->byte_counter; cinfo.ptr =DMAbuf_get_buffer_pointer (dev, dmap_out,DMODE_OUTPUT ) & ~3 ;if (cinfo.ptr < dmap_out->fragment_size && dmap_out->qhead !=0 )
@@ -900,7 +911,7 @@ cinfo.bytes += cinfo.ptr;if (dmap_out->mapping_flags &DMA_MAP_MAPPED ) dmap_out->qlen =0 ;/* Reset interrupt counter */ -spin_unlock_irqrestore (&dmap->lock,flags); +spin_unlock_irqrestore (&dmap_out->lock,flags);if (copy_to_user (arg, &cinfo,sizeof (cinfo)))return -EFAULT ;return 0 ;
@@ -913,7 +924,7 @@ ret=0 ;break ; } -spin_lock_irqsave (&dmap->lock,flags); +spin_lock_irqsave (&dmap_out->lock,flags);/* Compute number of bytes that have been played */ count =DMAbuf_get_buffer_pointer (dev, dmap_out,DMODE_OUTPUT );if (count < dmap_out->fragment_size && dmap_out->qhead !=0 )
@@ -923,7 +934,7 @@ count = dmap_out->user_counter - count;if (count <0 ) count =0 ; -spin_unlock_irqrestore (&dmap->lock,flags); +spin_unlock_irqrestore (&dmap_out->lock,flags); ret = count;break ;
sound/oss/dmasound/dmasound.h +1 -0
@@ -166,6 +166,7 @@int treble;int gain;int minDev;/* minor device number currently open */ +spinlock_t lock; };extern struct sound_settings dmasound;
sound/oss/dmasound/dmasound_atari.c +8 -6
@@ -19,7 +19,7 @@#include <linux/init.h> #include <linux/soundcard.h> #include <linux/mm.h> - +#include <linux/spinlock.h> #include <asm/pgalloc.h> #include <asm/uaccess.h> #include <asm/atariints.h>
@@ -1262,7 +1262,7 @@ return; }#endif - +spin_lock (&dmasound.lock);if (write_sq_ignore_int && is_falcon) {/* ++TeSche: Falcon only: ignore first irq because it comes * immediately after starting a frame. after that, irqs come
@@ -1314,6 +1314,7 @@/* We are not playing after AtaPlay(), so there is nothing to play any more. Wake up a process waiting for audio output to drain. */ +spin_unlock (&dmasound.lock); }
@@ -1349,14 +1350,15 @@static int AtaMixerIoctl (u_int cmd,u_long arg) {int data; +unsigned long flags;switch (cmd) {case SOUND_MIXER_READ_SPEAKER :if (is_falcon ||MACH_IS_TT ) {int porta; -cli (); +spin_lock_irqsave (&dmasound.lock, flags); sound_ym.rd_data_reg_sel =14 ; porta = sound_ym.rd_data_reg_sel; -sti (); +spin_unlock_irqrestore (&dmasound.lock, flags);return IOCTL_OUT (arg, porta &0x40 ?0 :100 ); }break ;
@@ -1367,12 +1369,12 @@if (is_falcon ||MACH_IS_TT ) {int porta;IOCTL_IN (arg, data); -cli (); +spin_lock_irqsave (&dmasound.lock, flags); sound_ym.rd_data_reg_sel =14 ; porta = (sound_ym.rd_data_reg_sel & ~0x40 ) | (data <50 ?0x40 :0 ); sound_ym.wd_data = porta; -sti (); +spin_unlock_irqrestore (&dmasound.lock, flags);return IOCTL_OUT (arg, porta &0x40 ?0 :100 ); } }
sound/oss/dmasound/dmasound_awacs.c +27 -16
191 lines not on this page · raw message
sound/oss/dmasound/dmasound_core.c +3 -2
@@ -597,9 +597,9 @@is drained - and if we get here in time then it does not apply. */ -save_flags (flags) ;cli () ; +spin_lock_irqsave (&dmasound.lock, flags); write_sq.syncing &= ~2 ;/* take out POST status */ -restore_flags (flags) ; +spin_unlock_irqrestore (&dmasound.lock, flags);if (write_sq.count >0 && (bLeft = write_sq.block_size-write_sq.rear_size) >0 ) {
@@ -1347,6 +1347,7 @@if (dmasound.mach.record) sq_fops.read = sq_read ;#endif +spin_lock_init (&dmasound.lock); sq_unit =register_sound_dsp (&sq_fops,-1 );if (sq_unit <0 ) {printk (KERN_ERR "dmasound_core: couldn't register fops\n" ) ;
sound/oss/dmasound/dmasound_q40.c +6 -2
@@ -459,28 +459,32 @@*/ return ; } -save_flags (flags);cli (); +spin_lock_irqsave (&dmasound.lock, flags);Q40PlayNextFrame (1 ); -restore_flags (flags); +spin_unlock_irqrestore_flags (&dmasound.lock, flags); }static void Q40StereoInterrupt (int irq,void *dummy,struct pt_regs *fp) { +spin_lock (&dmasound.lock);if (q40_sc>1 ){ *DAC_LEFT =*q40_pp++; *DAC_RIGHT =*q40_pp++; q40_sc -=2 ;master_outb (1 ,SAMPLE_CLEAR_REG ); }else Q40Interrupt (); +spin_unlock (&dmasound.lock); }static void Q40MonoInterrupt (int irq,void *dummy,struct pt_regs *fp) { +spin_lock (&dmasound.lock);if (q40_sc>0 ){ *DAC_LEFT =*q40_pp; *DAC_RIGHT =*q40_pp++; q40_sc --;master_outb (1 ,SAMPLE_CLEAR_REG ); }else Q40Interrupt (); +spin_unlock (&dmasound.lock); }static void Q40Interrupt (void ) {
sound/oss/gus_midi.c +12 -18
@@ -16,6 +16,7 @@*/ #include <linux/init.h> +#include <linux/spinlock.h> #include "sound_config.h" #include "gus.h"
@@ -25,7 +26,7 @@static int my_dev;static int output_used =0 ;static volatile unsigned char gus_midi_control; - +static spinlock_t lock=SPIN_LOCK_UNLOCKED ;static void (*midi_input_intr) (int dev,unsigned char data);static unsigned char tmp_queue[256 ];
@@ -75,8 +76,7 @@ output_used =1 ; -save_flags (flags); -cli (); +spin_lock_irqsave (&lock, flags);if (GUS_MIDI_STATUS () &MIDI_XMIT_EMPTY ) {
@@ -92,7 +92,7 @@outb ((gus_midi_control), u_MidiControl); } -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);return ok; }
@@ -113,16 +113,14 @@/* * Drain the local queue first */ - -save_flags (flags); -cli (); +spin_lock_irqsave (&lock, flags);while (qlen &&dump_to_midi (tmp_queue[qhead])) { qlen--; qhead++; } -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);/* * Output the byte if the local queue is empty.
@@ -142,14 +140,13 @@return 0 ;/* * Local queue full */ -save_flags (flags); -cli (); +spin_lock_irqsave (&lock, flags); tmp_queue[qtail] = midi_byte; qlen++; qtail++; -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);return 1 ; }
@@ -174,15 +171,14 @@if (!output_used)return 0 ; -save_flags (flags); -cli (); +spin_lock_irqsave (&lock, flags);if (qlen &&dump_to_midi (tmp_queue[qhead])) { qlen--; qhead++; } -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);return (qlen >0 ) | !(GUS_MIDI_STATUS () &MIDI_XMIT_EMPTY ); }
@@ -226,11 +222,9 @@void gus_midi_interrupt (int dummy) {volatile unsigned char stat, data; -unsigned long flags;int timeout =10 ; -save_flags (flags); -cli (); +spin_lock (&lock);while (timeout-- >0 && (stat =GUS_MIDI_STATUS ()) & (MIDI_RCV_FULL |MIDI_XMIT_EMPTY )) {
@@ -258,5 +252,5 @@ } } } -restore_flags (flags); +spin_unlock (&lock); }
sound/oss/gus_wave.c +93 -183
821 lines not on this page · raw message
sound/oss/ics2101.c +4 -3
@@ -15,6 +15,7 @@* Bartlomiej Zolnierkiewicz : added __init to ics2101_mixer_init() */ #include <linux/init.h> +#include <linux/spinlock.h> #include "sound_config.h" #include <linux/ultrasound.h>
@@ -28,6 +29,7 @@extern int *gus_osp;extern int gus_base; +extern spinlock_t lock;static int volumes[ICS_MIXDEVS ];static int left_fix[ICS_MIXDEVS ] = {1 ,1 ,1 ,2 ,1 ,2 };
@@ -85,13 +87,12 @@ attn_addr |=0x03 ; } -save_flags (flags); -cli (); +spin_lock_irqsave (&lock, flags);outb ((ctrl_addr), u_MixSelect);outb ((selector[dev]), u_MixData);outb ((attn_addr), u_MixSelect);outb (((unsigned char ) vol), u_MixData); -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags); }static int set_volumes (int dev,int vol)
sound/oss/v_midi.h +1 -1
@@ -3,7 +3,7 @@/* State variables */ int opened; - +spinlock_t lock;/* MIDI fields */ int my_mididev;
sound/oss/wf_midi.c +14 -15
@@ -50,6 +50,7 @@*/ #include <linux/init.h> +#include <linux/spinlock.h> #include "sound_config.h" #include <linux/wavefront.h>
@@ -79,6 +80,7 @@static struct wf_mpu_config *virt_dev = &devs[1 ];static void start_uart_mode (void ); +static spinlock_t lock=SPIN_LOCK_UNLOCKED ;#define OUTPUT_READY 0x40#define INPUT_AVAIL 0x80
@@ -365,8 +367,8 @@ }if (mi->m_busy)return ; +spin_lock (&lock); mi->m_busy =1 ; -sti ();if (!input_dev) { input_dev = physical_dev;
@@ -406,6 +408,7 @@ }while (input_avail () && n-- >0 ); mi->m_busy =0 ; +spin_unlock (&lock); } static int
@@ -486,18 +489,17 @@for (timeout =30000 ; timeout >0 && !output_ready (); timeout--); -save_flags (flags); -cli (); +spin_lock_irqsave (&lock,flags);if (!output_ready ()) {printk (KERN_WARNING "WF-MPU: Send switch " "byte timeout\n" ); -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);return 0 ; }write_data (switchch); -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags); } lastoutdev = dev;
@@ -511,16 +513,15 @@for (timeout =30000 ; timeout >0 && !output_ready (); timeout--); -save_flags (flags); -cli (); +spin_lock_irqsave (&lock,flags);if (!output_ready ()) { +spin_unlock_irqrestore (&lock,flags);printk (KERN_WARNING "WF-MPU: Send data timeout\n" ); -restore_flags (flags);return 0 ; }write_data (midi_byte); -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);return 1 ; }
@@ -768,14 +769,13 @@ {unsigned long flags; -save_flags (flags); -cli (); +spin_lock_irqsave (&lock,flags);wf_mpu_close (virt_dev->devno);/* no synth on virt_dev, so no need to call wf_mpu_synth_close() */ phys_dev->isvirtual =0 ; -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags);return 0 ; }
@@ -858,8 +858,7 @@int ok, i;unsigned long flags; -save_flags (flags); -cli (); +spin_lock_irqsave (&lock,flags);/* XXX fix me */
@@ -875,6 +874,6 @@ } } -restore_flags (flags); +spin_unlock_irqrestore (&lock,flags); }#endif