summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Meyerriecks <rmeyerreicks@digium.com>2010-01-18 21:00:20 +0000
committerRuss Meyerriecks <rmeyerreicks@digium.com>2010-01-18 21:00:20 +0000
commit3deec8a00a398b81f0b26bcae6c35f7c143f7677 (patch)
treea6c4048398829c3e7528f3ac3f9c3941c896534e
parent0eff337508847e7d3376de461cffb509df343582 (diff)
wct4xxp: Add some protection to prevent latency bumps during load time only
events such as firmware load git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7927 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/wct4xxp/base.c76
-rw-r--r--drivers/dahdi/wct4xxp/wct4xxp.h1
2 files changed, 38 insertions, 39 deletions
diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c
index 45a7056..bdd45ab 100644
--- a/drivers/dahdi/wct4xxp/base.c
+++ b/drivers/dahdi/wct4xxp/base.c
@@ -193,9 +193,9 @@ static int noburst = 1;
/* For 56kbps links, set this module parameter to 0x7f */
static int hardhdlcmode = 0xff;
-static int latency = 15;
+static int latency = 1;
-static int ms_per_irq = 5;
+static int ms_per_irq = 1;
#ifdef FANCY_ALARM
static int altab[] = {
@@ -1543,6 +1543,7 @@ static int t4_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc)
/* If we're already running, then go ahead and apply the changes */
if (span->flags & DAHDI_FLAG_RUNNING)
return t4_startup(span);
+
printk(KERN_INFO "Done with spanconfig!\n");
return 0;
}
@@ -2174,6 +2175,7 @@ static int t4_startup(struct dahdi_span *span)
struct t4_span *ts = span->pvt;
struct t4 *wc = ts->owner;
+ set_bit(T4_IGNORE_LATENCY, &wc->checkflag);
printk(KERN_INFO "About to enter startup!\n");
tspan = span->offset + 1;
if (tspan < 0) {
@@ -2268,6 +2270,7 @@ static int t4_startup(struct dahdi_span *span)
}
#endif
printk(KERN_INFO "Completed startup!\n");
+ clear_bit(T4_IGNORE_LATENCY, &wc->checkflag);
return 0;
}
@@ -3258,10 +3261,13 @@ DAHDI_IRQ_HANDLER(t4_interrupt_gen2)
rxident = (status >> 16) & 0x7f;
expected = (wc->rxident + ms_per_irq) % 128;
- if (rxident != expected) {
+ if ((rxident != expected) && !test_bit(T4_IGNORE_LATENCY, &wc->checkflag)) {
int needed_latency;
printk("!!! Missed interrupt. Expected ident of %d and got ident of %d\n", expected, rxident);
+ if (test_bit(T4_IGNORE_LATENCY, &wc->checkflag)) {
+ printk("Should have ignored latency\n");
+ }
if (rxident > wc->rxident) {
needed_latency = rxident - wc->rxident;
} else {
@@ -3313,25 +3319,23 @@ DAHDI_IRQ_HANDLER(t4_interrupt_gen2)
}
#else
#if 1
- //unsigned int reg12 = __t4_pci_in(wc, 12);
unsigned int reg5 = __t4_pci_in(wc, 5);
- unsigned int readoff, writeoff;
-
- //readoff = ((reg12 >> 16) << 1) & 0xffff;
- //writeoff = (reg12 & 0xffff) << 1;
if (wc->intcount < 20) {
printk("Reg 5 is %08x\n", reg5);
- //printk("Read @ %p and write @ %p\n", wc->readchunk + (readoff>>2), wc->writechunk + (writeoff >> 2));
}
#endif
if (wc->flags & FLAG_5THGEN) {
unsigned int current_index = (reg5 >> 8) & 0x7f;
+#if 0
int catchup = 0;
+#endif
while (((wc->lastindex + 1) % wc->numbufs) != current_index) {
+#if 0
catchup++;
+#endif
wc->lastindex = (wc->lastindex + 1) % wc->numbufs;
setup_chunks(wc, wc->lastindex);
t4_prep_gen2(wc);
@@ -3941,10 +3945,6 @@ static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_i
struct devtype *dt;
unsigned int x, f;
int init_latency;
-#if 0
- int y;
- unsigned int *canary;
-#endif
if (pci_enable_device(pdev)) {
return -EIO;
@@ -3958,21 +3958,6 @@ static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_i
spin_lock_init(&wc->reglock);
dt = (struct devtype *) (ent->driver_data);
- /* FIXME */
- dt->flags |= FLAG_5THGEN;
-
- if (dt->flags & FLAG_5THGEN) {
- if ((ms_per_irq > 1) && (latency <= ((ms_per_irq) << 1)))
- init_latency = ms_per_irq << 1;
- else
- init_latency = latency;
- } else {
- if (dt->flags & FLAG_2NDGEN)
- init_latency = 1;
- else
- init_latency = 2;
- }
-
if (dt->flags & FLAG_2PORT)
wc->numspans = 2;
else
@@ -3997,23 +3982,36 @@ static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_i
wc->dev = pdev;
- if (t4_allocate_buffers(wc, init_latency, NULL, NULL)) {
- return -ENOMEM;
- }
-
-#if 0
- memset((void *)wc->readchunk,0xff,DAHDI_MAX_CHUNKSIZE * 2 * 32 * 4);
- /* Initialize canary */
- canary = (unsigned int *)(wc->readchunk + DAHDI_CHUNKSIZE * 64 * 4 - 4);
- *canary = (CANARY << 16) | (0xffff);
-#endif
-
/* Enable bus mastering */
pci_set_master(pdev);
/* Keep track of which device we are */
pci_set_drvdata(pdev, wc);
+ /* FIXME */
+ dt->flags |= FLAG_5THGEN;
+
+ if (t4_pci_in(wc, WC_VERSION) >= 0xc01a016d) {
+ wc->flags |= FLAG_5THGEN;
+ }
+
+ if (dt->flags & FLAG_5THGEN) {
+ if ((ms_per_irq > 1) && (latency <= ((ms_per_irq) << 1))) {
+ init_latency = ms_per_irq << 1;
+ } else
+ init_latency = latency;
+ printk(KERN_INFO "5th gen card with initial latency of %d and %d ms per IRQ\n", init_latency, ms_per_irq);
+ } else {
+ if (dt->flags & FLAG_2NDGEN)
+ init_latency = 1;
+ else
+ init_latency = 2;
+ }
+
+ if (t4_allocate_buffers(wc, init_latency, NULL, NULL)) {
+ return -ENOMEM;
+ }
+
/* Initialize hardware */
t4_hardware_init_1(wc, dt->flags);
diff --git a/drivers/dahdi/wct4xxp/wct4xxp.h b/drivers/dahdi/wct4xxp/wct4xxp.h
index 390672f..f253ed1 100644
--- a/drivers/dahdi/wct4xxp/wct4xxp.h
+++ b/drivers/dahdi/wct4xxp/wct4xxp.h
@@ -109,6 +109,7 @@ struct t4_regs {
#define T4_STOP_DMA 2
#define T4_CHECK_TIMING 3
#define T4_CHANGE_LATENCY 4
+#define T4_IGNORE_LATENCY 5
#define WCT4_GET_REGS _IOW (DAHDI_CODE, 60, struct t4_regs)