[dahdi-commits] dahdi/linux.git branch "master" updated.

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Mon May 20 17:13:25 CDT 2013


branch "master" has been updated
       via  96652d88c64ba0d7e9c56c2671376fb5e70407ae (commit)
       via  c4a17f9442a26f2d124d835e0986436837256b86 (commit)
       via  9b11847aee6fd6100d8c0c8ca8b20893facda1aa (commit)
      from  a3ad32c370dac9fb8d196db7f4d53e2a3f59d1ba (commit)

Summary of changes:
 drivers/dahdi/dahdi-base.c        |   45 +++++++++++--------
 drivers/dahdi/wcte12xp/base.c     |   86 ++++++++++++++++++++++++++++++++++++-
 drivers/dahdi/wcte12xp/wcte12xp.h |    1 +
 3 files changed, 111 insertions(+), 21 deletions(-)


- Log -----------------------------------------------------------------
commit 96652d88c64ba0d7e9c56c2671376fb5e70407ae
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Mon May 20 13:36:50 2013 -0500

    wcte12xp: Reset all the framer registers when switching linemodes.
    
    If a span was fully configured before unassigning and reassigning to a new span
    type it was possible for stale values to be present in the register. When
    switching from T1 to E1 via the spantype sysfs attribute this could result in a
    test pattern being written.
    
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    Signed-off-by: Russ Meyerriecks <rmeyerriecks at digium.com>

diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c
index 19ca58e..ad3b3df 100644
--- a/drivers/dahdi/wcte12xp/base.c
+++ b/drivers/dahdi/wcte12xp/base.c
@@ -851,6 +851,75 @@ static void free_wc(struct t1 *wc)
 	kfree(wc);
 }
 
+/**
+ * t1_reset_registers - Put register back to their default values 
+ *
+ * Since the card does not have an ability to reset just the framer
+ * specifically, we need to write all the default values to the framer.
+ *
+ */
+static void t1_reset_registers(struct t1 *wc)
+{
+	int i;
+	struct t1_reg {
+		u8 address;
+		u8 value;
+	} __attribute__((packed));
+	struct t1_reg *reg;
+	static struct t1_reg DEFAULT_REGS[] = {
+		{0x00, 0x7d}, {0x01, 0x7d}, {0x02, 0x00}, {0x03, 0x00},
+		{0x04, 0xfd}, {0x05, 0xff}, {0x06, 0xff}, {0x07, 0xff},
+		{0x08, 0x05}, {0x09, 0x00}, {0x0a, 0x00}, {0x0b, 0x00},
+		{0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00},
+		{0x10, 0x00}, {0x11, 0x00}, {0x12, 0x00}, {0x13, 0x00},
+		{0x14, 0xff}, {0x15, 0xff}, {0x16, 0xff}, {0x17, 0xff},
+		{0x18, 0xff}, {0x19, 0xff}, {0x1a, 0x00}, {0x1b, 0x00},
+		{0x1c, 0x00}, {0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00},
+		{0x20, 0x00}, {0x21, 0x00}, {0x22, 0x00}, {0x23, 0x04},
+		{0x24, 0x00}, {0x25, 0x05}, {0x26, 0x7b}, {0x27, 0x03},
+		{0x28, 0x40}, {0x29, 0x00}, {0x2a, 0x00}, {0x2b, 0x00},
+		{0x2c, 0x00}, {0x2d, 0x00}, {0x2e, 0x00}, {0x2f, 0x00},
+		{0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00},
+		{0x34, 0x00}, {0x35, 0x00}, {0x36, 0x00}, {0x37, 0x80},
+		{0x38, 0x00}, {0x39, 0x00}, {0x3a, 0x20}, {0x3b, 0x00},
+		{0x3c, 0x00}, {0x3d, 0x00}, {0x3e, 0x0a}, {0x3f, 0x00},
+		{0x40, 0x04}, {0x41, 0x00}, {0x42, 0x00}, {0x43, 0x00},
+		{0x44, 0x30}, {0x45, 0x00}, {0x46, 0xc0}, {0x47, 0xff},
+		{0x48, 0x00}, {0x49, 0x1c}, {0x4a, 0x05}, {0x4b, 0x03},
+		{0x4c, 0xa3}, {0x4d, 0x28}, {0x4e, 0x00}, {0x4f, 0xc0},
+		{0x50, 0x00}, {0x51, 0x00}, {0x52, 0x00}, {0x53, 0x00},
+		{0x54, 0x00}, {0x55, 0x00}, {0x56, 0x00}, {0x57, 0x00},
+		{0x58, 0x00}, {0x59, 0x00}, {0x5a, 0x00}, {0x5b, 0x00},
+		{0x5c, 0x00}, {0x5d, 0x00}, {0x5e, 0x00}, {0x5f, 0x00},
+		{0x60, 0x00}, {0x61, 0x20}, {0x62, 0x00}, {0x63, 0x00},
+		{0x64, 0x5a}, {0x65, 0x02}, {0x66, 0x00}, {0x67, 0x00},
+		{0x68, 0x10}, {0x69, 0x09}, {0x6a, 0x00}, {0x6b, 0x03},
+		{0x6c, 0x00}, {0x6d, 0xc0}, {0x6e, 0x40}, {0x6f, 0x00},
+		{0x70, 0x00}, {0x71, 0x00}, {0x72, 0x00}, {0x73, 0x00},
+		{0x74, 0x00}, {0x75, 0x00}, {0x76, 0x00}, {0x77, 0x00},
+		{0x78, 0x00}, {0x79, 0x00}, {0x7a, 0x00}, {0x7b, 0x00},
+		{0x7c, 0x00}, {0x7d, 0x00}, {0x7e, 0x00}, {0x7f, 0x00},
+		{0x80, 0x00}, {0x81, 0x22}, {0x82, 0x65}, {0x83, 0x35},
+		{0x84, 0x31}, {0x85, 0x60}, {0x86, 0x03}, {0x87, 0x00},
+		{0x88, 0x00}, {0x89, 0x00}, {0x8a, 0x00}, {0x8b, 0x00},
+		{0x8c, 0x00}, {0x8d, 0x00}, {0x8e, 0x00}, {0x8f, 0x00},
+		{0x90, 0x00}, {0x91, 0x00}, {0x92, 0x00}, {0x93, 0x18},
+		{0x94, 0xfb}, {0x95, 0x0b}, {0x96, 0x00}, {0x97, 0x0b},
+		{0x98, 0xdb}, {0x99, 0xdf}, {0x9a, 0x48}, {0x9b, 0x00},
+		{0x9c, 0x3f}, {0x9d, 0x3f}, {0x9e, 0x77}, {0x9f, 0x77},
+		{0xa0, 0x00}, {0xa1, 0xff}, {0xa2, 0xff}, {0xa3, 0xff},
+		{0xa4, 0x00}, {0xa5, 0x00}, {0xa6, 0x00}, {0xa7, 0x00},
+		{0xa8, 0x00}
+	};
+
+	for (i = 0; i < ARRAY_SIZE(DEFAULT_REGS); ++i) {
+		reg = &DEFAULT_REGS[i];
+		t1_setreg(wc, reg->address, reg->value);
+	}
+	/* Flush previous writes. */
+	t1_getreg(wc, 0x1d);
+}
+
 static void t4_serial_setup(struct t1 *wc)
 {
 	t1_setreg(wc, 0x85, 0xe0);	/* GPC1: Multiplex mode enabled, FSC is output, active low, RCLK from channel 0 */
@@ -2039,10 +2108,13 @@ static int t1xxp_set_linemode(struct dahdi_span *span, enum spantypes linemode)
 	/* Stop the processing of the channels since we're going to change
 	 * them. */
 	clear_bit(INITIALIZED, &wc->bit_flags);
+	synchronize_irq(wc->vb.pdev->irq);
 	smp_mb__after_clear_bit();
 	del_timer_sync(&wc->timer);
 	flush_workqueue(wc->wq);
 
+	t1_reset_registers(wc);
+
 	switch (linemode) {
 	case SPANTYPE_DIGITAL_T1:
 		dev_info(&wc->vb.pdev->dev,

commit c4a17f9442a26f2d124d835e0986436837256b86
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Wed May 15 17:36:23 2013 -0500

    wcte12xp: Allow non-interrupting cards to unload faster.
    
    If a card stops generating interrupts for any reason, it can take awhile to
    unload the driver while waiting for the commands to timeout. Now if there is a
    problem, immediately set a bit that the card is failed so that no new commands
    will be submitted.
    
    Also, do not free and commands in submit since all commands are freed in get
    results now. This prevents list/memory corruption when commands time out.
    
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    Signed-off-by: Russ Meyerriecks <rmeyerriecks at digium.com>

diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c
index 22bd450..19ca58e 100644
--- a/drivers/dahdi/wcte12xp/base.c
+++ b/drivers/dahdi/wcte12xp/base.c
@@ -658,6 +658,17 @@ static int __t1_getresult(struct t1 *wc, struct command *cmd)
 
 	might_sleep();
 
+	if (test_bit(IOERROR, &wc->bit_flags)) {
+		spin_lock_irqsave(&wc->reglock, flags);
+		list_del_init(&cmd->node);
+		spin_unlock_irqrestore(&wc->reglock, flags);
+		if (printk_ratelimit()) {
+			dev_warn(&wc->vb.pdev->dev,
+				 "Timeout in %s\n", __func__);
+		}
+		return -EIO;
+	}
+
 	ret = wait_for_completion_interruptible_timeout(&cmd->complete, HZ*10);
 	if (unlikely(!ret)) {
 		spin_lock_irqsave(&wc->reglock, flags);
@@ -666,13 +677,13 @@ static int __t1_getresult(struct t1 *wc, struct command *cmd)
 			 * can go ahead and free it right away. */
 			list_del_init(&cmd->node);
 			spin_unlock_irqrestore(&wc->reglock, flags);
-			free_cmd(wc, cmd);
 			if (-ERESTARTSYS != ret) {
 				if (printk_ratelimit()) {
 					dev_warn(&wc->vb.pdev->dev,
 						 "Timeout in %s\n", __func__);
 				}
 				ret = -EIO;
+				set_bit(IOERROR, &wc->bit_flags);
 			}
 			return ret;
 		} else {
@@ -683,7 +694,6 @@ static int __t1_getresult(struct t1 *wc, struct command *cmd)
 			ret = wait_for_completion_timeout(&cmd->complete, HZ*2);
 			WARN_ON(!ret);
 			ret = cmd->data;
-			free_cmd(wc, cmd);
 			return ret;
 		}
 	}
diff --git a/drivers/dahdi/wcte12xp/wcte12xp.h b/drivers/dahdi/wcte12xp/wcte12xp.h
index 838f0dd..27ce597 100644
--- a/drivers/dahdi/wcte12xp/wcte12xp.h
+++ b/drivers/dahdi/wcte12xp/wcte12xp.h
@@ -114,6 +114,7 @@ struct t1 {
 #define INITIALIZED 1
 #define SHUTDOWN    2
 #define READY	    3
+#define IOERROR	    4
 	unsigned long bit_flags;
 	unsigned long alarmtimer;
 	unsigned char ledstate;

commit 9b11847aee6fd6100d8c0c8ca8b20893facda1aa
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Fri May 17 12:10:21 2013 -0500

    dahdi: Completely stop spans when unassigning.
    
    When spans are unassigned, dahdi_span_ops.shutdown was called, but the RUNNING
    flag was never cleared. Now make sure all calls to the shutdown span ops
    callback are the same.
    
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    Signed-off-by: Russ Meyerriecks <rmeyerriecks at digium.com>

diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index dda06ef..72aa5e3 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -5137,11 +5137,28 @@ static int dahdi_ioctl_startup(struct file *file, unsigned long data)
 	return res;
 }
 
+static int dahdi_shutdown_span(struct dahdi_span *s)
+{
+	int res = 0;
+	int x;
+
+	/* Unconfigure channels */
+	for (x = 0; x < s->channels; x++)
+		s->chans[x]->sig = 0;
+
+	if (s->ops->shutdown)
+		res = s->ops->shutdown(s);
+
+	clear_bit(DAHDI_FLAGBIT_RUNNING, &s->flags);
+	return res;
+}
+
 static int dahdi_ioctl_shutdown(unsigned long data)
 {
+	int res;
 	/* I/O CTL's for control interface */
 	int j;
-	int x;
+
 	struct dahdi_span *s;
 
 	if (get_user(j, (int __user *)data))
@@ -5149,22 +5166,9 @@ static int dahdi_ioctl_shutdown(unsigned long data)
 	s = span_find_and_get(j);
 	if (!s)
 		return -ENXIO;
-
-	/* Unconfigure channels */
-	for (x = 0; x < s->channels; x++)
-		s->chans[x]->sig = 0;
-
-	if (s->ops->shutdown) {
-		int res = s->ops->shutdown(s);
-		if (res) {
-			put_span(s);
-			return res;
-		}
-	}
-
-	s->flags &= ~DAHDI_FLAG_RUNNING;
+	res = dahdi_shutdown_span(s);
 	put_span(s);
-	return 0;
+	return res;
 }
 
 /**
@@ -7424,6 +7428,7 @@ static void disable_span(struct dahdi_span *span)
  */
 static int _dahdi_unassign_span(struct dahdi_span *span)
 {
+	int res;
 	int x;
 	struct dahdi_span *new_master, *s;
 	unsigned long flags;
@@ -7440,9 +7445,11 @@ static int _dahdi_unassign_span(struct dahdi_span *span)
 	span->spanno = 0;
 	clear_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags);
 
-	/* Shutdown the span if it's running */
-	if ((span->flags & DAHDI_FLAG_RUNNING) && span->ops->shutdown)
-		span->ops->shutdown(span);
+	res = dahdi_shutdown_span(span);
+	if (res) {
+		dev_err(span_device(span),
+			"Failed to shutdown when unassigning.\n");
+	}
 
 	if (debug & DEBUG_MAIN)
 		module_printk(KERN_NOTICE, "Unassigning Span '%s' with %d channels\n", span->name, span->channels);

-----------------------------------------------------------------------


-- 
dahdi/linux.git



More information about the dahdi-commits mailing list