[zaptel-commits] sruffell: branch 1.4 r3618 - in /branches: 1.2/wcte12xp/ 1.4/wcte12xp/

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Fri Jan 4 16:54:11 CST 2008


Author: sruffell
Date: Fri Jan  4 16:54:10 2008
New Revision: 3618

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3618
Log:
Increase the amount of code that is protected by locks in the wcte12xp interrupt handler.

Modified:
    branches/1.2/wcte12xp/base.c
    branches/1.2/wcte12xp/vpmadt032.c
    branches/1.4/wcte12xp/base.c
    branches/1.4/wcte12xp/vpmadt032.c

Modified: branches/1.2/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/wcte12xp/base.c?view=diff&rev=3618&r1=3617&r2=3618
==============================================================================
--- branches/1.2/wcte12xp/base.c (original)
+++ branches/1.2/wcte12xp/base.c Fri Jan  4 16:54:10 2008
@@ -220,7 +220,6 @@
 
 	/* Skip audio */
 	writechunk += 66;
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* Search for something waiting to transmit */
 	if ((slot < 6) && (eframe) && (eframe < ZT_CHUNKSIZE - 1)) { 
 		/* only 6 useable cs slots per */
@@ -255,7 +254,6 @@
 		writechunk[CMD_BYTE(slot,2,0)] = curcmd->data;
 	} 
 
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline void cmd_decipher(struct t1 *wc, volatile unsigned char *readchunk)
@@ -267,7 +265,6 @@
 
 	/* Skip audio */
 	readchunk += 66;
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* Search for any pending results */
 	for (x = 0; x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if ((wc->cmdq.cmds[x].flags & (__CMD_RD | __CMD_WR | __CMD_LEDS | __CMD_PINS)) && 
@@ -287,7 +284,6 @@
 			}
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline unsigned int __t1_sdi_clk(struct t1 *wc)
@@ -382,6 +378,7 @@
 	unsigned long flags;
 	int hit;
 	int ret;
+
 
 	do {
 		spin_lock_irqsave(&wc->reglock, flags);
@@ -423,7 +420,6 @@
 	unsigned int x;
 	int count = 0;
 	
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* find our requested command */
 	for (x = 0; x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if ((wc->cmdq.cmds[x].flags & __CMD_RD) &&
@@ -433,7 +429,6 @@
 			memset(&wc->cmdq.cmds[x], 0, sizeof(wc->cmdq.cmds[x]));
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 /********************************************************************
@@ -449,7 +444,6 @@
 	int ret;
 	unsigned int x;
 	
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* find our requested command */
 	for (x = 0;x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if ((wc->cmdq.cmds[x].flags & __CMD_RD) &&
@@ -461,14 +455,12 @@
 	}
 
 	if (hit < 0) {
-		spin_unlock_irqrestore(&wc->reglock, flags);
 		debug_printk(2, "t1_getreg_isr() no addr=%02x\n", addr);
 		return -1; /* oops, couldn't find it */
 	}
 
 	ret = wc->cmdq.cmds[hit].data;
 	memset(&wc->cmdq.cmds[hit], 0, sizeof(struct command));
-	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	return ret;
 }
@@ -480,7 +472,9 @@
 	int ret = 0;
 
 	do {
-		spin_lock_irqsave(&wc->reglock, flags);
+		if (!inisr) {
+			spin_lock_irqsave(&wc->reglock, flags);
+		}
 		hit = empty_slot(wc);
 		if (hit > -1) {
 			wc->cmdq.cmds[hit].address = addr;
@@ -493,9 +487,11 @@
 			if (inisr)
 				wc->cmdq.cmds[hit].flags |= __CMD_ISR;
 		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
 		if (inisr) /* must be requested in t1_getreg_isr() */
 			return (hit > -1) ? 0 : -1;
+		else {
+			spin_unlock_irqrestore(&wc->reglock, flags);
+		}
 		if (hit < 0) {
 			if ((ret = schluffen(&wc->regq)))
 				return ret;
@@ -533,15 +529,19 @@
 	leds = ~leds & 0x0E; /* invert the LED bits (3 downto 1)*/
 
 	do {
-		spin_lock_irqsave(&wc->reglock, flags);
+		if (!inisr) {
+			spin_lock_irqsave(&wc->reglock, flags);
+		}
 		hit = empty_slot(wc);
 		if (hit > -1) {
 			wc->cmdq.cmds[hit].flags |= __CMD_LEDS;
 			wc->cmdq.cmds[hit].address = leds;
 		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
-		if (inisr)
-			break;
+		if (inisr) {
+			break;
+		} else {
+			spin_unlock_irqrestore(&wc->reglock, flags);
+		}
 		if (hit < 0) {
 			if ((ret = schluffen(&wc->regq)))
 				return ret;
@@ -1062,13 +1062,19 @@
 				/* Get high channel in low bits */
 				rxs = (a & 0xf);
 				if (!(wc->span.chans[i+16].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+16].rxsig != rxs) 
+					if (wc->span.chans[i+16].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+16], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 4) & 0xf;
 				if (!(wc->span.chans[i].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i].rxsig != rxs)
+					if (wc->span.chans[i].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 			} else {
 				debug_printk(1, "no space to request register in isr\n");
@@ -1081,23 +1087,35 @@
 				/* Get high channel in low bits */
 				rxs = (a & 0x3) << 2;
 				if (!(wc->span.chans[i+3].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+3].rxsig != rxs)
+					if (wc->span.chans[i+3].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+3], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a & 0xc);
 				if (!(wc->span.chans[i+2].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+2].rxsig != rxs)
+					if (wc->span.chans[i+2].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+2], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 2) & 0xc;
 				if (!(wc->span.chans[i+1].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+1].rxsig != rxs)
+					if (wc->span.chans[i+1].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+1], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 4) & 0xc;
 				if (!(wc->span.chans[i].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i].rxsig != rxs)
+					if (wc->span.chans[i].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i], rxs);
+						spin_lock(&wc->reglock);
+					}	
 				}
 			}
 		}
@@ -1108,13 +1126,19 @@
 				/* Get high channel in low bits */
 				rxs = (a & 0xf);
 				if (!(wc->span.chans[i+1].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+1].rxsig != rxs)
+					if (wc->span.chans[i+1].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+1], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 4) & 0xf;
 				if (!(wc->span.chans[i].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i].rxsig != rxs)
+					if (wc->span.chans[i].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 			}
 		}
@@ -1560,7 +1584,9 @@
 	if (wc->span.mainttimer || wc->span.maintstat) 
 		alarms |= ZT_ALARM_LOOPBACK;
 	wc->span.alarms = alarms;
+	spin_unlock(&wc->reglock);
 	zt_alarm_notify(&wc->span);
+	spin_lock(&wc->reglock);
 }
 
 static inline void __handle_leds(struct t1 *wc)
@@ -1664,8 +1690,11 @@
 		writechunk += SFRAME_SIZE;
 
 	/* Calculate Transmission */
-	if (likely(wc->initialized))
+	if (likely(wc->initialized)) {
+		spin_unlock(&wc->reglock);
 		zt_transmit(&wc->span);
+		spin_lock(&wc->reglock);
+	}
 
 	for (x = 0; x < ZT_CHUNKSIZE; x++) {
 		if (likely(wc->initialized)) {
@@ -1678,8 +1707,9 @@
 			cmd_dequeue(wc, writechunk, x, y);
 		}
 #ifdef VPM_SUPPORT
-		if(likely(wc->vpm150m))
+		if(likely(wc->vpm150m)) {
 			vpm150m_cmd_dequeue(wc, writechunk, x);
+		}
 #endif
 
 		if (x < ZT_CHUNKSIZE - 1) {
@@ -1695,14 +1725,12 @@
 	unsigned int x;
 	unsigned long flags;
 
-	spin_lock_irqsave(&wc->reglock, flags);
 	for (x = 0; x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if (!(wc->cmdq.cmds[x].flags &  __CMD_FIN)) {
 			wc->cmdq.cmds[x].flags &= ~(__CMD_TX) ; /* clear __CMD_TX */
 			wc->cmdq.cmds[x].ident = 0;
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline void t1_receiveprep(struct t1 *wc, int dbl)
@@ -1743,12 +1771,14 @@
 	
 	/* echo cancel */
 	if (likely(wc->initialized)) {
+		spin_unlock(&wc->reglock);
 		for (x = 0; x < wc->span.channels; x++) {
 			zt_ec_chunk(&wc->chans[x], wc->chans[x].readchunk, wc->ec_chunk2[x]);
 			memcpy(wc->ec_chunk2[x],wc->ec_chunk1[x],ZT_CHUNKSIZE);
 			memcpy(wc->ec_chunk1[x],wc->chans[x].writechunk,ZT_CHUNKSIZE);
 		}
 		zt_receive(&wc->span);
+		spin_lock(&wc->reglock);
 	}
 
 	/* Wake up anyone sleeping to read/write a new register */
@@ -1842,17 +1872,20 @@
 	int res;
 
 	/* Read interrupts */
-	ints = t1_getctl(wc, 0x0028);
-
-	if (!ints)
+	spin_lock(&wc->reglock);
+	ints = __t1_getctl(wc, 0x0028);
+
+	if (!ints) {
+		spin_unlock(&wc->reglock);
 #ifdef LINUX26
 		return IRQ_NONE;
 #else
 		return;
 #endif		
+	}
 
 	/* clear interrupts interrupts (we only get here if interrupt is for us) */
-	t1_setctl(wc, 0x0028, ints);
+	__t1_setctl(wc, 0x0028, ints);
 	ints &= wc->intmask;
 
 	if (ints & 0x00000041) { 
@@ -1861,6 +1894,7 @@
 			res |= t1_check_descriptor(wc, 1);
 		} while(res);
 	}
+	spin_unlock(&wc->reglock);
 
 #ifdef LINUX26
 	return IRQ_RETVAL(1);

Modified: branches/1.2/wcte12xp/vpmadt032.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/wcte12xp/vpmadt032.c?view=diff&rev=3618&r1=3617&r2=3618
==============================================================================
--- branches/1.2/wcte12xp/vpmadt032.c (original)
+++ branches/1.2/wcte12xp/vpmadt032.c Fri Jan  4 16:54:10 2008
@@ -55,8 +55,6 @@
 	/* Skip audio */
 	writechunk += 66;
 
-	spin_lock_irqsave(&wc->reglock, flags);
-
 	if (test_bit(VPM150M_SPIRESET, &vpm150m->control) || test_bit(VPM150M_HPIRESET, &vpm150m->control)) {
 		debug_printk(1, "HW Resetting VPMADT032 ...\n");
 		for (x = 0; x < 4; x++) {
@@ -70,7 +68,6 @@
 			writechunk[CMD_BYTE(x, 1, 1)] = 0;
 			writechunk[CMD_BYTE(x, 2, 1)] = 0x00;
 		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
 		return;
 	}
 
@@ -233,8 +230,6 @@
 	if (test_bit(VPM150M_ACTIVE, &vpm150m->control) && !whichframe && !(wc->intcount % 10000))
 		queue_work(vpm150m->wq, &vpm150m->work_debug);
 #endif 
-
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 inline void vpm150m_cmd_decipher(struct t1 *wc, volatile unsigned char *readchunk)
@@ -245,7 +240,6 @@
 
 	/* Skip audio */
 	readchunk += 66;
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* Search for any pending results */
 	for (x = 0; x < VPM150M_MAX_COMMANDS; x++) {
 		if ((wc->vpm150m->cmdq[x].flags & (__VPM150M_RD | __VPM150M_WR)) && 
@@ -267,7 +261,6 @@
 			}
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline struct t1 * wc_find_iface(unsigned short dspid)

Modified: branches/1.4/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcte12xp/base.c?view=diff&rev=3618&r1=3617&r2=3618
==============================================================================
--- branches/1.4/wcte12xp/base.c (original)
+++ branches/1.4/wcte12xp/base.c Fri Jan  4 16:54:10 2008
@@ -220,7 +220,6 @@
 
 	/* Skip audio */
 	writechunk += 66;
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* Search for something waiting to transmit */
 	if ((slot < 6) && (eframe) && (eframe < ZT_CHUNKSIZE - 1)) { 
 		/* only 6 useable cs slots per */
@@ -255,7 +254,6 @@
 		writechunk[CMD_BYTE(slot,2,0)] = curcmd->data;
 	} 
 
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline void cmd_decipher(struct t1 *wc, volatile unsigned char *readchunk)
@@ -267,7 +265,6 @@
 
 	/* Skip audio */
 	readchunk += 66;
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* Search for any pending results */
 	for (x = 0; x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if ((wc->cmdq.cmds[x].flags & (__CMD_RD | __CMD_WR | __CMD_LEDS | __CMD_PINS)) && 
@@ -287,7 +284,6 @@
 			}
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline unsigned int __t1_sdi_clk(struct t1 *wc)
@@ -382,6 +378,7 @@
 	unsigned long flags;
 	int hit;
 	int ret;
+
 
 	do {
 		spin_lock_irqsave(&wc->reglock, flags);
@@ -423,7 +420,6 @@
 	unsigned int x;
 	int count = 0;
 	
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* find our requested command */
 	for (x = 0; x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if ((wc->cmdq.cmds[x].flags & __CMD_RD) &&
@@ -433,7 +429,6 @@
 			memset(&wc->cmdq.cmds[x], 0, sizeof(wc->cmdq.cmds[x]));
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 /********************************************************************
@@ -449,7 +444,6 @@
 	int ret;
 	unsigned int x;
 	
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* find our requested command */
 	for (x = 0;x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if ((wc->cmdq.cmds[x].flags & __CMD_RD) &&
@@ -461,14 +455,12 @@
 	}
 
 	if (hit < 0) {
-		spin_unlock_irqrestore(&wc->reglock, flags);
 		debug_printk(2, "t1_getreg_isr() no addr=%02x\n", addr);
 		return -1; /* oops, couldn't find it */
 	}
 
 	ret = wc->cmdq.cmds[hit].data;
 	memset(&wc->cmdq.cmds[hit], 0, sizeof(struct command));
-	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	return ret;
 }
@@ -480,7 +472,9 @@
 	int ret = 0;
 
 	do {
-		spin_lock_irqsave(&wc->reglock, flags);
+		if (!inisr) {
+			spin_lock_irqsave(&wc->reglock, flags);
+		}
 		hit = empty_slot(wc);
 		if (hit > -1) {
 			wc->cmdq.cmds[hit].address = addr;
@@ -493,9 +487,11 @@
 			if (inisr)
 				wc->cmdq.cmds[hit].flags |= __CMD_ISR;
 		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
 		if (inisr) /* must be requested in t1_getreg_isr() */
 			return (hit > -1) ? 0 : -1;
+		else {
+			spin_unlock_irqrestore(&wc->reglock, flags);
+		}
 		if (hit < 0) {
 			if ((ret = schluffen(&wc->regq)))
 				return ret;
@@ -533,15 +529,19 @@
 	leds = ~leds & 0x0E; /* invert the LED bits (3 downto 1)*/
 
 	do {
-		spin_lock_irqsave(&wc->reglock, flags);
+		if (!inisr) {
+			spin_lock_irqsave(&wc->reglock, flags);
+		}
 		hit = empty_slot(wc);
 		if (hit > -1) {
 			wc->cmdq.cmds[hit].flags |= __CMD_LEDS;
 			wc->cmdq.cmds[hit].address = leds;
 		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
-		if (inisr)
-			break;
+		if (inisr) {
+			break;
+		} else {
+			spin_unlock_irqrestore(&wc->reglock, flags);
+		}
 		if (hit < 0) {
 			if ((ret = schluffen(&wc->regq)))
 				return ret;
@@ -1058,13 +1058,19 @@
 				/* Get high channel in low bits */
 				rxs = (a & 0xf);
 				if (!(wc->span.chans[i+16].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+16].rxsig != rxs) 
+					if (wc->span.chans[i+16].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+16], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 4) & 0xf;
 				if (!(wc->span.chans[i].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i].rxsig != rxs)
+					if (wc->span.chans[i].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 			} else {
 				debug_printk(1, "no space to request register in isr\n");
@@ -1077,23 +1083,35 @@
 				/* Get high channel in low bits */
 				rxs = (a & 0x3) << 2;
 				if (!(wc->span.chans[i+3].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+3].rxsig != rxs)
+					if (wc->span.chans[i+3].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+3], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a & 0xc);
 				if (!(wc->span.chans[i+2].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+2].rxsig != rxs)
+					if (wc->span.chans[i+2].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+2], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 2) & 0xc;
 				if (!(wc->span.chans[i+1].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+1].rxsig != rxs)
+					if (wc->span.chans[i+1].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+1], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 4) & 0xc;
 				if (!(wc->span.chans[i].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i].rxsig != rxs)
+					if (wc->span.chans[i].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i], rxs);
+						spin_lock(&wc->reglock);
+					}	
 				}
 			}
 		}
@@ -1104,13 +1122,19 @@
 				/* Get high channel in low bits */
 				rxs = (a & 0xf);
 				if (!(wc->span.chans[i+1].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i+1].rxsig != rxs)
+					if (wc->span.chans[i+1].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i+1], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 				rxs = (a >> 4) & 0xf;
 				if (!(wc->span.chans[i].sig & ZT_SIG_CLEAR)) {
-					if (wc->span.chans[i].rxsig != rxs)
+					if (wc->span.chans[i].rxsig != rxs) {
+						spin_unlock(&wc->reglock);
 						zt_rbsbits(&wc->span.chans[i], rxs);
+						spin_lock(&wc->reglock);
+					}
 				}
 			}
 		}
@@ -1564,7 +1588,9 @@
 	if (wc->span.mainttimer || wc->span.maintstat) 
 		alarms |= ZT_ALARM_LOOPBACK;
 	wc->span.alarms = alarms;
+	spin_unlock(&wc->reglock);
 	zt_alarm_notify(&wc->span);
+	spin_lock(&wc->reglock);
 }
 
 static inline void __handle_leds(struct t1 *wc)
@@ -1668,8 +1694,11 @@
 		writechunk += SFRAME_SIZE;
 
 	/* Calculate Transmission */
-	if (likely(wc->initialized))
+	if (likely(wc->initialized)) {
+		spin_unlock(&wc->reglock);
 		zt_transmit(&wc->span);
+		spin_lock(&wc->reglock);
+	}
 
 	for (x = 0; x < ZT_CHUNKSIZE; x++) {
 		if (likely(wc->initialized)) {
@@ -1682,8 +1711,9 @@
 			cmd_dequeue(wc, writechunk, x, y);
 		}
 #ifdef VPM_SUPPORT
-		if(likely(wc->vpm150m))
+		if(likely(wc->vpm150m)) {
 			vpm150m_cmd_dequeue(wc, writechunk, x);
+		}
 #endif
 
 		if (x < ZT_CHUNKSIZE - 1) {
@@ -1699,14 +1729,12 @@
 	unsigned int x;
 	unsigned long flags;
 
-	spin_lock_irqsave(&wc->reglock, flags);
 	for (x = 0; x < sizeof(wc->cmdq.cmds) / sizeof(wc->cmdq.cmds[0]); x++) {
 		if (!(wc->cmdq.cmds[x].flags &  __CMD_FIN)) {
 			wc->cmdq.cmds[x].flags &= ~(__CMD_TX) ; /* clear __CMD_TX */
 			wc->cmdq.cmds[x].ident = 0;
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline void t1_receiveprep(struct t1 *wc, int dbl)
@@ -1747,12 +1775,14 @@
 	
 	/* echo cancel */
 	if (likely(wc->initialized)) {
+		spin_unlock(&wc->reglock);
 		for (x = 0; x < wc->span.channels; x++) {
 			zt_ec_chunk(&wc->chans[x], wc->chans[x].readchunk, wc->ec_chunk2[x]);
 			memcpy(wc->ec_chunk2[x],wc->ec_chunk1[x],ZT_CHUNKSIZE);
 			memcpy(wc->ec_chunk1[x],wc->chans[x].writechunk,ZT_CHUNKSIZE);
 		}
 		zt_receive(&wc->span);
+		spin_lock(&wc->reglock);
 	}
 
 	/* Wake up anyone sleeping to read/write a new register */
@@ -1846,17 +1876,20 @@
 	int res;
 
 	/* Read interrupts */
-	ints = t1_getctl(wc, 0x0028);
-
-	if (!ints)
+	spin_lock(&wc->reglock);
+	ints = __t1_getctl(wc, 0x0028);
+
+	if (!ints) {
+		spin_unlock(&wc->reglock);
 #ifdef LINUX26
 		return IRQ_NONE;
 #else
 		return;
 #endif		
+	}
 
 	/* clear interrupts interrupts (we only get here if interrupt is for us) */
-	t1_setctl(wc, 0x0028, ints);
+	__t1_setctl(wc, 0x0028, ints);
 	ints &= wc->intmask;
 
 	if (ints & 0x00000041) { 
@@ -1865,6 +1898,7 @@
 			res |= t1_check_descriptor(wc, 1);
 		} while(res);
 	}
+	spin_unlock(&wc->reglock);
 
 #ifdef LINUX26
 	return IRQ_RETVAL(1);

Modified: branches/1.4/wcte12xp/vpmadt032.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcte12xp/vpmadt032.c?view=diff&rev=3618&r1=3617&r2=3618
==============================================================================
--- branches/1.4/wcte12xp/vpmadt032.c (original)
+++ branches/1.4/wcte12xp/vpmadt032.c Fri Jan  4 16:54:10 2008
@@ -55,8 +55,6 @@
 	/* Skip audio */
 	writechunk += 66;
 
-	spin_lock_irqsave(&wc->reglock, flags);
-
 	if (test_bit(VPM150M_SPIRESET, &vpm150m->control) || test_bit(VPM150M_HPIRESET, &vpm150m->control)) {
 		debug_printk(1, "HW Resetting VPMADT032 ...\n");
 		for (x = 0; x < 4; x++) {
@@ -70,7 +68,6 @@
 			writechunk[CMD_BYTE(x, 1, 1)] = 0;
 			writechunk[CMD_BYTE(x, 2, 1)] = 0x00;
 		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
 		return;
 	}
 
@@ -233,8 +230,6 @@
 	if (test_bit(VPM150M_ACTIVE, &vpm150m->control) && !whichframe && !(wc->intcount % 10000))
 		queue_work(vpm150m->wq, &vpm150m->work_debug);
 #endif 
-
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 inline void vpm150m_cmd_decipher(struct t1 *wc, volatile unsigned char *readchunk)
@@ -245,7 +240,6 @@
 
 	/* Skip audio */
 	readchunk += 66;
-	spin_lock_irqsave(&wc->reglock, flags);
 	/* Search for any pending results */
 	for (x = 0; x < VPM150M_MAX_COMMANDS; x++) {
 		if ((wc->vpm150m->cmdq[x].flags & (__VPM150M_RD | __VPM150M_WR)) && 
@@ -267,7 +261,6 @@
 			}
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
 static inline struct t1 * wc_find_iface(unsigned short dspid)




More information about the zaptel-commits mailing list