[svn-commits] tzafrir: branch tzafrir/kernelmove r2496 - in /team/tzafrir/kernelmove: ./ ke...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri May 4 16:21:44 MST 2007


Author: tzafrir
Date: Fri May  4 18:21:43 2007
New Revision: 2496

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2496
Log:
Synced from trunk rev. 2402:2495 .

Added:
    team/tzafrir/kernelmove/kernel/jpah.h   (props changed)
      - copied unchanged from r2495, trunk/jpah.h
    team/tzafrir/kernelmove/kernel/xpp/ChangeLog   (props changed)
      - copied unchanged from r2495, trunk/xpp/ChangeLog
    team/tzafrir/kernelmove/kernel/xpp/init_card_3_26   (props changed)
      - copied unchanged from r2495, trunk/xpp/init_card_3_26
    team/tzafrir/kernelmove/kernel/xpp/init_card_4_26   (props changed)
      - copied unchanged from r2495, trunk/xpp/init_card_4_26
    team/tzafrir/kernelmove/kernel/xpp/init_card_6_26   (props changed)
      - copied unchanged from r2495, trunk/xpp/init_card_6_26
    team/tzafrir/kernelmove/kernel/xpp/init_card_7_26   (props changed)
      - copied unchanged from r2495, trunk/xpp/init_card_7_26
    team/tzafrir/kernelmove/kernel/xpp/utils/xpp_blink   (props changed)
      - copied unchanged from r2495, trunk/xpp/utils/xpp_blink
Removed:
    team/tzafrir/kernelmove/kernel/xpp/init_card_3_24
    team/tzafrir/kernelmove/kernel/xpp/init_card_4_24
    team/tzafrir/kernelmove/kernel/xpp/init_card_6_24
    team/tzafrir/kernelmove/kernel/xpp/init_card_7_24
    team/tzafrir/kernelmove/kernel/xpp/utils/adj_clock.8
    team/tzafrir/kernelmove/kernel/xpp/utils/adj_clock.c
Modified:
    team/tzafrir/kernelmove/   (props changed)
    team/tzafrir/kernelmove/kernel/   (props changed)
    team/tzafrir/kernelmove/kernel/wct1xxp.c
    team/tzafrir/kernelmove/kernel/wct4xxp/base.c
    team/tzafrir/kernelmove/kernel/wcte11xp.c
    team/tzafrir/kernelmove/kernel/xpp/.version
    team/tzafrir/kernelmove/kernel/xpp/README.Astribank
    team/tzafrir/kernelmove/kernel/xpp/calibrate_slics
    team/tzafrir/kernelmove/kernel/xpp/card_bri.c
    team/tzafrir/kernelmove/kernel/xpp/card_fxo.c
    team/tzafrir/kernelmove/kernel/xpp/card_fxs.c
    team/tzafrir/kernelmove/kernel/xpp/card_global.c
    team/tzafrir/kernelmove/kernel/xpp/card_global.h
    team/tzafrir/kernelmove/kernel/xpp/firmwares/FPGA_1141.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/FPGA_1151.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/FPGA_FXS.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/USB_1130.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/USB_1140.hex
    team/tzafrir/kernelmove/kernel/xpp/firmwares/USB_1150.hex
    team/tzafrir/kernelmove/kernel/xpp/utils/Makefile
    team/tzafrir/kernelmove/kernel/xpp/utils/fpga_load.8
    team/tzafrir/kernelmove/kernel/xpp/utils/fpga_load.c
    team/tzafrir/kernelmove/kernel/xpp/utils/genzaptelconf
    team/tzafrir/kernelmove/kernel/xpp/utils/hexfile.c
    team/tzafrir/kernelmove/kernel/xpp/utils/hexfile.h
    team/tzafrir/kernelmove/kernel/xpp/utils/lszaptel
    team/tzafrir/kernelmove/kernel/xpp/utils/xpp_fxloader
    team/tzafrir/kernelmove/kernel/xpp/utils/xpp_sync
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Chans.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Span.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
    team/tzafrir/kernelmove/kernel/xpp/utils/zt_registration
    team/tzafrir/kernelmove/kernel/xpp/xbus-core.c
    team/tzafrir/kernelmove/kernel/xpp/xpd.h
    team/tzafrir/kernelmove/kernel/xpp/xpp_usb.c
    team/tzafrir/kernelmove/kernel/xpp/xpp_zap.c
    team/tzafrir/kernelmove/kernel/xpp/xpp_zap.h
    team/tzafrir/kernelmove/kernel/xpp/xproto.c
    team/tzafrir/kernelmove/kernel/xpp/xproto.h
    team/tzafrir/kernelmove/kernel/zaptel.c
    team/tzafrir/kernelmove/kernel/zaptel.h
    team/tzafrir/kernelmove/kernel/zconfig.h
    team/tzafrir/kernelmove/zaptel.init
    team/tzafrir/kernelmove/zonedata.c
    team/tzafrir/kernelmove/ztmonitor.c

Propchange: team/tzafrir/kernelmove/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/tzafrir/kernelmove/kernel/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/tzafrir/kernelmove/kernel/jpah.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/kernelmove/kernel/jpah.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/kernelmove/kernel/jpah.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/tzafrir/kernelmove/kernel/wct1xxp.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/wct1xxp.c?view=diff&rev=2496&r1=2495&r2=2496
==============================================================================
--- team/tzafrir/kernelmove/kernel/wct1xxp.c (original)
+++ team/tzafrir/kernelmove/kernel/wct1xxp.c Fri May  4 18:21:43 2007
@@ -959,10 +959,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++) {
@@ -970,13 +972,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 {
@@ -990,18 +998,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); 
@@ -1105,11 +1120,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);
@@ -1121,9 +1141,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)
@@ -1161,8 +1184,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 */;
@@ -1170,17 +1195,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");
 

Modified: team/tzafrir/kernelmove/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/wct4xxp/base.c?view=diff&rev=2496&r1=2495&r2=2496
==============================================================================
--- team/tzafrir/kernelmove/kernel/wct4xxp/base.c (original)
+++ team/tzafrir/kernelmove/kernel/wct4xxp/base.c Fri May  4 18:21:43 2007
@@ -165,7 +165,7 @@
 
 #endif
 
-static int debug=0;
+static int debug=0x0;
 static int timingcable = 0;
 static int highestorder;
 static int t1e1override = -1; //0xFF; // -1 = jumper; 0xFF = E1
@@ -187,8 +187,6 @@
    aggressive cards.  Please note that burst mode has no effect on CPU
    utilization / max number of calls / etc. */
 static int noburst = 1;
-static int debugslips = 0;
-static int polling = 0;
 /* For 56kbps links, set this module parameter to 0x7f */
 static int hardhdlcmode = 0xff;
 
@@ -359,8 +357,8 @@
 static void t4_tsi_assign(struct t4 *wc, int fromspan, int fromchan, int tospan, int tochan);
 static void t4_tsi_unassign(struct t4 *wc, int tospan, int tochan);
 static void __t4_set_timing_source(struct t4 *wc, int unit, int master, int slave);
-static void __t4_check_alarms(struct t4 *wc, int span);
-static void __t4_check_sigbits(struct t4 *wc, int span);
+static void t4_check_alarms(struct t4 *wc, int span);
+static void t4_check_sigbits(struct t4 *wc, int span);
 
 #define WC_RDADDR	0
 #define WC_WRADDR	1
@@ -725,7 +723,7 @@
 			channel -= 5;
 		else
 			channel -= 1;
-		if (debug)
+		if (unlikely(debug))
 			printk("Got tone %s of '%c' on channel %d of span %d\n",
 				(start ? "START" : "STOP"), tone, channel, span + 1);
 		if (test_bit(channel, &wc->tspans[span]->dtmfmask) && (tone != 'u')) {
@@ -753,7 +751,7 @@
 	}
 }
 
-static void __t4_check_vpm400(struct t4 *wc, unsigned int newio)
+static void t4_check_vpm400(struct t4 *wc, unsigned int newio)
 {
 	unsigned int digit, regval = 0;
 	unsigned int regbyte;
@@ -772,11 +770,11 @@
 			continue;
 		ts = wc->tspans[x%4];
 		/* Start of DTMF detection process */	
-		regbyte = __t4_vpm_in(wc, x, 0xb8);
-		__t4_vpm_out(wc, x, 0xb8, regbyte); /* Write 1 to clear */
+		regbyte = t4_vpm_in(wc, x, 0xb8);
+		t4_vpm_out(wc, x, 0xb8, regbyte); /* Write 1 to clear */
 		regval = regbyte << 8;
-		regbyte = __t4_vpm_in(wc, x, 0xb9);
-		__t4_vpm_out(wc, x, 0xb9, regbyte);
+		regbyte = t4_vpm_in(wc, x, 0xb9);
+		t4_vpm_out(wc, x, 0xb9, regbyte);
 		regval |= regbyte;
 
 		for(i = 0; (i < MAX_DTMF_DET) && regval; i++) {
@@ -786,10 +784,10 @@
 
 				if (!wc->t1e1)
 					base -= 4;
-				regbyte = __t4_vpm_in(wc, x, 0xa8 + i);
+				regbyte = t4_vpm_in(wc, x, 0xa8 + i);
 				digit = vpm_digits[regbyte];
 				if (!(wc->tspans[0]->spanflags & FLAG_VPM2GEN)) {
-					energy = __t4_vpm_in(wc, x, 0x58 + channel);
+					energy = t4_vpm_in(wc, x, 0x58 + channel);
 					energy = ZT_XLAW(energy, ts->chans);
 					ts->dtmfenergy[base] = energy;
 				}
@@ -823,11 +821,11 @@
 			continue;
 
 		/* Start of DTMF off detection process */	
-		regbyte = __t4_vpm_in(wc, x, 0xbc);
-		__t4_vpm_out(wc, x, 0xbc, regbyte); /* Write 1 to clear */
+		regbyte = t4_vpm_in(wc, x, 0xbc);
+		t4_vpm_out(wc, x, 0xbc, regbyte); /* Write 1 to clear */
 		regval = regbyte << 8;
-		regbyte = __t4_vpm_in(wc, x, 0xbd);
-		__t4_vpm_out(wc, x, 0xbd, regbyte);
+		regbyte = t4_vpm_in(wc, x, 0xbd);
+		t4_vpm_out(wc, x, 0xbd, regbyte);
 		regval |= regbyte;
 
 		for(i = 0; (i < MAX_DTMF_DET) && regval; i++) {
@@ -855,7 +853,7 @@
 }
 #endif
 
-static void __hdlc_stop(struct t4 *wc, unsigned int span)
+static void hdlc_stop(struct t4 *wc, unsigned int span)
 {
 	struct t4_span *t = wc->tspans[span];
 	unsigned char imr0, imr1, mode;
@@ -865,23 +863,23 @@
 	
 	/* Clear receive and transmit timeslots */
 	for (i = 0; i < 4; i++) {
-		__t4_framer_out(wc, span, FRMR_RTR_BASE + i, 0x00);
-		__t4_framer_out(wc, span, FRMR_TTR_BASE + i, 0x00);
-	}
-
-	imr0 = __t4_framer_in(wc, span, FRMR_IMR0);
-	imr1 = __t4_framer_in(wc, span, FRMR_IMR1);
+		t4_framer_out(wc, span, FRMR_RTR_BASE + i, 0x00);
+		t4_framer_out(wc, span, FRMR_TTR_BASE + i, 0x00);
+	}
+
+	imr0 = t4_framer_in(wc, span, FRMR_IMR0);
+	imr1 = t4_framer_in(wc, span, FRMR_IMR1);
 
 	/* Disable HDLC interrupts */
 	imr0 |= HDLC_IMR0_MASK;
-	__t4_framer_out(wc, span, FRMR_IMR0, imr0);
+	t4_framer_out(wc, span, FRMR_IMR0, imr0);
 
 	imr1 |= HDLC_IMR1_MASK;
-	__t4_framer_out(wc, span, FRMR_IMR1, imr1);
-
-	mode = __t4_framer_in(wc, span, FRMR_MODE);
+	t4_framer_out(wc, span, FRMR_IMR1, imr1);
+
+	mode = t4_framer_in(wc, span, FRMR_MODE);
 	mode &= ~FRMR_MODE_HRAC;
-	__t4_framer_out(wc, span, FRMR_MODE, mode);
+	t4_framer_out(wc, span, FRMR_MODE, mode);
 
 	t->sigactive = 0;
 }
@@ -891,14 +889,14 @@
 	__t4_framer_out(wc, span, FRMR_CMDR, cmd);
 }
 
-static inline void __t4_framer_cmd_wait(struct t4 *wc, unsigned int span, int cmd)
+static inline void t4_framer_cmd_wait(struct t4 *wc, unsigned int span, int cmd)
 {
 	int sis;
 	int loops = 0;
 
 	/* XXX could be time consuming XXX */
 	for (;;) {
-		sis = __t4_framer_in(wc, span, FRMR_SIS);
+		sis = t4_framer_in(wc, span, FRMR_SIS);
 		if (!(sis & 0x04))
 			break;
 		if (!loops++) {
@@ -908,14 +906,15 @@
 	if (loops)
 		printk("!!!SIS waited %d loops\n", loops);
 
-	__t4_framer_out(wc, span, FRMR_CMDR, cmd);
-}
-
-static int __hdlc_start(struct t4 *wc, unsigned int span, struct zt_chan *chan, unsigned char mode)
+	t4_framer_out(wc, span, FRMR_CMDR, cmd);
+}
+
+static int hdlc_start(struct t4 *wc, unsigned int span, struct zt_chan *chan, unsigned char mode)
 {
 	struct t4_span *t = wc->tspans[span];
 	unsigned char imr0, imr1;
 	int offset = chan->chanpos;
+	unsigned long flags;
 
 	if (debug & DEBUG_FRAMER) printk("Starting HDLC controller for channel %d span %d\n", offset, span+1);
 
@@ -925,33 +924,36 @@
 	mode |= FRMR_MODE_HRAC;
 
 	/* Make sure we're in the right mode */
-	__t4_framer_out(wc, span, FRMR_MODE, mode);
-	__t4_framer_out(wc, span, FRMR_TSEO, 0x00);
-	__t4_framer_out(wc, span, FRMR_TSBS1, hardhdlcmode);
+	t4_framer_out(wc, span, FRMR_MODE, mode);
+	t4_framer_out(wc, span, FRMR_TSEO, 0x00);
+	t4_framer_out(wc, span, FRMR_TSBS1, hardhdlcmode);
 
 	/* Set the interframe gaps, etc */
-	__t4_framer_out(wc, span, FRMR_CCR1, FRMR_CCR1_ITF|FRMR_CCR1_EITS);
-
-	__t4_framer_out(wc, span, FRMR_CCR2, FRMR_CCR2_RCRC);
+	t4_framer_out(wc, span, FRMR_CCR1, FRMR_CCR1_ITF|FRMR_CCR1_EITS);
+
+	t4_framer_out(wc, span, FRMR_CCR2, FRMR_CCR2_RCRC);
 	
 	/* Set up the time slot that we want to tx/rx on */
-	__t4_framer_out(wc, span, FRMR_TTR_BASE + (offset / 8), (0x80 >> (offset % 8)));
-	__t4_framer_out(wc, span, FRMR_RTR_BASE + (offset / 8), (0x80 >> (offset % 8)));
-
-	imr0 = __t4_framer_in(wc, span, FRMR_IMR0);
-	imr1 = __t4_framer_in(wc, span, FRMR_IMR1);
+	t4_framer_out(wc, span, FRMR_TTR_BASE + (offset / 8), (0x80 >> (offset % 8)));
+	t4_framer_out(wc, span, FRMR_RTR_BASE + (offset / 8), (0x80 >> (offset % 8)));
+
+	imr0 = t4_framer_in(wc, span, FRMR_IMR0);
+	imr1 = t4_framer_in(wc, span, FRMR_IMR1);
 
 	/* Enable our interrupts again */
 	imr0 &= ~HDLC_IMR0_MASK;
-	__t4_framer_out(wc, span, FRMR_IMR0, imr0);
+	t4_framer_out(wc, span, FRMR_IMR0, imr0);
 
 	imr1 &= ~HDLC_IMR1_MASK;
-	__t4_framer_out(wc, span, FRMR_IMR1, imr1);
+	t4_framer_out(wc, span, FRMR_IMR1, imr1);
 
 	/* Reset the signaling controller */
-	__t4_framer_cmd_wait(wc, span, FRMR_CMDR_SRES);
-
+	t4_framer_cmd_wait(wc, span, FRMR_CMDR_SRES);
+
+	spin_lock_irqsave(&wc->reglock, flags);
 	t->sigchan = chan;
+	spin_unlock_irqrestore(&wc->reglock, flags);
+
 	t->sigactive = 0;
 
 	return 0;
@@ -1174,7 +1176,7 @@
 	return 0;
 }
 
-static void inline __t4_hdlc_xmit_fifo(struct t4 *wc, unsigned int span, struct t4_span *ts)
+static void inline t4_hdlc_xmit_fifo(struct t4 *wc, unsigned int span, struct t4_span *ts)
 {
 	int res, i, size = 32;
 	unsigned char buf[32];
@@ -1192,11 +1194,11 @@
 		}
 
 		for (i = 0; i < size; i++)
-			__t4_framer_out(wc, span, FRMR_TXFIFO, buf[i]);
+			t4_framer_out(wc, span, FRMR_TXFIFO, buf[i]);
 
 		if (res) /* End of message */ {
 			if (debug & DEBUG_FRAMER) printk("transmiting XHF|XME\n");
-			__t4_framer_cmd_wait(wc, span, FRMR_CMDR_XHF | FRMR_CMDR_XME);
+			t4_framer_cmd_wait(wc, span, FRMR_CMDR_XHF | FRMR_CMDR_XME);
 #if 0
 			ts->sigactive = (__t4_framer_in(wc, span, FRMR_SIS) & FRMR_SIS_XFW) ? 0 : 1;
 #endif
@@ -1205,7 +1207,7 @@
 				printk("Transmitted %d frames on span %d\n", ts->frames_out, span);
 		} else { /* Still more to transmit */
 			if (debug & DEBUG_FRAMER) printk("transmiting XHF\n");
-			__t4_framer_cmd_wait(wc, span, FRMR_CMDR_XHF);
+			t4_framer_cmd_wait(wc, span, FRMR_CMDR_XHF);
 		}
 	}
 	else if (res < 0)
@@ -1225,10 +1227,12 @@
 		spin_unlock_irqrestore(&wc->reglock, flags);
 		return;
 	}
+	spin_unlock_irqrestore(&wc->reglock, flags);
+
 	if (debug & DEBUG_FRAMER) printk("t4_hdlc_hard_xmit on channel %s (sigchan %s), sigactive=%d\n", chan->name, ts->sigchan->name, ts->sigactive);
+
 	if ((ts->sigchan == chan) && !ts->sigactive)
-		__t4_hdlc_xmit_fifo(wc, span, ts);
-	spin_unlock_irqrestore(&wc->reglock, flags);
+		t4_hdlc_xmit_fifo(wc, span, ts);
 }
 
 static int t4_maint(struct zt_span *span, int cmd)
@@ -1357,6 +1361,10 @@
 	}
 
 	if (debug & DEBUG_MAIN) printk("Shutting down span %d (%s)\n", span->spanno, span->name);
+
+	/* Stop HDLC controller if runned */
+	if (ts->sigchan)
+		hdlc_stop(wc, span->offset);
 	
 	spin_lock_irqsave(&wc->reglock, flags);
 	wasrunning = span->flags & ZT_FLAG_RUNNING;
@@ -1364,10 +1372,6 @@
 	span->flags &= ~ZT_FLAG_RUNNING;
 	if (wasrunning)
 		wc->spansstarted--;
-
-	/* Stop HDLC controller if runned */
-	if (ts->sigchan)
-		__hdlc_stop(wc, span->offset);
 
 	__t4_set_led(wc, span->offset, WC_OFF);
 	if (((wc->numspans == 4) && 
@@ -1449,30 +1453,34 @@
 	if (alreadyrunning)
 		__set_clear(wc, chan->span->offset);
 
+	spin_unlock_irqrestore(&wc->reglock, flags);	
+
 	/* (re)configure signalling channel */
 	if ((sigtype == ZT_SIG_HARDHDLC) || (ts->sigchan == chan)) {
 		if (debug & DEBUG_FRAMER)
 				printk("%sonfiguring hardware HDLC on %s\n", ((sigtype == ZT_SIG_HARDHDLC) ? "C" : "Unc"), chan->name);
 		if (alreadyrunning) {
 			if (ts->sigchan)
-				__hdlc_stop(wc, ts->sigchan->span->offset);
+				hdlc_stop(wc, ts->sigchan->span->offset);
 			if (sigtype == ZT_SIG_HARDHDLC) {
-				if (__hdlc_start(wc, chan->span->offset, chan, ts->sigmode)) {
+				if (hdlc_start(wc, chan->span->offset, chan, ts->sigmode)) {
 					printk("Error initializing signalling controller\n");
-					spin_unlock_irqrestore(&wc->reglock, flags);
 					return -1;
 				}
-			}
-			else
+			} else {
+				spin_lock_irqsave(&wc->reglock, flags);
 				ts->sigchan = NULL;
+				spin_unlock_irqrestore(&wc->reglock, flags);
+			}
 		
 		}
 		else {
+			spin_lock_irqsave(&wc->reglock, flags);
 			ts->sigchan = (sigtype == ZT_SIG_HARDHDLC) ? chan : NULL;
+			spin_unlock_irqrestore(&wc->reglock, flags);
 			ts->sigactive = 0;
 		}
 	}
-	spin_unlock_irqrestore(&wc->reglock, flags);	
 	return 0;
 }
 
@@ -1847,19 +1855,9 @@
 	__t4_framer_out(wc, unit, FRMR_IMR0, 0xff & ~((wc->tspans[unit]->sigchan) ? HDLC_IMR0_MASK : 0));	/* IMR0: We care about CAS changes, etc */
 	__t4_framer_out(wc, unit, FRMR_IMR1, 0xff & ~((wc->tspans[unit]->sigchan) ? HDLC_IMR1_MASK : 0));	/* IMR1: We care about nothing */
 	__t4_framer_out(wc, unit, 0x16, 0x00);	/* IMR2: We care about all the alarm stuff! */
-	if (debugslips) {
-		__t4_framer_out(wc, unit, 0x17, 0xf4);	/* IMR3: We care about AIS and friends */
-		__t4_framer_out(wc, unit, 0x18, 0x3f);  /* IMR4: We care about slips on transmit */
-	} else {
-		__t4_framer_out(wc, unit, 0x17, 0xf7);	/* IMR3: We care about AIS and friends */
-		__t4_framer_out(wc, unit, 0x18, 0xff);  /* IMR4: We don't care about slips on transmit */
-	}
-
-	if (!polling) {
-		__t4_check_alarms(wc, unit);
-		__t4_check_sigbits(wc, unit);
-	}		
-		
+	__t4_framer_out(wc, unit, 0x17, 0xf4);	/* IMR3: We care about AIS and friends */
+	__t4_framer_out(wc, unit, 0x18, 0x3f);  /* IMR4: We care about slips on transmit */
+
 	printk("TE%dXXP: Span %d configured for %s/%s\n", wc->numspans, unit + 1, framing, line);
 }
 
@@ -1936,17 +1934,9 @@
 	__t4_framer_out(wc, unit, FRMR_IMR0, 0xff & ~((wc->tspans[unit]->sigchan) ? HDLC_IMR0_MASK : 0));	/* IMR0: We care about CRC errors, CAS changes, etc */
 	__t4_framer_out(wc, unit, FRMR_IMR1, 0x3f & ~((wc->tspans[unit]->sigchan) ? HDLC_IMR1_MASK : 0));	/* IMR1: We care about loopup / loopdown */
 	__t4_framer_out(wc, unit, 0x16, 0x00);	/* IMR2: We care about all the alarm stuff! */
-	if (debugslips) {
-		__t4_framer_out(wc, unit, 0x17, 0xc4 | imr3extra);	/* IMR3: We care about AIS and friends */
-		__t4_framer_out(wc, unit, 0x18, 0x3f);  /* IMR4: We care about slips on transmit */
-	} else {
-		__t4_framer_out(wc, unit, 0x17, 0xc7 | imr3extra);	/* IMR3: We care about AIS and friends */
-		__t4_framer_out(wc, unit, 0x18, 0xff);  /* IMR4: We don't care about slips on transmit */
-	}
-	if (!polling) {
-		__t4_check_alarms(wc, unit);
-		__t4_check_sigbits(wc, unit);
-	}
+	__t4_framer_out(wc, unit, 0x17, 0xc4 | imr3extra);	/* IMR3: We care about AIS and friends */
+	__t4_framer_out(wc, unit, 0x18, 0x3f);  /* IMR4: We care about slips on transmit */
+
 	printk("TE%dXXP: Span %d configured for %s/%s%s\n", wc->numspans, unit + 1, framing, line, crc4);
 }
 
@@ -2011,22 +2001,26 @@
 		if (noburst)
 			wc->dmactrl |= (1 << 26);
 		__t4_pci_out(wc, WC_DMACTRL, wc->dmactrl);
-		if (!polling) {
-			__t4_check_alarms(wc, span->offset);
-			__t4_check_sigbits(wc, span->offset);
-		}
+
 		/* Startup HDLC controller too */
-		if (ts->sigchan) {
-			if (__hdlc_start(wc, span->offset, ts->sigchan, ts->sigmode)) {
-				printk("Error initializing signalling controller\n");
-				/* XXX Should de-initialize span XXX */
-				spin_unlock_irqrestore(&wc->reglock, flags);
-				return -1;
-			}
-		}
+	}
+
+	if (ts->sigchan) {
+		struct zt_chan *sigchan = ts->sigchan;
+
+		spin_unlock_irqrestore(&wc->reglock, flags);
+		if (hdlc_start(wc, span->offset, sigchan, ts->sigmode)) {
+			printk("Error initializing signalling controller\n");
+			return -1;
+		}
+		spin_lock_irqsave(&wc->reglock, flags);
 	}
 
 	spin_unlock_irqrestore(&wc->reglock, flags);
+
+	t4_check_alarms(wc, span->offset);
+	t4_check_sigbits(wc, span->offset);
+
 	if (wc->tspans[0]->sync == span->spanno) printk("SPAN %d: Primary Sync Source\n",span->spanno);
 	if (wc->tspans[1]->sync == span->spanno) printk("SPAN %d: Secondary Sync Source\n",span->spanno);
 	if (wc->numspans == 4) {
@@ -2284,7 +2278,7 @@
 }
 #endif
 
-static void __t4_check_sigbits(struct t4 *wc, int span)
+static void t4_check_sigbits(struct t4 *wc, int span)
 {
 	int a,i,rxs;
 	struct t4_span *ts = wc->tspans[span];
@@ -2296,7 +2290,7 @@
 		return;
 	if (ts->spantype == TYPE_E1) {
 		for (i = 0; i < 15; i++) {
-			a = __t4_framer_in(wc, span, 0x71 + i);
+			a = t4_framer_in(wc, span, 0x71 + i);
 			/* Get high channel in low bits */
 			rxs = (a & 0xf);
 			if (!(ts->span.chans[i+16].sig & ZT_SIG_CLEAR)) {
@@ -2311,7 +2305,7 @@
 		}
 	} else if (ts->span.lineconfig & ZT_CONFIG_D4) {
 		for (i = 0; i < 24; i+=4) {
-			a = __t4_framer_in(wc, span, 0x70 + (i>>2));
+			a = t4_framer_in(wc, span, 0x70 + (i>>2));
 			/* Get high channel in low bits */
 			rxs = (a & 0x3) << 2;
 			if (!(ts->span.chans[i+3].sig & ZT_SIG_CLEAR)) {
@@ -2336,7 +2330,7 @@
 		}
 	} else {
 		for (i = 0; i < 24; i+=2) {
-			a = __t4_framer_in(wc, span, 0x70 + (i>>1));
+			a = t4_framer_in(wc, span, 0x70 + (i>>1));
 			/* Get high channel in low bits */
 			rxs = (a & 0xf);
 			if (!(ts->span.chans[i+1].sig & ZT_SIG_CLEAR)) {
@@ -2356,15 +2350,18 @@
 	}
 }
 
-static void __t4_check_alarms(struct t4 *wc, int span)
+static void t4_check_alarms(struct t4 *wc, int span)
 {
 	unsigned char c,d;
 	int alarms;
 	int x,j;
 	struct t4_span *ts = wc->tspans[span];
+	unsigned long flags;
 
 	if (!(ts->span.flags & ZT_FLAG_RUNNING))
 		return;
+
+	spin_lock_irqsave(&wc->reglock, flags);
 
 	c = __t4_framer_in(wc, span, 0x4c);
 	d = __t4_framer_in(wc, span, 0x4d);
@@ -2475,15 +2472,18 @@
 	if (ts->span.mainttimer || ts->span.maintstat) 
 		alarms |= ZT_ALARM_LOOPBACK;
 	ts->span.alarms = alarms;
+	spin_unlock_irqrestore(&wc->reglock, flags);
 	zt_alarm_notify(&ts->span);
 }
 
-static void __t4_do_counters(struct t4 *wc)
+static void t4_do_counters(struct t4 *wc)
 {
 	int span;
 	for (span=0;span<wc->numspans;span++) {
 		struct t4_span *ts = wc->tspans[span];
 		int docheck=0;
+
+		spin_lock(&wc->reglock);
 		if (ts->loopupcnt || ts->loopdowncnt)
 			docheck++;
 		if (ts->alarmtimer) {
@@ -2492,9 +2492,9 @@
 				ts->span.alarms &= ~(ZT_ALARM_RECOVER);
 			}
 		}
+		spin_unlock(&wc->reglock);
 		if (docheck) {
-			if (!polling)
-				__t4_check_alarms(wc, span);
+			t4_check_alarms(wc, span);
 			zt_alarm_notify(&ts->span);
 		}
 	}
@@ -2562,40 +2562,43 @@
 #endif
 }
 
-static inline void __t4_framer_interrupt(struct t4 *wc, int span)
+static inline void t4_framer_interrupt(struct t4 *wc, int span)
 {
 	/* Check interrupts for a given span */
 	unsigned char gis, isr0, isr1, isr2, isr3, isr4;
 	int readsize = -1;
 	struct t4_span *ts = wc->tspans[span];
+	struct zt_chan *sigchan;
+	unsigned long flags;
 
 	if (debug & DEBUG_FRAMER)	
 		printk("framer interrupt span %d:%d!\n", wc->num, span + 1);
 
 	/* 1st gen cards isn't used interrupts */
-	gis = __t4_framer_in(wc, span, FRMR_GIS);
-	isr0 = (gis & FRMR_GIS_ISR0) ? __t4_framer_in(wc, span, FRMR_ISR0) : 0;
-	isr1 = (gis & FRMR_GIS_ISR1) ? __t4_framer_in(wc, span, FRMR_ISR1) : 0;
-	isr2 = (gis & FRMR_GIS_ISR2) ? __t4_framer_in(wc, span, FRMR_ISR2) : 0;
-	isr3 = (gis & FRMR_GIS_ISR3) ? __t4_framer_in(wc, span, FRMR_ISR3) : 0;
-	isr4 = (gis & FRMR_GIS_ISR4) ? __t4_framer_in(wc, span, FRMR_ISR4) : 0;
+	gis = t4_framer_in(wc, span, FRMR_GIS);
+	isr0 = (gis & FRMR_GIS_ISR0) ? t4_framer_in(wc, span, FRMR_ISR0) : 0;
+	isr1 = (gis & FRMR_GIS_ISR1) ? t4_framer_in(wc, span, FRMR_ISR1) : 0;
+	isr2 = (gis & FRMR_GIS_ISR2) ? t4_framer_in(wc, span, FRMR_ISR2) : 0;
+	isr3 = (gis & FRMR_GIS_ISR3) ? t4_framer_in(wc, span, FRMR_ISR3) : 0;
+	isr4 = (gis & FRMR_GIS_ISR4) ? t4_framer_in(wc, span, FRMR_ISR4) : 0;
 
 	if (debug & DEBUG_FRAMER)
 		printk("gis: %02x, isr0: %02x, isr1: %02x, isr2: %02x, isr3: %02x, isr4: %02x\n", gis, isr0, isr1, isr2, isr3, isr4);
 
 	if (isr0)
-		__t4_check_sigbits(wc, span);
+		t4_check_sigbits(wc, span);
 
 	if (ts->spantype == TYPE_E1) {
 		/* E1 checks */
 		if ((isr3 & 0x38) || isr2 || isr1)
-			__t4_check_alarms(wc, span);
+			t4_check_alarms(wc, span);
 	} else {
 		/* T1 checks */
 		if (isr2 || (isr3 & 0x08)) 
-			__t4_check_alarms(wc, span);		
-	}
-	if (debugslips && !ts->span.alarms) {
+			t4_check_alarms(wc, span);		
+	}
+	if (!ts->span.alarms) {
+		ts->span.timingslips++;
 		if (isr3 & 0x02)
 			printk("TE%d10P: RECEIVE slip NEGATIVE on span %d\n", wc->numspans, span + 1);
 		if (isr3 & 0x01)
@@ -2606,12 +2609,18 @@
 			printk("TE%d10P: TRANSMIT slip NEGATIVE on span %d\n", wc->numspans, span + 1);
 	}
 
+	spin_lock_irqsave(&wc->reglock, flags);
 	/* HDLC controller checks - receive side */
-	if (!ts->sigchan)
+	if (!ts->sigchan) {
+		spin_unlock_irqrestore(&wc->reglock, flags);
 		return;
+	}
+
+	sigchan = ts->sigchan;
+	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	if (isr0 & FRMR_ISR0_RME) {
-		readsize = (__t4_framer_in(wc, span, FRMR_RBCH) << 8) | __t4_framer_in(wc, span, FRMR_RBCL);
+		readsize = (t4_framer_in(wc, span, FRMR_RBCH) << 8) | t4_framer_in(wc, span, FRMR_RBCL);
 		if (debug & DEBUG_FRAMER) printk("Received data length is %d (%d)\n", readsize, readsize & FRMR_RBCL_MAX_SIZE);
 		/* RPF isn't set on last part of frame */
 		if ((readsize > 0) && ((readsize &= FRMR_RBCL_MAX_SIZE) == 0))
@@ -2620,17 +2629,16 @@
 		readsize = 32;
 
 	if (readsize > 0) {
-		struct zt_chan *sigchan = ts->sigchan;
 		int i;
 		unsigned char readbuf[readsize];
 
 		if (debug & DEBUG_FRAMER) printk("Framer %d: Got RPF/RME! readsize is %d\n", sigchan->span->offset, readsize);
 
 		for (i = 0; i < readsize; i++)
-			readbuf[i] = __t4_framer_in(wc, span, FRMR_RXFIFO);
+			readbuf[i] = t4_framer_in(wc, span, FRMR_RXFIFO);
 
 		/* Tell the framer to clear the RFIFO */
-		__t4_framer_cmd_wait(wc, span, FRMR_CMDR_RMC);
+		t4_framer_cmd_wait(wc, span, FRMR_CMDR_RMC);
 
 		if (debug & DEBUG_FRAMER) {
 			printk("RX(");
@@ -2642,8 +2650,10 @@
 		if (isr0 & FRMR_ISR0_RME) {
 			/* Do checks for HDLC problems */
 			unsigned char rsis = readbuf[readsize-1];
+#if 0
 			unsigned int olddebug = debug;
-			unsigned char rsis_reg = __t4_framer_in(wc, span, FRMR_RSIS);
+#endif
+			unsigned char rsis_reg = t4_framer_in(wc, span, FRMR_RSIS);
 
 #if 0
 			if ((rsis != 0xA2) || (rsis != rsis_reg))
@@ -2671,7 +2681,9 @@
 				zt_hdlc_finish(sigchan);
 				if (debug & DEBUG_FRAMER) printk("Received valid HDLC frame on span %d\n", span);
 			}
+#if 0
 			debug = olddebug;
+#endif
 		} else if (isr0 & FRMR_ISR0_RPF)
 			zt_hdlc_putbuf(sigchan, readbuf, readsize);
 	}
@@ -2679,15 +2691,13 @@
 	/* Transmit side */
 	if (isr1 & FRMR_ISR1_XDU) {
 		if (debug & DEBUG_FRAMER) printk("XDU: Resetting signal controler!\n");
-		__t4_framer_cmd_wait(wc, span, FRMR_CMDR_SRES);
+		t4_framer_cmd_wait(wc, span, FRMR_CMDR_SRES);
 	} else if (isr1 & FRMR_ISR1_XPR) {
-		struct zt_chan *sigchan = ts->sigchan;
-
 		if (debug & DEBUG_FRAMER)
 			printk("Sigchan %d is %p\n", sigchan->chanpos, sigchan);
 
 		if (debug & DEBUG_FRAMER) printk("Framer %d: Got XPR!\n", sigchan->span->offset);
-		__t4_hdlc_xmit_fifo(wc, span, ts);
+		t4_hdlc_xmit_fifo(wc, span, ts);
 	}
 
 	if (isr1 & FRMR_ISR1_ALLS) {
@@ -2717,12 +2727,10 @@
 	/* Process framer interrupts */
 	status2 = t4_framer_in(wc, 0, FRMR_CIS);
 	if (status2 & 0x0f) {
-		spin_lock_irqsave(&wc->reglock, flags);
 		for (x = 0; x < wc->numspans; ++x) {
 			if (status2 & (1 << x))
-				__t4_framer_interrupt(wc, x);
-		}
-		spin_unlock_irqrestore(&wc->reglock, flags);
+				t4_framer_interrupt(wc, x);
+		}
 	}
 
 	/* Ignore if it's not for us */
@@ -2765,11 +2773,7 @@
 		}
 	}
 #endif
-	spin_lock_irqsave(&wc->reglock, flags);
-
-	__handle_leds(wc);
-
-	__t4_do_counters(wc);
+	t4_do_counters(wc);
 
 	x = wc->intcount & 15 /* 63 */;
 	switch(x) {
@@ -2777,18 +2781,23 @@
 	case 1:
 	case 2:
 	case 3:
-		__t4_check_sigbits(wc, x);
+		t4_check_sigbits(wc, x);
 		break;
 	case 4:
 	case 5:
 	case 6:
 	case 7:
-		__t4_check_alarms(wc, x - 4);
+		t4_check_alarms(wc, x - 4);
 		break;
 	}
+
+	spin_lock_irqsave(&wc->reglock, flags);
+
+	__handle_leds(wc);
 
 	if (wc->checktiming > 0)
 		__t4_set_timing_source_auto(wc);
+
 	spin_unlock_irqrestore(&wc->reglock, flags);
 #ifdef LINUX26
 	return IRQ_RETVAL(1);
@@ -2799,21 +2808,18 @@
 static void t4_isr_bh(unsigned long data)
 {
 	struct t4 *wc = (struct t4 *)data;
-	unsigned long flags;
 	unsigned char cis;
 
 	if (test_and_clear_bit(T4_CHECK_FRAMER, &wc->checkflag)) {
-		spin_lock_irqsave(&wc->reglock, flags);
-		cis = __t4_framer_in(wc, 0, FRMR_CIS);
+		cis = t4_framer_in(wc, 0, FRMR_CIS);
 		if (cis & FRMR_CIS_GIS1)
-			__t4_framer_interrupt(wc, 0);
+			t4_framer_interrupt(wc, 0);
 		if (cis & FRMR_CIS_GIS2)
-			__t4_framer_interrupt(wc, 1);
+			t4_framer_interrupt(wc, 1);
 		if (cis & FRMR_CIS_GIS3)
-			__t4_framer_interrupt(wc, 2);
+			t4_framer_interrupt(wc, 2);
 		if (cis & FRMR_CIS_GIS4)
-			__t4_framer_interrupt(wc, 3);
-		spin_unlock_irqrestore(&wc->reglock, flags);
+			t4_framer_interrupt(wc, 3);
 	}
 
 #ifdef VPM_SUPPORT
@@ -2824,11 +2830,8 @@
 				   interrupt when there's a tone, in spite of what their
 				   documentation says? */
 				t4_check_vpm450(wc);
-			} else {
-				spin_lock_irqsave(&wc->reglock, flags);
-				__t4_check_vpm400(wc, wc->vpm400checkstatus);
-				spin_unlock_irqrestore(&wc->reglock, flags);
-			}
+			} else
+				t4_check_vpm400(wc, wc->vpm400checkstatus);
 		}
 	}
 #endif
@@ -2868,7 +2871,7 @@
 
 	if (unlikely((wc->intcount < 20) && debug))
 
-		printk("2G: Got interrupt, status = %08x, CIS = %04x\n", status, __t4_framer_in(wc, 0, FRMR_CIS));
+		printk("2G: Got interrupt, status = %08x, CIS = %04x\n", status, t4_framer_in(wc, 0, FRMR_CIS));
 
 	if (likely(status & 0x2)) {
 #ifdef ENABLE_WORKQUEUES
@@ -2914,9 +2917,10 @@
 		}
 	}
 
+	t4_do_counters(wc);
+
 	spin_lock(&wc->reglock);
 
-	__t4_do_counters(wc);
 	__handle_leds(wc);
 
 	if (unlikely(wc->checktiming > 0)) {
@@ -3336,7 +3340,7 @@
 	unsigned int version;
 
 	version = t4_pci_in(wc, WC_VERSION);
-	printk("TE%dXXP version %08x, burst %s, slip debug: %s\n", wc->numspans, version, noburst ? "OFF" : "ON", debugslips ? "ON" : "OFF");
+	printk("TE%dXXP version %08x, burst %s\n", wc->numspans, version, noburst ? "OFF" : "ON");
 #ifdef ENABLE_WORKQUEUES
 	printk("TE%dXXP running with work queues.\n", wc->numspans);
 #endif
@@ -3776,8 +3780,6 @@
 module_param(debug, int, 0600);
 module_param(loopback, int, 0600);
 module_param(noburst, int, 0600);
-module_param(debugslips, int, 0600);
-module_param(polling, int, 0600);
 module_param(timingcable, int, 0600);
 module_param(t1e1override, int, 0600);
 module_param(alarmdebounce, int, 0600);
@@ -3793,8 +3795,6 @@
 MODULE_PARM(debug, "i");
 MODULE_PARM(loopback, "i");
 MODULE_PARM(noburst, "i");
-MODULE_PARM(debugslips, "i");
-MODULE_PARM(polling, "i");
 MODULE_PARM(hardhdlcmode, "i");
 MODULE_PARM(timingcable, "i");
 MODULE_PARM(t1e1override, "i");

Modified: team/tzafrir/kernelmove/kernel/wcte11xp.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/wcte11xp.c?view=diff&rev=2496&r1=2495&r2=2496
==============================================================================
--- team/tzafrir/kernelmove/kernel/wcte11xp.c (original)
+++ team/tzafrir/kernelmove/kernel/wcte11xp.c Fri May  4 18:21:43 2007
@@ -561,24 +561,35 @@
 	return 0;
 }
 
-static void __t1_check_sigbits(struct t1 *wc)
+static void t1_check_sigbits(struct t1 *wc)
 {
 	int a,i,rxs;
+	unsigned long flags;
+
 	if (!(wc->span.flags & ZT_FLAG_RUNNING))
 		return;
+
+	spin_lock_irqsave(&wc->lock, flags);
+
 	if (wc->spantype == TYPE_E1) {
 		for (i = 0; i < 15; i++) {
 			a = __t1_framer_in(wc, 0x71 + i);
 			/* 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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i+16], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 			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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 		}
 	} else if (wc->span.lineconfig & ZT_CONFIG_D4) {
@@ -587,23 +598,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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i+3], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 			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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i+2], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 			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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i+1], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 			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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 		}
 	} else {
@@ -612,16 +635,23 @@
 			/* 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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i+1], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 			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_irqrestore(&wc->lock, flags);
 					zt_rbsbits(&wc->span.chans[i], rxs);
+					spin_lock_irqsave(&wc->lock, flags);
+				}
 			}
 		}
 	}
+	spin_unlock_irqrestore(&wc->lock, flags);
 }
 
 static void t4_serial_setup(struct t1 *wc)
@@ -1145,14 +1175,17 @@
 	zt_receive(&wc->span);
 }
 
-static void __t1_check_alarms(struct t1 *wc)
+static void t1_check_alarms(struct t1 *wc)
 {
 	unsigned char c,d;
 	int alarms;
 	int x,j;
+	unsigned long flags;
 
 	if (!(wc->span.flags & ZT_FLAG_RUNNING))
 		return;
+
+	spin_lock_irqsave(&wc->lock, flags);
 
 	c = __t1_framer_in(wc, 0x4c);
 	if (wc->spanflags & FLAG_FALC12)
@@ -1267,18 +1300,25 @@
 	if (wc->span.mainttimer || wc->span.maintstat) 
 		alarms |= ZT_ALARM_LOOPBACK;
 	wc->span.alarms = alarms;
+	spin_unlock_irqrestore(&wc->lock, flags);
 	zt_alarm_notify(&wc->span);
 }
 
 
-static void __t1_do_counters(struct t1 *wc)
-{
+static void t1_do_counters(struct t1 *wc)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&wc->lock, flags);
 	if (wc->alarmtimer) {
 		if (!--wc->alarmtimer) {
 			wc->span.alarms &= ~(ZT_ALARM_RECOVER);
+			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)
@@ -1316,8 +1356,10 @@
 	__handle_leds(wc);
 #endif
 
+	spin_unlock_irqrestore(&wc->lock, flags);
+
 	/* Count down timers */
-	__t1_do_counters(wc);
+	t1_do_counters(wc);
 
 	/* Do some things that we don't have to do very often */
 	x = wc->intcount & 15 /* 63 */;
@@ -1326,17 +1368,15 @@
 	case 1:
 		break;
 	case 2:
-		__t1_check_sigbits(wc);
+		t1_check_sigbits(wc);
 		break;
 	case 4:
 		/* Check alarms 1/4 as frequently */
 		if (!(wc->intcount & 0x30))
-			__t1_check_alarms(wc);
+			t1_check_alarms(wc);
 		break;
 	}
 	
-	spin_unlock_irqrestore(&wc->lock, flags);
-
 	if (ints & 0x10) 
 		printk("PCI Master abort\n");
 

Modified: team/tzafrir/kernelmove/kernel/xpp/.version
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove/kernel/xpp/.version?view=diff&rev=2496&r1=2495&r2=2496
==============================================================================
--- team/tzafrir/kernelmove/kernel/xpp/.version (original)
+++ team/tzafrir/kernelmove/kernel/xpp/.version Fri May  4 18:21:43 2007
@@ -1,1 +1,1 @@
-trunk-r3495
+trunk-r3814

Propchange: team/tzafrir/kernelmove/kernel/xpp/ChangeLog
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tzafrir/kernelmove/kernel/xpp/ChangeLog
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tzafrir/kernelmove/kernel/xpp/ChangeLog
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/tzafrir/kernelmove/kernel/xpp/README.Astribank

[... 9340 lines stripped ...]


More information about the svn-commits mailing list