[dahdi-commits] sruffell: linux/trunk r10380 - /linux/trunk/drivers/dahdi/wct4xxp/base.c

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Wed Dec 14 13:02:57 CST 2011


Author: sruffell
Date: Wed Dec 14 13:02:53 2011
New Revision: 10380

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10380
Log:
wct4xxp: Fail startup if not generating interrupts.

I've seen some platforms that do not properly route the interrupt from the
card to the host CPU. In these cases the card potentially could appear to be
greened up even though no data is flowing over the spans.

This change allows dahdi_cfg to return an error when this occurs, and also
ensures that all the spans are in RED alarm.

For example, dahdi_cfg output when the card is not generating interrupts:
  # dahdi_cfg
  DAHDI startup failed: Input/output error

And the kernel log will contain a string like:
  wct4xxp 0000:02:08.0: Interrupts not detected.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>

Modified:
    linux/trunk/drivers/dahdi/wct4xxp/base.c

Modified: linux/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=10380&r1=10379&r2=10380
==============================================================================
--- linux/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wct4xxp/base.c Wed Dec 14 13:02:53 2011
@@ -2786,6 +2786,39 @@
 			wc->numspans, unit + 1, framing, line, crc4);
 }
 
+/**
+ * t4_check_for_interrupts - Return 0 if the card is generating interrupts.
+ * @wc:	The card to check.
+ *
+ * If the card is not generating interrupts, this function will also place all
+ * the spans on the card into red alarm.
+ *
+ */
+static int t4_check_for_interrupts(struct t4 *wc)
+{
+	unsigned int starting_intcount = wc->intcount;
+	unsigned long stop_time = jiffies + HZ*2;
+	unsigned long flags;
+	int x;
+
+	msleep(20);
+	spin_lock_irqsave(&wc->reglock, flags);
+	while (starting_intcount == wc->intcount) {
+		spin_unlock_irqrestore(&wc->reglock, flags);
+		if (time_after(jiffies, stop_time)) {
+			for (x = 0; x < wc->numspans; x++)
+				wc->tspans[x]->span.alarms = DAHDI_ALARM_RED;
+			dev_err(&wc->dev->dev, "Interrupts not detected.\n");
+			return -EIO;
+		}
+		msleep(100);
+		spin_lock_irqsave(&wc->reglock, flags);
+	}
+	spin_unlock_irqrestore(&wc->reglock, flags);
+
+	return 0;
+}
+
 static int t4_startup(struct file *file, struct dahdi_span *span)
 {
 #ifdef SUPPORT_GEN1
@@ -2906,6 +2939,11 @@
 		if (wc->tspans[7]->sync == span->spanno)
 			dev_info(&wc->dev->dev, "SPAN %d: Octonary Sync "
 					"Source\n", span->spanno);
+	}
+
+	if (!alreadyrunning) {
+		if (t4_check_for_interrupts(wc))
+			return -EIO;
 	}
 
 	if (debug)




More information about the dahdi-commits mailing list