[svn-commits] sruffell: linux/trunk r5275 - in /linux/trunk/drivers/dahdi: ./ wcte12xp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Nov 10 13:48:22 CST 2008


Author: sruffell
Date: Mon Nov 10 13:48:22 2008
New Revision: 5275

URL: http://svn.digium.com/view/dahdi?view=rev&rev=5275
Log:
- Do not hold any locks while calling close_channel, which can result in calls
  to the echocan modules which do not necesarrily assume they are being called
  in atomic context.
- Remove the bigzaplock around calls to psuedo_alloc and pseudo_free.  The
  structures protected by this lock are already protected by the chan_lock in
  these two cases.
- Remove calls to in_atomic() that were previously added to work around this,
  but did not cover all the cases.

Issue: DAHDI-195, DAHDI-170

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c
    linux/trunk/drivers/dahdi/wcte12xp/base.c

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=5275&r1=5274&r2=5275
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Nov 10 13:48:22 2008
@@ -48,7 +48,6 @@
 #include <linux/kmod.h>
 #include <linux/moduleparam.h>
 #include <linux/list.h>
-#include <linux/interrupt.h>
 
 #ifdef CONFIG_DAHDI_NET
 #include <linux/netdevice.h>
@@ -868,7 +867,7 @@
 
 	/* We need to allocate our buffers now */
 	if (j) {
-		if(!(newbuf = kcalloc(j * 2, numbufs, (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL)))
+		if (!(newbuf = kcalloc(j * 2, numbufs, GFP_KERNEL)))
 			return -ENOMEM;
 	} else
 		newbuf = NULL;
@@ -1148,6 +1147,8 @@
 #ifdef CONFIG_DAHDI_PPP
 	struct ppp_channel *ppp;
 #endif
+
+	might_sleep();
 
 	/* XXX Buffers should be send out before reallocation!!! XXX */
 	if (!(chan->flags & DAHDI_FLAG_NOSTDTXRX))
@@ -1455,6 +1456,8 @@
 	int res = 0;
 	unsigned long flags;
 
+	might_sleep();
+
 	write_lock_irqsave(&chan_lock, flags);
 	for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
 		if (chans[x])
@@ -1471,6 +1474,7 @@
 			chan->readchunk = chan->sreadchunk;
 		if (!chan->writechunk)
 			chan->writechunk = chan->swritechunk;
+		write_unlock_irqrestore(&chan_lock, flags);
 		dahdi_set_law(chan, 0);
 		close_channel(chan);
 		/* set this AFTER running close_channel() so that
@@ -1479,10 +1483,11 @@
 		res = 0;
 		break;
 	}
-	write_unlock_irqrestore(&chan_lock, flags);
-
-	if (x == DAHDI_MAX_CHANNELS)
+
+	if (DAHDI_MAX_CHANNELS == x) {
+		write_unlock_irqrestore(&chan_lock, flags);
 		module_printk(KERN_ERR, "No more channels available\n");
+	}
 
 	return res;
 }
@@ -1835,6 +1840,9 @@
 {
 	int x;
 	unsigned long flags;
+
+	might_sleep();
+
 #ifdef CONFIG_DAHDI_NET
 	if (chan->flags & DAHDI_FLAG_NETDEV) {
 		unregister_hdlc_device(chan->hdlcnetdev->netdev);
@@ -2600,7 +2608,6 @@
 static struct dahdi_chan *dahdi_alloc_pseudo(void)
 {
 	struct dahdi_chan *pseudo;
-	unsigned long flags;
 
 	/* Don't allow /dev/dahdi/pseudo to open if there are no spans */
 	if (maxspans < 1)
@@ -2613,24 +2620,20 @@
 	pseudo->sigcap = DAHDI_SIG_CLEAR;
 	pseudo->flags = DAHDI_FLAG_PSEUDO | DAHDI_FLAG_AUDIO;
 
-	spin_lock_irqsave(&bigzaplock, flags);
 	if (dahdi_chan_reg(pseudo)) {
 		kfree(pseudo);
 		pseudo = NULL;
-	} else
-		sprintf(pseudo->name, "Pseudo/%d", pseudo->channo);
-	spin_unlock_irqrestore(&bigzaplock, flags);
+	} else {
+		sprintf(pseudo->name, "Pseudo/%d", pseudo->channo); 
+	}
 
 	return pseudo;
 }
 
 static void dahdi_free_pseudo(struct dahdi_chan *pseudo)
 {
-	unsigned long flags;
 	if (pseudo) {
-		spin_lock_irqsave(&bigzaplock, flags);
 		dahdi_chan_unreg(pseudo);
-		spin_unlock_irqrestore(&bigzaplock, flags);
 		kfree(pseudo);
 	}
 }

Modified: linux/trunk/drivers/dahdi/wcte12xp/base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wcte12xp/base.c?view=diff&rev=5275&r1=5274&r2=5275
==============================================================================
--- linux/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcte12xp/base.c Mon Nov 10 13:48:22 2008
@@ -35,7 +35,6 @@
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/moduleparam.h>
-#include <linux/interrupt.h>
 
 #include <dahdi/kernel.h>
 
@@ -1071,7 +1070,7 @@
 	   to control whether the ec is on or off, so translate it */
 	params.tap_length = ecp->tap_length ? 1 : 0;
 
-	if (!(work = kmalloc(sizeof(*work), (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL)))
+	if (!(work = kmalloc(sizeof(*work), GFP_KERNEL)))
 		return -ENOMEM;
 
 	work->params = params;




More information about the svn-commits mailing list