All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.4.9-ac5: drivers/sound/trident.c
@ 2001-09-02  3:29 Frank Davis
  2001-09-02 12:59 ` Alan Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Davis @ 2001-09-02  3:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox

[-- Attachment #1: Type: text/plain, Size: 155 bytes --]

Hello,
   The attached patch addresses a locking concern with the trident 
driver. Please apply and test. It is against 2.4.9-ac5 . Thanks.
Regards,
Frank

[-- Attachment #2: TRIDENTP --]
[-- Type: text/plain, Size: 1647 bytes --]

--- drivers/sound/trident.c.old	Thu Aug 30 21:42:58 2001
+++ drivers/sound/trident.c	Sat Sep  1 23:04:34 2001
@@ -37,6 +37,8 @@
  *
  *  History
  *  v0.14.9c
+ *	September 1 2001 Frank Davis <fdavis112@juno.com>
+ *	added spinlock to SNDCTL_DSP_RESET
  *	August 10 2001 Peter Wächtler <pwaechtler@loewe-komp.de>
  *	added support for Tvia (formerly Integraphics/IGST) CyberPro5050
  *	this chip is often found in settop boxes (combined video+audio)
@@ -703,8 +705,7 @@
  	 *	clash with another cyberpro config event
  	 */
  
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&card->lock, flags);
 	portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
 	/* enable, if it was disabled */
 	if( (portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE ) {
@@ -729,7 +730,7 @@
 		cyber_outidx( CYBER_PORT_AUDIO, 0xb3, 0x06 );
 		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x00 );
 	}
-	restore_flags(flags);
+	spin_unlock_irqrestore(&card->lock, flags);
 	return ret;
 }
 
@@ -2098,20 +2099,23 @@
 		break;
 		
 	case SNDCTL_DSP_RESET:
-		/* FIXME: spin_lock ? */
 		if (file->f_mode & FMODE_WRITE) {
 			stop_dac(state);
 			synchronize_irq();
 			dmabuf->ready = 0;
+			spin_lock_irqsave(&card->lock, flags);
 			dmabuf->swptr = dmabuf->hwptr = 0;
 			dmabuf->count = dmabuf->total_bytes = 0;
+			spin_unlock_irqrestore(&card->lock, flags);
 		}
 		if (file->f_mode & FMODE_READ) {
 			stop_adc(state);
 			synchronize_irq();
 			dmabuf->ready = 0;
+			spin_lock_irqsave(&card->lock, flags);
 			dmabuf->swptr = dmabuf->hwptr = 0;
 			dmabuf->count = dmabuf->total_bytes = 0;
+			spin_unlock_irqrestore(&card->lock, flags);
 		}
 		break;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] 2.4.9-ac5: drivers/sound/trident.c
  2001-09-02  3:29 [PATCH] 2.4.9-ac5: drivers/sound/trident.c Frank Davis
@ 2001-09-02 12:59 ` Alan Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2001-09-02 12:59 UTC (permalink / raw)
  To: fdavis; +Cc: linux-kernel, Alan Cox

>   
> -	save_flags(flags);
> -	cli();
> +	spin_lock_irqsave(&card->lock, flags);
>  	portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
>  	/* enable, if it was disabled */
>  	if( (portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE ) {
> @@ -729,7 +730,7 @@
>  		cyber_outidx( CYBER_PORT_AUDIO, 0xb3, 0x06 );
>  		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x00 );
>  	}
> -	restore_flags(flags);
> +	spin_unlock_irqrestore(&card->lock, flags);

This one is wrong. What is probably not obvious on first reading is that
the cyber_out* code actually configures the chipset so needs to be locked
against other chipset configurations (current cli/sti based therefore)

> +			spin_lock_irqsave(&card->lock, flags);
>  			dmabuf->swptr = dmabuf->hwptr = 0;
>  			dmabuf->count = dmabuf->total_bytes = 0;
> +			spin_unlock_irqrestore(&card->lock, flags);
>  		}
>  		if (file->f_mode & FMODE_READ) {
>  			stop_adc(state);
>  			synchronize_irq();
>  			dmabuf->ready = 0;
> +			spin_lock_irqsave(&card->lock, flags);
>  			dmabuf->swptr = dmabuf->hwptr = 0;
>  			dmabuf->count = dmabuf->total_bytes = 0;
> +			spin_unlock_irqrestore(&card->lock, flags);
>  		}

Possibly needed yes. We have however stopped the adc before we read it
and we hold the semaphore so I think its ok on this card


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-02 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-02  3:29 [PATCH] 2.4.9-ac5: drivers/sound/trident.c Frank Davis
2001-09-02 12:59 ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.