[svn-commits] mattf: branch 1.4 r2452 - in /branches/1.4: ./ wct1xxp.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Apr 25 09:32:26 MST 2007


Author: mattf
Date: Wed Apr 25 11:32:25 2007
New Revision: 2452

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2452
Log:
Merged revisions 2451 via svnmerge from 
https://origsvn.digium.com/svn/zaptel/branches/1.2

........
r2451 | mattf | 2007-04-25 11:26:18 -0500 (Wed, 25 Apr 2007) | 1 line

Start fixing potential deadlock between device driver and zaptel
........

Modified:
    branches/1.4/   (props changed)
    branches/1.4/wct1xxp.c

Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: branches/1.4/wct1xxp.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wct1xxp.c?view=diff&rev=2452&r1=2451&r2=2452
==============================================================================
--- branches/1.4/wct1xxp.c (original)
+++ branches/1.4/wct1xxp.c Wed Apr 25 11:32:25 2007
@@ -957,10 +957,12 @@
 	zt_receive(&wc->span);
 }
 
-static void __t1xxp_check_sigbits(struct t1xxp *wc, int x)
+static void t1xxp_check_sigbits(struct t1xxp *wc, int x)
 {
 	int a,b,i,y,rxs;
-
+	unsigned long flags;
+
+	spin_lock_irqsave(&wc->lock, flags);
 	if (wc->ise1) {
 		/* Read 5 registers at a time, loading 10 channels at a time */
 		for (i = (x * 5); i < (x * 5) + 5; i++) {
@@ -968,13 +970,19 @@
 			/* Get high channel in low bits */
 			rxs = (a & 0xf);
 			if (!(wc->chans[i+16].sig & ZT_SIG_CLEAR)) {
-				if (wc->chans[i+16].rxsig != rxs)
+				if (wc->chans[i+16].rxsig != rxs) {
+					spin_unlock_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->chans[i+16], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 			rxs = (a >> 4) & 0xf;
 			if (!(wc->chans[i].sig & ZT_SIG_CLEAR)) {
-				if (wc->chans[i].rxsig != rxs)
+				if (wc->chans[i].rxsig != rxs) {
+					spin_unlock_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->chans[i], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 		}
 	} else {
@@ -988,18 +996,25 @@
 			if (b & (1 << y))
 				rxs |= ZT_BBIT;
 			if (!(wc->chans[i].sig & ZT_SIG_CLEAR)) {
-				if (wc->chans[i].rxsig != rxs)
+				if (wc->chans[i].rxsig != rxs) {
+					spin_unlock_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->chans[i], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 		}
 	}
-}
-
-static void __t1xxp_check_alarms(struct t1xxp *wc)
+	spin_unlock_irqrestore(&wc->lock, flags);
+}
+
+static void t1xxp_check_alarms(struct t1xxp *wc)
 {
 	unsigned char c,d;
 	int alarms;
 	int x,j;
+	unsigned long flags;
+
+	spin_lock_irqsave(&wc->lock, flags);
 
 	if (wc->ise1) {
 		__t1_set_reg(wc, 0x06, 0xff); 
@@ -1103,11 +1118,16 @@
 
 	wc->span.alarms = alarms;
 
+	spin_unlock_irqrestore(&wc->lock, flags);
+
 	zt_alarm_notify(&wc->span);
 }
 
-static void __t1xxp_do_counters(struct t1xxp *wc)
-{
+static void t1xxp_do_counters(struct t1xxp *wc)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&wc->lock, flags);
 	if (wc->alarmtimer) {
 		if (!--wc->alarmtimer) {
 			wc->span.alarms &= ~(ZT_ALARM_RECOVER);
@@ -1119,9 +1139,12 @@
 				__t1_set_reg(wc, 0x21, 0x5f);
 			else
 				__t1_set_reg(wc, 0x35, 0x10);
+			spin_unlock_irqrestore(&wc->lock, flags);
 			zt_alarm_notify(&wc->span);
+			spin_lock_irqsave(&wc->lock, flags);
 		}
 	}
+	spin_unlock_irqrestore(&wc->lock, flags);
 }
 
 ZAP_IRQ_HANDLER(t1xxp_interrupt)
@@ -1159,8 +1182,10 @@
 	__handle_leds(wc);
 #endif
 
+	spin_unlock_irqrestore(&wc->lock, flags);
+
 	/* Count down timers */
-	__t1xxp_do_counters(wc);
+	t1xxp_do_counters(wc);
 
 	/* Do some things that we don't have to do very often */
 	x = wc->intcount & 15 /* 63 */;
@@ -1168,17 +1193,15 @@
 	case 0:
 	case 1:
 	case 2:
-		__t1xxp_check_sigbits(wc, x);
+		t1xxp_check_sigbits(wc, x);
 		break;
 	case 4:
 		/* Check alarms 1/4 as frequently */
 		if (!(wc->intcount & 0x30))
-			__t1xxp_check_alarms(wc);
+			t1xxp_check_alarms(wc);
 		break;
 	}
 	
-	spin_unlock_irqrestore(&wc->lock, flags);
-
 	if (ints & 0x10) 
 		printk("PCI Master abort\n");
 



More information about the svn-commits mailing list