[dahdi-commits] sruffell: tag linux/2.1.0.4 r5865 - in /linux/tags/2.1.0.4: ./ drivers/dahdi/...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Jan 27 20:55:34 CST 2009
Author: sruffell
Date: Tue Jan 27 20:55:34 2009
New Revision: 5865
URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=5865
Log:
Merged revisions 5590,5811,5819 via svnmerge from
https://origsvn.digium.com/svn/dahdi/linux/trunk
........
r5590 | tzafrir | 2008-12-19 04:39:31 -0800 (Fri, 19 Dec 2008) | 4 lines
Fix the safety check in tor2 to be for SPANS_PER_CARD
Thanks to Eugene Teo, in a from issue #13954 .
........
r5811 | sruffell | 2009-01-25 23:19:47 -0800 (Sun, 25 Jan 2009) | 7 lines
Ensure the channel is in a good state before placing it on the chans arrays.
Also ensure that dahdi_receive holds the chan_lock while iterating over the
chans array to prevent channels from entering or leaving the array while the
interrupt handler is running.
Related to issue #14183 .
........
r5819 | sruffell | 2009-01-26 11:44:36 -0800 (Mon, 26 Jan 2009) | 3 lines
Manipulate the REGISTERED flag with atomic bitops now since the bit is set
outside the protection of any locks.
........
Modified:
linux/tags/2.1.0.4/ (props changed)
linux/tags/2.1.0.4/drivers/dahdi/dahdi-base.c
linux/tags/2.1.0.4/drivers/dahdi/dahdi_dynamic.c
linux/tags/2.1.0.4/drivers/dahdi/tor2.c
linux/tags/2.1.0.4/drivers/dahdi/wct1xxp.c
linux/tags/2.1.0.4/drivers/dahdi/wct4xxp/base.c
linux/tags/2.1.0.4/drivers/dahdi/wcte11xp.c
linux/tags/2.1.0.4/drivers/dahdi/wcte12xp/base.c
linux/tags/2.1.0.4/include/dahdi/kernel.h
Propchange: linux/tags/2.1.0.4/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: linux/tags/2.1.0.4/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/dahdi-base.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/dahdi-base.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/dahdi-base.c Tue Jan 27 20:55:34 2009
@@ -1161,6 +1161,14 @@
#endif
}
+/**
+ * close_channel - close the channel, resetting any channel variables
+ * @chan: the dahdi_chan to close
+ *
+ * This function might be called before the channel is placed on the global
+ * array of channels, (chans), and therefore, neither this function nor it's
+ * children should depend on the dahdi_chan.channo member which is not set yet.
+ */
static void close_channel(struct dahdi_chan *chan)
{
unsigned long flags;
@@ -1478,43 +1486,43 @@
static int dahdi_chan_reg(struct dahdi_chan *chan)
{
int x;
- int res = 0;
unsigned long flags;
might_sleep();
+
+ spin_lock_init(&chan->lock);
+ if (!chan->master)
+ chan->master = chan;
+ if (!chan->readchunk)
+ chan->readchunk = chan->sreadchunk;
+ if (!chan->writechunk)
+ chan->writechunk = chan->swritechunk;
+ dahdi_set_law(chan, 0);
+ close_channel(chan);
write_lock_irqsave(&chan_lock, flags);
for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
if (chans[x])
continue;
- spin_lock_init(&chan->lock);
chans[x] = chan;
if (maxchans < x + 1)
maxchans = x + 1;
chan->channo = x;
- if (!chan->master)
- chan->master = chan;
- if (!chan->readchunk)
- 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
HDLC channels wont cause hangage */
- chan->flags |= DAHDI_FLAG_REGISTERED;
- res = 0;
+ set_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags);
break;
}
if (DAHDI_MAX_CHANNELS == x) {
write_unlock_irqrestore(&chan_lock, flags);
module_printk(KERN_ERR, "No more channels available\n");
- }
-
- return res;
+ return -ENOMEM;
+ }
+
+ return 0;
}
char *dahdi_lboname(int x)
@@ -1877,9 +1885,9 @@
}
#endif
write_lock_irqsave(&chan_lock, flags);
- if (chan->flags & DAHDI_FLAG_REGISTERED) {
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags)) {
chans[chan->channo] = NULL;
- chan->flags &= ~DAHDI_FLAG_REGISTERED;
+ clear_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags);
}
#ifdef CONFIG_DAHDI_PPP
if (chan->ppp) {
@@ -2355,7 +2363,7 @@
}
/* if not registered yet, just return here */
- if (!(chan->flags & DAHDI_FLAG_REGISTERED))
+ if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags))
return res;
/* Mark all buffers as empty */
@@ -5353,7 +5361,7 @@
if (!span)
return -EINVAL;
- if (span->flags & DAHDI_FLAG_REGISTERED) {
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
module_printk(KERN_ERR, "Span %s already appears to be registered\n", span->name);
return -EBUSY;
}
@@ -5379,7 +5387,7 @@
return -EBUSY;
}
- span->flags |= DAHDI_FLAG_REGISTERED;
+ set_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags);
span->spanno = x;
spin_lock_init(&span->lock);
@@ -5447,7 +5455,7 @@
char tempfile[17];
#endif /* CONFIG_PROC_FS */
- if (!(span->flags & DAHDI_FLAG_REGISTERED)) {
+ if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
module_printk(KERN_ERR, "Span %s does not appear to be registered\n", span->name);
return -1;
}
@@ -5474,7 +5482,7 @@
spans[span->spanno] = NULL;
span->spanno = 0;
- span->flags &= ~DAHDI_FLAG_REGISTERED;
+ clear_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags);
for (x=0;x<span->channels;x++)
dahdi_chan_unreg(span->chans[x]);
new_maxspans = 0;
@@ -7606,7 +7614,7 @@
int dahdi_receive(struct dahdi_span *span)
{
int x,y,z;
- unsigned long flags, flagso;
+ unsigned long flags;
#if 1
#ifdef CONFIG_DAHDI_WATCHDOG
@@ -7688,7 +7696,8 @@
if (span == master) {
/* Hold the big zap lock for the duration of major
activities which touch all sorts of channels */
- spin_lock_irqsave(&bigzaplock, flagso);
+ spin_lock_irqsave(&bigzaplock, flags);
+ read_lock(&chan_lock);
/* Process any timers */
process_timers();
/* If we have dynamic stuff, call the ioctl with 0,0 parameters to
@@ -7698,12 +7707,12 @@
for (x=1;x<maxchans;x++) {
if (chans[x] && chans[x]->confmode && !(chans[x]->flags & DAHDI_FLAG_PSEUDO)) {
u_char *data;
- spin_lock_irqsave(&chans[x]->lock, flags);
+ spin_lock(&chans[x]->lock);
data = __buf_peek(&chans[x]->confin);
__dahdi_receive_chunk(chans[x], data);
if (data)
__buf_pull(&chans[x]->confin, NULL,chans[x], "confreceive");
- spin_unlock_irqrestore(&chans[x]->lock, flags);
+ spin_unlock(&chans[x]->lock);
}
}
/* This is the master channel, so make things switch over */
@@ -7711,9 +7720,9 @@
/* do all the pseudo and/or conferenced channel receives (getbuf's) */
for (x=1;x<maxchans;x++) {
if (chans[x] && (chans[x]->flags & DAHDI_FLAG_PSEUDO)) {
- spin_lock_irqsave(&chans[x]->lock, flags);
+ spin_lock(&chans[x]->lock);
__dahdi_transmit_chunk(chans[x], NULL);
- spin_unlock_irqrestore(&chans[x]->lock, flags);
+ spin_unlock(&chans[x]->lock);
}
}
if (maxlinks) {
@@ -7736,21 +7745,21 @@
for (x=1;x<maxchans;x++) {
if (chans[x] && (chans[x]->flags & DAHDI_FLAG_PSEUDO)) {
unsigned char tmp[DAHDI_CHUNKSIZE];
- spin_lock_irqsave(&chans[x]->lock, flags);
+ spin_lock(&chans[x]->lock);
__dahdi_getempty(chans[x], tmp);
__dahdi_receive_chunk(chans[x], tmp);
- spin_unlock_irqrestore(&chans[x]->lock, flags);
+ spin_unlock(&chans[x]->lock);
}
}
for (x=1;x<maxchans;x++) {
if (chans[x] && chans[x]->confmode && !(chans[x]->flags & DAHDI_FLAG_PSEUDO)) {
u_char *data;
- spin_lock_irqsave(&chans[x]->lock, flags);
+ spin_lock(&chans[x]->lock);
data = __buf_pushpeek(&chans[x]->confout);
__dahdi_transmit_chunk(chans[x], data);
if (data)
__buf_push(&chans[x]->confout, NULL, "conftransmit");
- spin_unlock_irqrestore(&chans[x]->lock, flags);
+ spin_unlock(&chans[x]->lock);
}
}
#ifdef DAHDI_SYNC_TICK
@@ -7761,7 +7770,8 @@
s->sync_tick(s, s == master);
}
#endif
- spin_unlock_irqrestore(&bigzaplock, flagso);
+ read_unlock(&chan_lock);
+ spin_unlock_irqrestore(&bigzaplock, flags);
}
#endif
return 0;
Modified: linux/tags/2.1.0.4/drivers/dahdi/dahdi_dynamic.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/dahdi_dynamic.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/dahdi_dynamic.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/dahdi_dynamic.c Tue Jan 27 20:55:34 2009
@@ -414,7 +414,7 @@
unsigned int x;
/* Unregister span if appropriate */
- if (z->span.flags & DAHDI_FLAG_REGISTERED)
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &z->span.flags))
dahdi_unregister(&z->span);
/* Destroy the pvt stuff if there */
Modified: linux/tags/2.1.0.4/drivers/dahdi/tor2.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/tor2.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/tor2.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/tor2.c Tue Jan 27 20:55:34 2009
@@ -200,7 +200,7 @@
if (debug)
printk(KERN_INFO "Tor2: Configuring span %d\n", span->spanno);
- if ((lc->sync < 0) || (lc->sync >= MAX_TOR_CARDS)) {
+ if ((lc->sync < 0) || (lc->sync >= SPANS_PER_CARD)) {
printk(KERN_WARNING "%s %d: invalid span timing value %d.\n",
THIS_MODULE->name, span->spanno, lc->sync);
return -EINVAL;
@@ -314,7 +314,7 @@
static int __devinit tor2_launch(struct tor2 *tor)
{
- if (tor->spans[0].flags & DAHDI_FLAG_REGISTERED)
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &tor->spans[0].flags))
return 0;
printk(KERN_INFO "Tor2: Launching card: %d\n", tor->order);
if (dahdi_register(&tor->spans[0], 0)) {
@@ -618,6 +618,7 @@
static void __devexit tor2_remove(struct pci_dev *pdev)
{
struct tor2 *tor;
+ int i;
tor = pci_get_drvdata(pdev);
if (!tor)
@@ -627,14 +628,10 @@
tor->mem8[LEDREG] = 0;
tor->plx[INTCSR] = cpu_to_le16(0);
free_irq(tor->irq, tor);
- if (tor->spans[0].flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&tor->spans[0]);
- if (tor->spans[1].flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&tor->spans[1]);
- if (tor->spans[2].flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&tor->spans[2]);
- if (tor->spans[3].flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&tor->spans[3]);
+ for (i = 0; i < SPANS_PER_CARD; ++i) {
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &tor->spans[i].flags))
+ dahdi_unregister(&tor->spans[i]);
+ }
release_mem_region(tor->plx_region, tor->plx_len);
release_mem_region(tor->xilinx32_region, tor->xilinx32_len);
release_mem_region(tor->xilinx8_region, tor->xilinx8_len);
Modified: linux/tags/2.1.0.4/drivers/dahdi/wct1xxp.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/wct1xxp.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/wct1xxp.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/wct1xxp.c Tue Jan 27 20:55:34 2009
@@ -624,7 +624,7 @@
t1xxp_e1_framer_start(wc);
else
t1xxp_t1_framer_start(wc);
- printk(KERN_INFO "Calling startup (flags is %d)\n", span->flags);
+ printk(KERN_INFO "Calling startup (flags is %lu)\n", span->flags);
if (!alreadyrunning) {
/* Only if we're not already going */
Modified: linux/tags/2.1.0.4/drivers/dahdi/wct4xxp/base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/wct4xxp/base.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/wct4xxp/base.c Tue Jan 27 20:55:34 2009
@@ -3441,7 +3441,7 @@
{
int x;
unsigned long flags;
- if (wc->tspans[0]->span.flags & DAHDI_FLAG_REGISTERED)
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &wc->tspans[0]->span.flags))
return 0;
printk(KERN_INFO "TE%dXXP: Launching card: %d\n", wc->numspans, wc->order);
@@ -3726,6 +3726,8 @@
static void __devexit t4_remove_one(struct pci_dev *pdev)
{
struct t4 *wc = pci_get_drvdata(pdev);
+ struct dahdi_span *span;
+ int i;
if (!wc) {
return;
@@ -3739,15 +3741,11 @@
release_vpm450m(wc->vpm450m);
wc->vpm450m = NULL;
/* Unregister spans */
- if (wc->tspans[0]->span.flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&wc->tspans[0]->span);
- if (wc->tspans[1]->span.flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&wc->tspans[1]->span);
- if (wc->numspans == 4) {
- if (wc->tspans[2]->span.flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&wc->tspans[2]->span);
- if (wc->tspans[3]->span.flags & DAHDI_FLAG_REGISTERED)
- dahdi_unregister(&wc->tspans[3]->span);
+
+ for (i = 0; i < wc->numspans; ++i) {
+ span = &wc->tspans[i]->span;
+ if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags))
+ dahdi_unregister(span);
}
#ifdef ENABLE_WORKQUEUES
if (wc->workq) {
Modified: linux/tags/2.1.0.4/drivers/dahdi/wcte11xp.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/wcte11xp.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/wcte11xp.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/wcte11xp.c Tue Jan 27 20:55:34 2009
@@ -898,7 +898,7 @@
/* Reset framer with proper parameters and start */
t1xxp_framer_start(wc, span);
- printk(KERN_INFO "Calling startup (flags is %d)\n", span->flags);
+ printk(KERN_INFO "Calling startup (flags is %lu)\n", span->flags);
if (!alreadyrunning) {
/* Only if we're not already going */
Modified: linux/tags/2.1.0.4/drivers/dahdi/wcte12xp/base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/drivers/dahdi/wcte12xp/base.c?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/tags/2.1.0.4/drivers/dahdi/wcte12xp/base.c Tue Jan 27 20:55:34 2009
@@ -697,7 +697,7 @@
/* Reset framer with proper parameters and start */
t1xxp_framer_start(wc, span);
- debug_printk(1, "Calling startup (flags is %d)\n", span->flags);
+ debug_printk(1, "Calling startup (flags is %lu)\n", span->flags);
return 0;
}
Modified: linux/tags/2.1.0.4/include/dahdi/kernel.h
URL: http://svn.digium.com/svn-view/dahdi/linux/tags/2.1.0.4/include/dahdi/kernel.h?view=diff&rev=5865&r1=5864&r2=5865
==============================================================================
--- linux/tags/2.1.0.4/include/dahdi/kernel.h (original)
+++ linux/tags/2.1.0.4/include/dahdi/kernel.h Tue Jan 27 20:55:34 2009
@@ -519,7 +519,7 @@
char location[40]; /*!< span device's location in system */
int deflaw; /*!< Default law (DAHDI_MULAW or DAHDI_ALAW) */
int alarms; /*!< Pending alarms on span */
- int flags;
+ unsigned long flags;
int irq; /*!< IRQ for this span's hardware */
int lbo; /*!< Span Line-Buildout */
int lineconfig; /*!< Span line configuration */
More information about the dahdi-commits
mailing list