[svn-commits] sruffell: branch linux/sruffell/dahdi-linux-2.4.1-preview r9640 - in /linux/t...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jan 17 20:07:38 CST 2011


Author: sruffell
Date: Mon Jan 17 20:07:30 2011
New Revision: 9640

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9640
Log:
Update with candidate changes for 2.4.1

Includes the following changes from trunk...in a single commit in order to not
span the mailing lists too much....

Kinsey Moore (4):
      wcte11xp, wcte12xp: Fix a long-standing issue with shutdown
      dahdi-base: All channels for a span are now unconfigured on shutdown
      dahdi: Fix 'void *' pointer arithmetic warnings.
      dahdi: Anonymous member in dahdi_echocan_events union.

Russ Meyerriecks (1):
      wct4xxp: Update span-local struct with timing info

Shaun Ruffell (31):
      dahdi: Fix compilation error when CONFIG_DAHDI_NET is defined.
      README: Remove references to dahdi_dummy.
      dahdi_dummy: #include <linux/slab.h> for kzalloc and friends.
      wcte12xp, wctdm24xxp: Remove redundant vb_enable_io_access.
      wcte12xp, wctdm24xxp: Add call to 'pci_set_mwi' on initialization.
      dahdi: Be more tolerant of surprise removal of channels.
      wctdm24xxp: Add optional FXO digital loopback if DEBUG is defined.
      vpmadt032: Honor the CONFIG_DAHDI_NO_ECHOCAN_DISABLE flag.
      vpmadt032: Remove potential endless waits when resetting.
      dahdi: Fix for when PPP support is compiled as a kernel module.
      dahdi: Make CONFIG_DAHDI_PPP off by default.
      wct4xxp: Drop usage of 'volatile' qualifier.
      wcte12xp, wctdm24xxp: Do not rely on polling main memory.
      dahdi: '-o' -> '--no-same-owner' in drivers/dahdi/firmware/Makefile
      wctdm24xxp: Leave FXO (DAA) always in full-wave ring detect mode.
      wctdm24xxp: Detect FXS modules based on the 3210 SLIC.
      Remove mutex emulation
      wctdm24xxp, wcte12xp: Close a few potential resource assignment leaks.
      dahdi: Prevent unloadable module on failed open.
      wcte12xp: Use interruptible waits to decrease impact on load average.
      wctdm24xxp, wcte12xp: Add more descriptive message on a failed reset.
      wctdm24xxp, wcte12xp: Lock interrupts when recovering from an underrun.
      wct4xxp: Close a memory leak in the VPM450 error path.
      wctdm24xxp, wcte12xp: Disable PCI read-line multiple command.
      wcte12xp, wctdm24xxp: Do not call pci_set_drvdata after device initialization.
      wcb4xxp: HDLC packets do not pass over D-channel.
      dahdi: If mutexes are not available use semaphores instead.
      "struct pci_device_id[]" -> "DEFINE_PCI_DEVICE_TABLE"
      wcte12xp: Remove unused functions from t1_span_ops.
      dahdi: Add error if CONFIG_BKL is not defined
      wct4xxp: Perform an extended reset on PCI-Express cards by default.

Tzafrir Cohen (6):
      xpp: Fixes init error for PRI devices with < 4 ports
      live_dahdi: only check for TOOLS_DIR when used
      xpd_pri: ignore DAHDI_VMWI and DAHDIVMWI_CONFIG
      xpd_pri: Remove pointless hooksig span op
      live_dahdi: fix usage of xpp.conf
      README: clarify required kernel configuration

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

Modified:
    linux/team/sruffell/dahdi-linux-2.4.1-preview/README
    linux/team/sruffell/dahdi-linux-2.4.1-preview/build_tools/live_dahdi
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi-base.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_dummy.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_kb1.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_mg2.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/firmware/Makefile
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/hpec/dahdi_echocan_hpec.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/pciradio.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/tor2-hw.h
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/GpakCust.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/voicebus.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wcb4xxp/base.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wcfxo.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wct1xxp.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wct4xxp/base.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wct4xxp/vpm450m.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wctc4xxp/base.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wctdm.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wctdm24xxp/base.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wctdm24xxp/xhfc.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wcte11xp.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/wcte12xp/base.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/xpp/card_pri.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/xpp/init_card_4_30
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/xpp/xbus-core.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/xpp/xpp_usb.c
    linux/team/sruffell/dahdi-linux-2.4.1-preview/include/dahdi/dahdi_config.h
    linux/team/sruffell/dahdi-linux-2.4.1-preview/include/dahdi/kernel.h

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/README
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/README?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/README (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/README Mon Jan 17 20:07:30 2011
@@ -51,8 +51,6 @@
 - wctc4xxp: Digium hardware transcoder cards (also need dahdi_transcode)
 - dahdi_dynamic_eth: TDM over Ethernet (TDMoE) driver. Requires dahdi_dynamic
 - dahdi_dynamic_loc: Mirror a local span. Requires dahdi_dynamic
-- dahdi_dummy: A dummy driver that only provides a DAHDI timing source.
-
 
 Installation
 ------------
@@ -89,9 +87,9 @@
 - If you use a kernel from your distribution you will typically have a
   package with all the files required to build a kernel modules for your
   kernel image.
-  * On Debian Etch and Ubuntu this is
+  * On Debian and Ubuntu this is
     +++ linux-headers-`uname -r` +++
-  * On Fedora, RHEL and compatibles (e.g. CentOS) and in SUSE this is
+  * On Fedora, RHEL and compatibles (e.g. CentOS) and SUSE this is
     the kernel-devel package. Or if you run kernel-smp or kernel-xen,
     you need kernel-smp-devel or kernel-xen-devel, respectively.
   * In some distributions (e.g.: in RHEL/CentOS, Fedora, Ubuntu) the
@@ -106,6 +104,19 @@
 
   make KVERS=2.6.18.Custom
   make KSRC=/home/tzafrir/kernels/linus
+
+
+Kernel Configuration
+^^^^^^^^^^^^^^^^^^^^
+If you build a custom kernel, note the following configuration items:
+
+- CONFIG_CRC_CCITT must be enabled ('y' or 'm'). On 2.6 kernels this can
+  be selected These can be selected from the "Library Routines" submenu
+  during kernel configuration via "make menuconfig".
+- DAHDI will work if you disable module unloading. But you may need
+  extra reboots.
+- DAHDI needs the BKL (Big Kernel Lock). This may be annoying in
+  >=2.6.37 kernels. Make sure you enable CONFIG_BKL on those kernels.
 
 
 Installing to a Subtree
@@ -406,9 +417,6 @@
   +
   Some modules have "debugging flags" bits - the value of debug is a
   bitmask and several messages are printed if some bits are set:
-  - dahdi_dummy:
-    * 1: DEBUG_GENERAL - general error messages.
-    * 2: DEBUG_TICKS - Show that the module is alive :-)
   - wctdm24xxp:
     * 1: DEBUG_CARD
     * 2: DEBUG_ECHOCAN
@@ -499,9 +507,9 @@
 cards are also capable of providing timing from a clock on card. Cheap x100P
 clone cards are sometimes used for that purpose.
 
-If all the above fail, you can use the module dahdi_dummy to provide timing
-alone without needing any DAHDI hardware. It will work with most systems and
-kernels.
+If a hardware timing source either cannot be found or stops providing timing
+during runtime, DAHDI will automatically use the host timer in order provide
+timing.
 
 You can check the DAHDI timing source with dahdi_test, which is a small
 utility that is included with DAHDI. It runs in cycles. In each such cycle it
@@ -510,13 +518,6 @@
 timing device it will hang forever in the first cycle. Otherwise it will just
 give you in each cycle the percent of how close it was. Also try running it
 with the option -v for a verbose output.
-
-To check the clock source that is built into dahdi_dummy, you can either look
-at title of its span in /proc/dahdi file for a "source:" in the description.
-Or even run:
-
-  strings dahdi.ko | grep source:
-
 
 Spans and Channels
 ~~~~~~~~~~~~~~~~~~
@@ -656,8 +657,6 @@
 
 When a span is registered, it is considered "unconfigured". Only after
 dahdi_cfg has been run to apply configuration, the span is ready to run.
-The only exception to that is 'dahdi_dummy', which does not need any
-configuration.
 
 Some of the configuration is handled by the DAHDI core. Some of it is
 handled by callbacks, which are function pointers in the `struct

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/build_tools/live_dahdi
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/build_tools/live_dahdi?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/build_tools/live_dahdi (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/build_tools/live_dahdi Mon Jan 17 20:07:30 2011
@@ -29,13 +29,16 @@
 	exit 1
 fi
 
-if [ ! -d "$TOOLS_DIR" ]; then
-	echo >&2 "$0:dahdi-tools dir '$TOOLS_DIR' does not exits.  Aborting".
-	exit 1
-fi
 set -e
 LINUX_DIR_FULL=`(cd $LINUX_DIR; pwd)`
-TOOLS_DIR_FULL=`(cd $TOOLS_DIR; pwd)`
+
+set_tools_dir() {
+	if [ ! -d "$TOOLS_DIR" ]; then
+		echo >&2 "$0:dahdi-tools dir '$TOOLS_DIR' does not exits.  Aborting".
+		exit 1
+	fi
+	TOOLS_DIR_FULL=`(cd $TOOLS_DIR; pwd)`
+}
 
 # Give priority to our installed binaries:
 PATH=$DESTDIR/sbin:$DESTDIR/usr/sbin:$PATH
@@ -227,15 +230,18 @@
 case "$1" in
 configure)
 	shift
+	set_tools_dir
 	cd "$TOOLS_DIR"; ./configure --with-dahdi="$LINUX_DIR_FULL" "$@"
 	;;
 install)
 	shift
+	set_tools_dir
 	cd "$LINUX_DIR"; make install DESTDIR=$DESTDIR "$@"
 	cd "$TOOLS_DIR_FULL"; make install DESTDIR=$DESTDIR DYNFS=yes "$@"
 	;;
 config)
 	shift
+	set_tools_dir
 	cd "$TOOLS_DIR"; make config DESTDIR=$DESTDIR "$@"
 	mkdir -p $DESTDIR/etc/asterisk
 	cat >"$FIRMWARE_DIR/live-init.conf" <<EOF
@@ -244,6 +250,7 @@
 dahdiconfdir="${DESTDIR}/etc/dahdi"
 export dahdiconfdir
 EOF
+	ln -s ../../../etc/dahdi/xpp.conf "$DESTDIR/usr/share/dahdi/
 	;;
 rsync)
 	if [ $# -ne 2 ]; then

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi-base.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi-base.c Mon Jan 17 20:07:30 2011
@@ -47,6 +47,7 @@
 #include <linux/moduleparam.h>
 #include <linux/sched.h>
 #include <linux/list.h>
+#include <linux/delay.h>
 
 #ifdef HAVE_UNLOCKED_IOCTL
 #include <linux/smp_lock.h>
@@ -86,6 +87,12 @@
 
 #if defined(EMPULSE) && defined(EMFLASH)
 #error "You cannot define both EMPULSE and EMFLASH"
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+#ifndef CONFIG_BKL
+#error You must have CONFIG_BKL lock defined to build DAHDI
+#endif
 #endif
 
 /* Get helper arithmetic */
@@ -1665,6 +1672,13 @@
 #endif
 
 #ifdef CONFIG_DAHDI_NET
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+static inline struct net_device_stats *hdlc_stats(struct net_device *dev)
+{
+	return &dev->stats;
+}
+#endif
+
 #ifdef NEW_HDLC_INTERFACE
 static int dahdi_net_open(struct net_device *dev)
 {
@@ -1993,6 +2007,15 @@
 
 	might_sleep();
 
+	/* In the case of surprise removal of hardware, make sure any open
+	 * file handles to this channel are disassociated with the actual
+	 * dahdi_chan. */
+	if (chan->file) {
+		chan->file->private_data = NULL;
+		if (chan->span)
+			module_put(chan->span->ops->owner);
+	}
+
 	release_echocan(chan->ec_factory);
 
 #ifdef CONFIG_DAHDI_NET
@@ -2046,9 +2069,10 @@
 	write_unlock_irqrestore(&chan_lock, flags);
 }
 
-static ssize_t dahdi_chan_read(struct file *file, char __user *usrbuf, size_t count, int unit)
-{
-	struct dahdi_chan *chan = chans[unit];
+static ssize_t dahdi_chan_read(struct file *file, char __user *usrbuf,
+			       size_t count)
+{
+	struct dahdi_chan *chan = file->private_data;
 	int amnt;
 	int res, rv;
 	int oldbuf,x;
@@ -2057,10 +2081,19 @@
 	/* Make sure count never exceeds 65k, and make sure it's unsigned */
 	count &= 0xffff;
 
-	if (!chan)
-		return -EINVAL;
-
-	if (count < 1)
+	if (unlikely(!chan)) {
+		/* We would typically be here because of surprise hardware
+		 * removal or driver unbinding while a user space application
+		 * has a channel open.  Most telephony applications are run at
+		 * elevated priorities so this sleep can prevent the high
+		 * priority threads from consuming the CPU if they're not
+		 * expecting surprise device removal.
+		 */
+		msleep(5);
+		return -ENODEV;
+	}
+
+	if (unlikely(count < 1))
 		return -EINVAL;
 
 	for (;;) {
@@ -2172,21 +2205,30 @@
 	return range1 + range2;
 }
 
-static ssize_t dahdi_chan_write(struct file *file, const char __user *usrbuf, size_t count, int unit)
+static ssize_t dahdi_chan_write(struct file *file, const char __user *usrbuf,
+				size_t count)
 {
 	unsigned long flags;
-	struct dahdi_chan *chan = chans[unit];
+	struct dahdi_chan *chan = file->private_data;
 	int res, amnt, oldbuf, rv, x;
 
 	/* Make sure count never exceeds 65k, and make sure it's unsigned */
 	count &= 0xffff;
 
-	if (!chan)
+	if (unlikely(!chan)) {
+		/* We would typically be here because of surprise hardware
+		 * removal or driver unbinding while a user space application
+		 * has a channel open.  Most telephony applications are run at
+		 * elevated priorities so this sleep can prevent the high
+		 * priority threads from consuming the CPU if they're not
+		 * expecting surprise device removal.
+		 */
+		msleep(5);
+		return -ENODEV;
+	}
+
+	if (unlikely(count < 1))
 		return -EINVAL;
-
-	if (count < 1) {
-		return -EINVAL;
-	}
 
 	for (;;) {
 		spin_lock_irqsave(&chan->lock, flags);
@@ -2753,6 +2795,7 @@
 			res = -EBUSY;
 		else if (!test_and_set_bit(DAHDI_FLAGBIT_OPEN, &chan->flags)) {
 			unsigned long flags;
+			const struct dahdi_span_ops *ops;
 			res = initialize_channel(chan);
 			if (res) {
 				/* Reallocbufs must have failed */
@@ -2763,13 +2806,18 @@
 			if (chan->flags & DAHDI_FLAG_PSEUDO)
 				chan->flags |= DAHDI_FLAG_AUDIO;
 			if (chan->span) {
-				if (!try_module_get(chan->span->ops->owner))
+				ops = chan->span->ops;
+				if (!try_module_get(ops->owner)) {
 					res = -ENXIO;
-				else if (chan->span->ops->open)
-					res = chan->span->ops->open(chan);
+				} else if (ops->open) {
+					res = ops->open(chan);
+					if (res)
+						module_put(ops->owner);
+				}
 			}
 			if (!res) {
 				chan->file = file;
+				file->private_data = chan;
 				spin_unlock_irqrestore(&chan->lock, flags);
 			} else {
 				spin_unlock_irqrestore(&chan->lock, flags);
@@ -2934,7 +2982,7 @@
 		chan = file->private_data;
 		if (!chan)
 			return -EINVAL;
-		return dahdi_chan_read(file, usrbuf, count, chan->channo);
+		return dahdi_chan_read(file, usrbuf, count);
 	}
 
 	if (unit == 255) {
@@ -2943,12 +2991,12 @@
 			module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");
 			return -EINVAL;
 		}
-		return dahdi_chan_read(file, usrbuf, count, chan->channo);
+		return dahdi_chan_read(file, usrbuf, count);
 	}
 	if (count < 0)
 		return -EINVAL;
 
-	return dahdi_chan_read(file, usrbuf, count, unit);
+	return dahdi_chan_read(file, usrbuf, count);
 }
 
 static ssize_t dahdi_write(struct file *file, const char __user *usrbuf, size_t count, loff_t *ppos)
@@ -2966,7 +3014,7 @@
 		chan = file->private_data;
 		if (!chan)
 			return -EINVAL;
-		return dahdi_chan_write(file, usrbuf, count, chan->channo);
+		return dahdi_chan_write(file, usrbuf, count);
 	}
 	if (unit == 255) {
 		chan = file->private_data;
@@ -2974,9 +3022,9 @@
 			module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");
 			return -EINVAL;
 		}
-		return dahdi_chan_write(file, usrbuf, count, chan->channo);
-	}
-	return dahdi_chan_write(file, usrbuf, count, unit);
+		return dahdi_chan_write(file, usrbuf, count);
+	}
+	return dahdi_chan_write(file, usrbuf, count);
 
 }
 
@@ -3056,7 +3104,7 @@
 		return -ENOMEM;
 	}
 
-	ptr += sizeof(*z);
+	ptr = (char *) ptr + sizeof(*z);
 	space -= sizeof(*z);
 
 	dahdi_copy_string(z->name, work->th.name, sizeof(z->name));
@@ -3098,7 +3146,7 @@
 			t = work->samples[x] = ptr;
 
 			space -= sizeof(*t);
-			ptr += sizeof(*t);
+			ptr = (char *) ptr + sizeof(*t);
 
 			/* Remember which sample is work->next */
 			work->next[x] = work->td.next;
@@ -4134,6 +4182,15 @@
 #endif
 }
 
+#if defined(CONFIG_DAHDI_NET) && defined(HAVE_NET_DEVICE_OPS)
+static const struct net_device_ops dahdi_netdev_ops = {
+	.ndo_open       = dahdi_net_open,
+	.ndo_stop       = dahdi_net_stop,
+	.ndo_do_ioctl   = dahdi_net_ioctl,
+	.ndo_start_xmit = dahdi_xmit,
+};
+#endif
+
 static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long data)
 {
 	/* I/O CTL's for control interface */
@@ -4205,6 +4262,11 @@
 		return 0;
 	case DAHDI_SHUTDOWN:
 		CHECK_VALID_SPAN(j);
+
+		/* Unconfigure channels */
+		for (x = 0; x < spans[j]->channels; x++)
+			spans[j]->chans[x]->sig = 0;
+
 		if (spans[j]->ops->shutdown)
 			res =  spans[j]->ops->shutdown(spans[j]);
 		spans[j]->flags &= ~DAHDI_FLAG_RUNNING;
@@ -4382,9 +4444,13 @@
 #endif
 					chans[ch.chan]->hdlcnetdev->netdev->irq = chans[ch.chan]->span->irq;
 					chans[ch.chan]->hdlcnetdev->netdev->tx_queue_len = 50;
+#ifdef HAVE_NET_DEVICE_OPS
+					chans[ch.chan]->hdlcnetdev->netdev->netdev_ops = &dahdi_netdev_ops;
+#else
 					chans[ch.chan]->hdlcnetdev->netdev->do_ioctl = dahdi_net_ioctl;
 					chans[ch.chan]->hdlcnetdev->netdev->open = dahdi_net_open;
 					chans[ch.chan]->hdlcnetdev->netdev->stop = dahdi_net_stop;
+#endif
 					dev_to_hdlc(chans[ch.chan]->hdlcnetdev->netdev)->attach = dahdi_net_attach;
 					dev_to_hdlc(chans[ch.chan]->hdlcnetdev->netdev)->xmit = dahdi_xmit;
 					spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
@@ -5893,6 +5959,12 @@
 		ret = dahdi_chanandpseudo_ioctl(file, cmd, data, chan->channo);
 		goto unlock_exit;
 	}
+
+	if (!file->private_data) {
+		ret = -ENXIO;
+		goto unlock_exit;
+	}
+
 	ret = dahdi_chan_ioctl(file, cmd, data, unit);
 
 unlock_exit:
@@ -7083,7 +7155,7 @@
 {
 	union dahdi_echocan_events events = chan->ec_state->events;
 
-	if (events.CED_tx_detected) {
+	if (events.bit.CED_tx_detected) {
 		dahdi_qevent_nolock(chan, DAHDI_EVENT_TX_CED_DETECTED);
 		if (chan->ec_state) {
 			if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE)
@@ -7093,7 +7165,7 @@
 		}
 	}
 
-	if (events.CED_rx_detected) {
+	if (events.bit.CED_rx_detected) {
 		dahdi_qevent_nolock(chan, DAHDI_EVENT_RX_CED_DETECTED);
 		if (chan->ec_state) {
 			if (chan->ec_state->status.mode == ECHO_MODE_ACTIVE)
@@ -7103,18 +7175,18 @@
 		}
 	}
 
-	if (events.CNG_tx_detected)
+	if (events.bit.CNG_tx_detected)
 		dahdi_qevent_nolock(chan, DAHDI_EVENT_TX_CNG_DETECTED);
 
-	if (events.CNG_rx_detected)
+	if (events.bit.CNG_rx_detected)
 		dahdi_qevent_nolock(chan, DAHDI_EVENT_RX_CNG_DETECTED);
 
-	if (events.NLP_auto_disabled) {
+	if (events.bit.NLP_auto_disabled) {
 		dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_NLP_DISABLED);
 		chan->ec_state->status.mode = ECHO_MODE_FAX;
 	}
 
-	if (events.NLP_auto_enabled) {
+	if (events.bit.NLP_auto_enabled) {
 		dahdi_qevent_nolock(chan, DAHDI_EVENT_EC_NLP_ENABLED);
 		chan->ec_state->status.mode = ECHO_MODE_ACTIVE;
 	}
@@ -7636,8 +7708,11 @@
 #ifdef CONFIG_DAHDI_PPP
 						if (!ms->do_ppp_error)
 #endif
-							skb = dev_alloc_skb(ms->readn[ms->inreadbuf]);
+							skb = dev_alloc_skb(ms->readn[ms->inreadbuf] + 2);
 						if (skb) {
+							unsigned char cisco_addr = *(ms->readbuf[ms->inreadbuf]);
+							if (cisco_addr != 0x0f && cisco_addr != 0x8f)
+								skb_reserve(skb, 2);
 							/* XXX Get rid of this memcpy XXX */
 							memcpy(skb->data, ms->readbuf[ms->inreadbuf], ms->readn[ms->inreadbuf]);
 							skb_put(skb, ms->readn[ms->inreadbuf]);

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_dummy.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_dummy.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_dummy.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_dummy.c Mon Jan 17 20:07:30 2011
@@ -49,6 +49,7 @@
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 
 #if defined(USE_HIGHRESTIMER)
 #include <linux/hrtimer.h>

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_kb1.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_kb1.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_kb1.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_kb1.c Mon Jan 17 20:07:30 2011
@@ -266,7 +266,7 @@
 
 static inline void init_cc(struct ec_pvt *pvt, int N, int maxy, int maxu)
 {
-	void *ptr = pvt;
+	char *ptr = (char *) pvt;
 	unsigned long tmp;
 
 	/* Double-word align past end of state */
@@ -281,9 +281,9 @@
 	pvt->beta2_i = DEFAULT_BETA1_I;
   
 	/* Allocate coefficient memory */
-	pvt->a_i = ptr;
+	pvt->a_i = (int *) ptr;
 	ptr += (sizeof(int) * pvt->N_d);
-	pvt->a_s = ptr;
+	pvt->a_s = (short *) ptr;
 	ptr += (sizeof(short) * pvt->N_d);
 
 	/* Reset Y circular buffer (short version) */

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_mg2.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_mg2.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_mg2.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/dahdi_echocan_mg2.c Mon Jan 17 20:07:30 2011
@@ -307,7 +307,7 @@
 
 static inline void init_cc(struct ec_pvt *pvt, int N, int maxy, int maxu)
 {
-	void *ptr = pvt;
+	char *ptr = (char *) pvt;
 	unsigned long tmp;
 
 	/* Double-word align past end of state */
@@ -322,15 +322,15 @@
 	pvt->beta2_i = DEFAULT_BETA1_I;
   
 	/* Allocate coefficient memory */
-	pvt->a_i = ptr;
+	pvt->a_i = (int *) ptr;
 	ptr += (sizeof(int) * pvt->N_d);
-	pvt->a_s = ptr;
+	pvt->a_s = (short *) ptr;
 	ptr += (sizeof(short) * pvt->N_d);
 
 	/* Allocate backup memory */
-	pvt->b_i = ptr;
+	pvt->b_i = (int *) ptr;
 	ptr += (sizeof(int) * pvt->N_d);
-	pvt->c_i = ptr;
+	pvt->c_i = (int *) ptr;
 	ptr += (sizeof(int) * pvt->N_d);
 
 	/* Reset Y circular buffer (short version) */
@@ -387,7 +387,7 @@
 }
 
 #ifdef DC_NORMALIZE
-short inline dc_removal(int *dc_estimate, short samp)
+static inline short dc_removal(int *dc_estimate, short samp)
 {
 	*dc_estimate += ((((int)samp << 15) - *dc_estimate) >> 9);
 	return samp - (*dc_estimate >> 15);

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/firmware/Makefile
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/firmware/Makefile?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/firmware/Makefile (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/firmware/Makefile Mon Jan 17 20:07:30 2011
@@ -80,7 +80,7 @@
 		echo "Attempting to download $@"; \
 		if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi; \
 		if test ! -f $@; then exit 1; fi; \
-		(cat $@ | gzip -d | tar -xof -) \
+		(cat $@ | gzip -d | tar --no-same-owner -xf -) \
 	fi
 
 firmware-loaders: $(FWLOADERS)
@@ -89,7 +89,7 @@
 dahdi-fwload-vpmadt032-$(VPMADT032_VERSION).tar.gz:
 	@if test ! -f $@; then echo "Attempting to download $@"; $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi; \
 	if test ! -f $@; then exit 1; fi; \
-	(cd ../../..; cat drivers/dahdi/firmware/$@ | gzip -d | tar -xof -) 
+	(cd ../../..; cat drivers/dahdi/firmware/$@ | gzip -d | tar --no-same-owner -xf -)
 
 # Create object files suitable for linking against
 object-build: $(FIRMWARE) $(OBJECT_FILES)

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/hpec/dahdi_echocan_hpec.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/hpec/dahdi_echocan_hpec.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/hpec/dahdi_echocan_hpec.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/hpec/dahdi_echocan_hpec.c Mon Jan 17 20:07:30 2011
@@ -115,7 +115,7 @@
 	hpec_channel_update(pvt->hpec, isig, iref);
 }
 
-DECLARE_MUTEX(license_lock);
+DEFINE_SEMAPHORE(license_lock);
 
 static int echo_can_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
 			   struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec)

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/pciradio.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/pciradio.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/pciradio.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/pciradio.c Mon Jan 17 20:07:30 2011
@@ -1852,7 +1852,7 @@
 	}
 }
 
-static struct pci_device_id pciradio_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(pciradio_pci_tbl) = {
 	{ 0xe159, 0x0001, 0xe16b, PCI_ANY_ID, 0, 0, (unsigned long)"PCIRADIO" },
 	{ 0 }
 };

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/tor2-hw.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/tor2-hw.h?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/tor2-hw.h (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/tor2-hw.h Mon Jan 17 20:07:30 2011
@@ -108,7 +108,7 @@
 #define PCI_VENDOR_ID_PLX	0x10b5
 
 #ifdef __KERNEL__
-static struct pci_device_id tor2_pci_ids[] =
+static DEFINE_PCI_DEVICE_TABLE(tor2_pci_ids) =
 #else
 #define PCI_ANY_ID -1
 static struct tor2_pci_id {

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/GpakCust.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/GpakCust.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/GpakCust.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/GpakCust.c Mon Jan 17 20:07:30 2011
@@ -564,27 +564,45 @@
 	int res;
 	gpakPingDspStat_t pingstatus;
 	u16 version;
+	unsigned long stoptime;
+	struct device *const dev = &vpm->vb->pdev->dev;
 
 	might_sleep();
 
 	set_bit(VPM150M_HPIRESET, &vpm->control);
 	msleep(2000);
-	while (test_bit(VPM150M_HPIRESET, &vpm->control))
+	/* It should never take longer than 5 seconds. */
+	stoptime = jiffies + 3*HZ;
+	while (test_bit(VPM150M_HPIRESET, &vpm->control) &&
+	       time_before(jiffies, stoptime))
 		msleep(1);
+
+	if (time_after(jiffies, stoptime)) {
+		dev_dbg(dev, "Detected failure to clear HPIRESET.\n");
+		return -EIO;
+	}
 
 	/* Set us up to page 0 */
 	vpmadt032_setpage(vpm, 0);
 
 	res = vpmadtreg_loadfirmware(vpm->vb);
 	if (res) {
-		dev_info(&vpm->vb->pdev->dev, "Failed to load the firmware.\n");
+		dev_err(dev, "Failed to load VPMADT032 firmware.\n");
 		return res;
 	}
 	vpm->curpage = -1;
 
+	stoptime = jiffies + 3*HZ;
 	set_bit(VPM150M_SWRESET, &vpm->control);
-	while (test_bit(VPM150M_SWRESET, &vpm->control))
+	while (test_bit(VPM150M_SWRESET, &vpm->control) &&
+	       time_before(jiffies, stoptime))
 		msleep(1);
+
+	if (time_after(jiffies, stoptime)) {
+		dev_dbg(dev, "Detected failure to clear SWRESET.\n");
+		return -EIO;
+	}
+
 
 	/* Set us up to page 0 */
 	pingstatus = gpakPingDsp(vpm->dspid, &version);
@@ -606,6 +624,8 @@
 	int i;
 	u16 reg;
 	int res = -EFAULT;
+	unsigned long stoptime;
+	struct device *dev;
 	gpakPingDspStat_t pingstatus;
 
 	BUG_ON(!vpm->setchanconfig_from_state);
@@ -615,6 +635,8 @@
 	vpm->vb = vb;
 
 	might_sleep();
+
+	dev = &vpm->vb->pdev->dev;
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
 	INIT_WORK(&vpm->work, vpmadt032_bh, vpm);
@@ -622,7 +644,7 @@
 	INIT_WORK(&vpm->work, vpmadt032_bh);
 #endif
 	if (vpm->options.debug & DEBUG_VPMADT032_ECHOCAN)
-		dev_info(&vpm->vb->pdev->dev, "VPMADT032 Testing page access: ");
+		dev_info(dev, "VPMADT032 Testing page access: ");
 
 	for (i = 0; i < 0xf; i++) {
 		int x;
@@ -630,8 +652,12 @@
 			vpmadt032_setpage(vpm, i);
 			reg = vpmadt032_getpage(vpm);
 			if (reg != i) {
-				if (vpm->options.debug & DEBUG_VPMADT032_ECHOCAN)
-					dev_info(&vpm->vb->pdev->dev, "Failed: Sent %x != %x VPMADT032 Failed HI page test\n", i, reg);
+				if (vpm->options.debug &
+				    DEBUG_VPMADT032_ECHOCAN) {
+					dev_err(dev, "Failed: Sent %x != %x " \
+						"VPMADT032 Failed HI page " \
+						"test\n", i, reg);
+				}
 				res = -ENODEV;
 				goto failed_exit;
 			}
@@ -641,9 +667,17 @@
 	if (vpm->options.debug & DEBUG_VPMADT032_ECHOCAN)
 		dev_info(&vpm->vb->pdev->dev, "Passed\n");
 
+	stoptime = jiffies + 3*HZ;
 	set_bit(VPM150M_HPIRESET, &vpm->control);
-	while (test_bit(VPM150M_HPIRESET, &vpm->control))
+	while (test_bit(VPM150M_HPIRESET, &vpm->control) &&
+	       time_before(jiffies, stoptime))
 		msleep(1);
+
+	if (time_after(jiffies, stoptime)) {
+		dev_dbg(dev, "Detected failure to clear HPIRESET.\n");
+		res = -EIO;
+		goto failed_exit;
+	}
 	msleep(250);
 
 	/* Set us up to page 0 */
@@ -666,9 +700,17 @@
 	if (vpm->options.debug & DEBUG_VPMADT032_ECHOCAN)
 		printk(KERN_CONT "Passed\n");
 
+	stoptime = jiffies + 3*HZ;
 	set_bit(VPM150M_HPIRESET, &vpm->control);
-	while (test_bit(VPM150M_HPIRESET, &vpm->control))
+	while (test_bit(VPM150M_HPIRESET, &vpm->control) &&
+	       time_before(jiffies, stoptime))
 		msleep(1);
+
+	if (time_after(jiffies, stoptime)) {
+		dev_dbg(dev, "Detected failure to clear SWRESET.\n");
+		res = -EIO;
+		goto failed_exit;
+	}
 
 	res = vpmadtreg_loadfirmware(vb);
 	if (res) {
@@ -678,9 +720,18 @@
 	vpm->curpage = -1;
 
 	dev_info(&vb->pdev->dev, "Booting VPMADT032\n");
+
+	stoptime = jiffies + 3*HZ;
 	set_bit(VPM150M_SWRESET, &vpm->control);
-	while (test_bit(VPM150M_SWRESET, &vpm->control))
+	while (test_bit(VPM150M_SWRESET, &vpm->control) &&
+	       time_before(jiffies, stoptime))
 		msleep(1);
+
+	if (time_after(jiffies, stoptime)) {
+		dev_dbg(dev, "Detected failure to clear SWRESET.\n");
+		res = -EIO;
+		goto failed_exit;
+	}
 
 	pingstatus = gpakPingDsp(vpm->dspid, &vpm->version);
 
@@ -708,7 +759,13 @@
 	p->EcanTapLength = 1024;
 	p->EcanNlpType = DEFAULT_NLPTYPE;
 	p->EcanAdaptEnable = 1;
+
+#ifdef CONFIG_DAHDI_NO_ECHOCAN_DISABLE
+	p->EcanG165DetEnable = 0;
+#else
 	p->EcanG165DetEnable = 1;
+#endif
+
 	p->EcanDblTalkThresh = 6;
 	p->EcanMaxDoubleTalkThres = 40;
 	p->EcanNlpThreshold = DEFAULT_NLPTHRESH;

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/voicebus/voicebus.c Mon Jan 17 20:07:30 2011
@@ -629,19 +629,6 @@
 	spin_unlock_irqrestore(&vb->lock, flags);
 }
 
-static void
-vb_enable_io_access(struct voicebus *vb)
-{
-	u32 reg;
-	unsigned long flags;
-	BUG_ON(!vb->pdev);
-	spin_lock_irqsave(&vb->lock, flags);
-	pci_read_config_dword(vb->pdev, 0x0004, &reg);
-	reg |= 0x00000007;
-	pci_write_config_dword(vb->pdev, 0x0004, reg);
-	spin_unlock_irqrestore(&vb->lock, flags);
-}
-
 /*! \brief Resets the voicebus hardware interface. */
 static int
 vb_reset_interface(struct voicebus *vb)
@@ -649,7 +636,7 @@
 	unsigned long timeout;
 	u32 reg;
 	u32 pci_access;
-	const u32 DEFAULT_PCI_ACCESS = 0xfffc0002;
+	const u32 DEFAULT_PCI_ACCESS = 0xffdc0002;
 	u8 cache_line_size;
 	BUG_ON(in_interrupt());
 
@@ -691,8 +678,13 @@
 	} while ((reg & 0x00000001) && time_before(jiffies, timeout));
 
 	if (reg & 0x00000001) {
-		dev_warn(&vb->pdev->dev, "Did not come out of reset "
-			 "within 100ms\n");
+		if (-1 == reg) {
+			dev_err(&vb->pdev->dev,
+				"Unable to read I/O registers.\n");
+		} else {
+			dev_err(&vb->pdev->dev, "Did not come out of reset "
+				"within 100ms\n");
+		}
 		return -EIO;
 	}
 
@@ -730,11 +722,7 @@
 	return 0;
 }
 
-/**
- * voicebus_transmit - Queue a buffer on the hardware descriptor ring.
- *
- */
-int voicebus_transmit(struct voicebus *vb, struct vbb *vbb)
+static int __voicebus_transmit(struct voicebus *vb, struct vbb *vbb)
 {
 	struct voicebus_descriptor *d;
 	struct voicebus_descriptor_list *dl = &vb->txd;
@@ -758,6 +746,17 @@
 	SET_OWNED(d); /* That's it until the hardware is done with it. */
 	atomic_inc(&dl->count);
 	return 0;
+}
+
+/**
+ * voicebus_transmit - Queue a buffer on the hardware descriptor ring.
+ *
+ */
+int voicebus_transmit(struct voicebus *vb, struct vbb *vbb)
+{
+	int res = __voicebus_transmit(vb, vbb);
+	__vb_setctl(vb, 0x0008, 0x00000000);
+	return res;
 }
 EXPORT_SYMBOL(voicebus_transmit);
 
@@ -823,8 +822,9 @@
 		while (!list_empty(&buffers)) {
 			vbb = list_entry(buffers.next, struct vbb, entry);
 			list_del_init(&vbb->entry);
-			voicebus_transmit(vb, vbb);
+			__voicebus_transmit(vb, vbb);
 		}
+		__vb_setctl(vb, 0x0008, 0x00000000);
 		vb_enable_deferred(vb);
 	}
 
@@ -1120,7 +1120,7 @@
  */
 void voicebus_stop(struct voicebus *vb)
 {
-	static DECLARE_MUTEX(stop);
+	static DEFINE_SEMAPHORE(stop);
 
 	down(&stop);
 
@@ -1187,9 +1187,10 @@
 	}
 
 	release_mem_region(pci_resource_start(vb->pdev, 1),
-		pci_resource_len(vb->pdev, 1));
+			   pci_resource_len(vb->pdev, 1));
 
 	pci_iounmap(vb->pdev, vb->iobase);
+	pci_clear_mwi(vb->pdev);
 	pci_disable_device(vb->pdev);
 }
 EXPORT_SYMBOL(voicebus_release);
@@ -1293,8 +1294,9 @@
 	while (!list_empty(&buffers)) {
 		vbb = list_entry(buffers.next, struct vbb, entry);
 		list_del(&vbb->entry);
-		voicebus_transmit(vb, vbb);
-	}
+		__voicebus_transmit(vb, vbb);
+	}
+	__vb_setctl(vb, 0x0008, 0x00000000);
 
 	/* If there may still be buffers in the descriptor rings, reschedule
 	 * ourself to run again.  We essentially yield here to allow any other
@@ -1368,8 +1370,9 @@
 	while (!list_empty(&buffers)) {
 		vbb = list_entry(buffers.next, struct vbb, entry);
 		list_del(&vbb->entry);
-		voicebus_transmit(vb, vbb);
-	}
+		__voicebus_transmit(vb, vbb);
+	}
+	__vb_setctl(vb, 0x0008, 0x00000000);
 
 	/* Print any messages about soft latency bumps after we fix the transmit
 	 * descriptor ring. Otherwise it's possible to take so much time
@@ -1483,12 +1486,19 @@
 
 	if (unlikely(softunderrun)) {
 		int i;
+		unsigned long flags;
+
+		/* Disable interrupts on the local processor.  We don't want
+		 * the following process interrupted. We're 'racing' against
+		 * the hardware here.... */
+		local_irq_save(flags);
 		vb_increase_latency(vb, behind, &buffers);
-
 		d = vb_descriptor(dl, dl->head);
 		while (!OWNED(d)) {
-			if (d->buffer1 != vb->idle_vbb_dma_addr)
+			if (d->buffer1 != vb->idle_vbb_dma_addr) {
+				local_irq_restore(flags);
 				goto tx_error_exit;
+			}
 			SET_OWNED(d);
 			dl->head = (dl->head + 1) & DRING_MASK;
 			d = vb_descriptor(dl, dl->head);
@@ -1503,6 +1513,7 @@
 			dl->head = (dl->head + 1) & DRING_MASK;
 		}
 		dl->tail = dl->head;
+		local_irq_restore(flags);
 	}
 
 	d = vb_descriptor(dl, dl->tail);
@@ -1513,8 +1524,9 @@
 	while (!list_empty(&buffers)) {
 		vbb = list_entry(buffers.next, struct vbb, entry);
 		list_del(&vbb->entry);
-		voicebus_transmit(vb, vbb);
-	}
+		__voicebus_transmit(vb, vbb);
+	}
+	__vb_setctl(vb, 0x0008, 0x00000000);
 
 	/* Print any messages about soft latency bumps after we fix the transmit
 	 * descriptor ring. Otherwise it's possible to take so much time
@@ -1718,6 +1730,7 @@
 		enum voicebus_mode mode)
 {
 	int retval = 0;
+	int reserved_iomem = 0;
 
 	BUG_ON(NULL == vb);
 	BUG_ON(NULL == board_name);
@@ -1777,12 +1790,17 @@
 		goto cleanup;
 	}
 	vb->iobase = pci_iomap(vb->pdev, 1, 0);
-	if (!request_mem_region(pci_resource_start(vb->pdev, 1),
-	    pci_resource_len(vb->pdev, 1), board_name)) {
+	if (request_mem_region(pci_resource_start(vb->pdev, 1),
+			       pci_resource_len(vb->pdev, 1),
+			       board_name)) {
+		reserved_iomem = 1;
+	} else {
 		dev_err(&vb->pdev->dev, "IO Registers are in use by another "
 			"module.\n");
-		retval = -EIO;
-		goto cleanup;
+		if (!(*vb->debug)) {
+			retval = -EIO;
+			goto cleanup;
+		}
 	}
 
 	vb->idle_vbb = dma_alloc_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
@@ -1792,14 +1810,17 @@
 	   Configure the hardware interface.
 	   ---------------------------------------------------------------- */
 	if (pci_set_dma_mask(vb->pdev, DMA_BIT_MASK(32))) {
-		release_mem_region(pci_resource_start(vb->pdev, 1),
-			pci_resource_len(vb->pdev, 1));
 		dev_warn(&vb->pdev->dev, "No suitable DMA available.\n");
 		goto cleanup;
 	}
 
+	retval = pci_set_mwi(vb->pdev);
+	if (retval) {
+		dev_warn(&vb->pdev->dev, "Failed to set Memory-Write " \
+			 "Invalidate Command Bit..\n");
+	}
+
 	pci_set_master(vb->pdev);
-	vb_enable_io_access(vb);
 
 	if (vb_reset_interface(vb)) {
 		retval = -EIO;
@@ -1847,6 +1868,11 @@
 
 	if (vb->pdev)
 		pci_disable_device(vb->pdev);
+
+	if (reserved_iomem) {
+		release_mem_region(pci_resource_start(vb->pdev, 1),
+				   pci_resource_len(vb->pdev, 1));
+	}
 
 	if (0 == retval)
 		retval = -EIO;

Modified: linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c?view=diff&rev=9640&r1=9639&r2=9640
==============================================================================
--- linux/team/sruffell/dahdi-linux-2.4.1-preview/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c (original)

[... 838 lines stripped ...]



More information about the svn-commits mailing list