Skip to contentSkip to conversation

2.4.9-ac5: drivers/sound/trident.c

PATCH In review Frank Davis 2 participants 2 messages Sep 2, 2001 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.9-ac5: drivers/sound/trident.c

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

sound/trident.c renamed from sound/trident.c.old +8 -4
@@ -37,6 +37,8 @@
  *
  *  History
  *  v0.14.9c
+ *	September 1 2001 Frank Davis <[email protected]>
+ *	added spinlock to SNDCTL_DSP_RESET
  *	August 10 2001 Peter W�chtler <[email protected]>
  *	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;
 
#1 lore raw

sound/trident.c line 733

Quoted 13 lines
sound/trident.c renamed from sound/trident.c.old +2 -3
-	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)

Quoted 4 lines
sound/trident.c renamed from sound/trident.c.old +2 -0
+			spin_lock_irqsave(&card->lock, flags);
 			dmabuf->swptr = dmabuf->hwptr = 0;
 			dmabuf->count = dmabuf->total_bytes = 0;
+			spin_unlock_irqrestore(&card->lock, flags);

sound/trident.c line 2119

Quoted 10 lines
sound/trident.c renamed from sound/trident.c.old +2 -0
 		}
 		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