Commit 252aa9d9 authored by David S. Miller's avatar David S. Miller

Revert "NET: Fix locking issues in PPP, 6pack, mkiss and strip line disciplines."

This reverts commit adeab1af.

As Alan Cox explained, the TTY layer changes that went recently
to get rid of the tty->low_latency stuff fixes this already,
and even for -stable it's the ->low_latency changes that should
go in to fix this, rather than this patch.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8660c124
...@@ -398,14 +398,13 @@ static DEFINE_RWLOCK(disc_data_lock); ...@@ -398,14 +398,13 @@ static DEFINE_RWLOCK(disc_data_lock);
static struct sixpack *sp_get(struct tty_struct *tty) static struct sixpack *sp_get(struct tty_struct *tty)
{ {
unsigned long flags;
struct sixpack *sp; struct sixpack *sp;
read_lock_irqsave(&disc_data_lock, flags); read_lock(&disc_data_lock);
sp = tty->disc_data; sp = tty->disc_data;
if (sp) if (sp)
atomic_inc(&sp->refcnt); atomic_inc(&sp->refcnt);
read_unlock_irqrestore(&disc_data_lock, flags); read_unlock(&disc_data_lock);
return sp; return sp;
} }
...@@ -689,13 +688,12 @@ static int sixpack_open(struct tty_struct *tty) ...@@ -689,13 +688,12 @@ static int sixpack_open(struct tty_struct *tty)
*/ */
static void sixpack_close(struct tty_struct *tty) static void sixpack_close(struct tty_struct *tty)
{ {
unsigned long flags;
struct sixpack *sp; struct sixpack *sp;
write_lock_irqsave(&disc_data_lock, flags); write_lock(&disc_data_lock);
sp = tty->disc_data; sp = tty->disc_data;
tty->disc_data = NULL; tty->disc_data = NULL;
write_unlock_irqrestore(&disc_data_lock, flags); write_unlock(&disc_data_lock);
if (!sp) if (!sp)
return; return;
......
...@@ -244,16 +244,15 @@ static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc, ...@@ -244,16 +244,15 @@ static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc,
/* Send one completely decapsulated AX.25 packet to the AX.25 layer. */ /* Send one completely decapsulated AX.25 packet to the AX.25 layer. */
static void ax_bump(struct mkiss *ax) static void ax_bump(struct mkiss *ax)
{ {
unsigned long flags;
struct sk_buff *skb; struct sk_buff *skb;
int count; int count;
spin_lock_irqsave(&ax->buflock, flags); spin_lock_bh(&ax->buflock);
if (ax->rbuff[0] > 0x0f) { if (ax->rbuff[0] > 0x0f) {
if (ax->rbuff[0] & 0x80) { if (ax->rbuff[0] & 0x80) {
if (check_crc_16(ax->rbuff, ax->rcount) < 0) { if (check_crc_16(ax->rbuff, ax->rcount) < 0) {
ax->dev->stats.rx_errors++; ax->dev->stats.rx_errors++;
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
return; return;
} }
...@@ -268,7 +267,7 @@ static void ax_bump(struct mkiss *ax) ...@@ -268,7 +267,7 @@ static void ax_bump(struct mkiss *ax)
} else if (ax->rbuff[0] & 0x20) { } else if (ax->rbuff[0] & 0x20) {
if (check_crc_flex(ax->rbuff, ax->rcount) < 0) { if (check_crc_flex(ax->rbuff, ax->rcount) < 0) {
ax->dev->stats.rx_errors++; ax->dev->stats.rx_errors++;
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
return; return;
} }
if (ax->crcmode != CRC_MODE_FLEX && ax->crcauto) { if (ax->crcmode != CRC_MODE_FLEX && ax->crcauto) {
...@@ -295,7 +294,7 @@ static void ax_bump(struct mkiss *ax) ...@@ -295,7 +294,7 @@ static void ax_bump(struct mkiss *ax)
printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n", printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n",
ax->dev->name); ax->dev->name);
ax->dev->stats.rx_dropped++; ax->dev->stats.rx_dropped++;
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
return; return;
} }
...@@ -304,13 +303,11 @@ static void ax_bump(struct mkiss *ax) ...@@ -304,13 +303,11 @@ static void ax_bump(struct mkiss *ax)
netif_rx(skb); netif_rx(skb);
ax->dev->stats.rx_packets++; ax->dev->stats.rx_packets++;
ax->dev->stats.rx_bytes += count; ax->dev->stats.rx_bytes += count;
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
} }
static void kiss_unesc(struct mkiss *ax, unsigned char s) static void kiss_unesc(struct mkiss *ax, unsigned char s)
{ {
unsigned long flags;
switch (s) { switch (s) {
case END: case END:
/* drop keeptest bit = VSV */ /* drop keeptest bit = VSV */
...@@ -337,18 +334,18 @@ static void kiss_unesc(struct mkiss *ax, unsigned char s) ...@@ -337,18 +334,18 @@ static void kiss_unesc(struct mkiss *ax, unsigned char s)
break; break;
} }
spin_lock_irqsave(&ax->buflock, flags); spin_lock_bh(&ax->buflock);
if (!test_bit(AXF_ERROR, &ax->flags)) { if (!test_bit(AXF_ERROR, &ax->flags)) {
if (ax->rcount < ax->buffsize) { if (ax->rcount < ax->buffsize) {
ax->rbuff[ax->rcount++] = s; ax->rbuff[ax->rcount++] = s;
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
return; return;
} }
ax->dev->stats.rx_over_errors++; ax->dev->stats.rx_over_errors++;
set_bit(AXF_ERROR, &ax->flags); set_bit(AXF_ERROR, &ax->flags);
} }
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
} }
static int ax_set_mac_address(struct net_device *dev, void *addr) static int ax_set_mac_address(struct net_device *dev, void *addr)
...@@ -370,7 +367,6 @@ static void ax_changedmtu(struct mkiss *ax) ...@@ -370,7 +367,6 @@ static void ax_changedmtu(struct mkiss *ax)
{ {
struct net_device *dev = ax->dev; struct net_device *dev = ax->dev;
unsigned char *xbuff, *rbuff, *oxbuff, *orbuff; unsigned char *xbuff, *rbuff, *oxbuff, *orbuff;
unsigned long flags;
int len; int len;
len = dev->mtu * 2; len = dev->mtu * 2;
...@@ -396,7 +392,7 @@ static void ax_changedmtu(struct mkiss *ax) ...@@ -396,7 +392,7 @@ static void ax_changedmtu(struct mkiss *ax)
return; return;
} }
spin_lock_irqsave(&ax->buflock, flags); spin_lock_bh(&ax->buflock);
oxbuff = ax->xbuff; oxbuff = ax->xbuff;
ax->xbuff = xbuff; ax->xbuff = xbuff;
...@@ -427,7 +423,7 @@ static void ax_changedmtu(struct mkiss *ax) ...@@ -427,7 +423,7 @@ static void ax_changedmtu(struct mkiss *ax)
ax->mtu = dev->mtu + 73; ax->mtu = dev->mtu + 73;
ax->buffsize = len; ax->buffsize = len;
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
kfree(oxbuff); kfree(oxbuff);
kfree(orbuff); kfree(orbuff);
...@@ -437,7 +433,6 @@ static void ax_changedmtu(struct mkiss *ax) ...@@ -437,7 +433,6 @@ static void ax_changedmtu(struct mkiss *ax)
static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
{ {
struct mkiss *ax = netdev_priv(dev); struct mkiss *ax = netdev_priv(dev);
unsigned long flags;
unsigned char *p; unsigned char *p;
int actual, count; int actual, count;
...@@ -454,7 +449,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) ...@@ -454,7 +449,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
p = icp; p = icp;
spin_lock_irqsave(&ax->buflock, flags); spin_lock_bh(&ax->buflock);
if ((*p & 0x0f) != 0) { if ((*p & 0x0f) != 0) {
/* Configuration Command (kissparms(1). /* Configuration Command (kissparms(1).
* Protocol spec says: never append CRC. * Protocol spec says: never append CRC.
...@@ -484,7 +479,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) ...@@ -484,7 +479,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
ax->crcauto = (cmd ? 0 : 1); ax->crcauto = (cmd ? 0 : 1);
printk(KERN_INFO "mkiss: %s: crc mode %s %d\n", ax->dev->name, (len) ? "set to" : "is", cmd); printk(KERN_INFO "mkiss: %s: crc mode %s %d\n", ax->dev->name, (len) ? "set to" : "is", cmd);
} }
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
netif_start_queue(dev); netif_start_queue(dev);
return; return;
...@@ -517,7 +512,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len) ...@@ -517,7 +512,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
count = kiss_esc(p, (unsigned char *)ax->xbuff, len); count = kiss_esc(p, (unsigned char *)ax->xbuff, len);
} }
} }
spin_unlock_irqrestore(&ax->buflock, flags); spin_unlock_bh(&ax->buflock);
set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
actual = ax->tty->ops->write(ax->tty, ax->xbuff, count); actual = ax->tty->ops->write(ax->tty, ax->xbuff, count);
...@@ -709,14 +704,13 @@ static DEFINE_RWLOCK(disc_data_lock); ...@@ -709,14 +704,13 @@ static DEFINE_RWLOCK(disc_data_lock);
static struct mkiss *mkiss_get(struct tty_struct *tty) static struct mkiss *mkiss_get(struct tty_struct *tty)
{ {
unsigned long flags;
struct mkiss *ax; struct mkiss *ax;
read_lock_irqsave(&disc_data_lock, flags); read_lock(&disc_data_lock);
ax = tty->disc_data; ax = tty->disc_data;
if (ax) if (ax)
atomic_inc(&ax->refcnt); atomic_inc(&ax->refcnt);
read_unlock_irqrestore(&disc_data_lock, flags); read_unlock(&disc_data_lock);
return ax; return ax;
} }
...@@ -815,13 +809,12 @@ static int mkiss_open(struct tty_struct *tty) ...@@ -815,13 +809,12 @@ static int mkiss_open(struct tty_struct *tty)
static void mkiss_close(struct tty_struct *tty) static void mkiss_close(struct tty_struct *tty)
{ {
unsigned long flags;
struct mkiss *ax; struct mkiss *ax;
write_lock_irqsave(&disc_data_lock, flags); write_lock(&disc_data_lock);
ax = tty->disc_data; ax = tty->disc_data;
tty->disc_data = NULL; tty->disc_data = NULL;
write_unlock_irqrestore(&disc_data_lock, flags); write_unlock(&disc_data_lock);
if (!ax) if (!ax)
return; return;
......
...@@ -132,15 +132,13 @@ static DEFINE_RWLOCK(disc_data_lock); ...@@ -132,15 +132,13 @@ static DEFINE_RWLOCK(disc_data_lock);
static struct asyncppp *ap_get(struct tty_struct *tty) static struct asyncppp *ap_get(struct tty_struct *tty)
{ {
unsigned long flags;
struct asyncppp *ap; struct asyncppp *ap;
read_lock_irqsave(&disc_data_lock, flags); read_lock(&disc_data_lock);
ap = tty->disc_data; ap = tty->disc_data;
if (ap != NULL) if (ap != NULL)
atomic_inc(&ap->refcnt); atomic_inc(&ap->refcnt);
read_unlock_irqrestore(&disc_data_lock, flags); read_unlock(&disc_data_lock);
return ap; return ap;
} }
...@@ -217,13 +215,12 @@ ppp_asynctty_open(struct tty_struct *tty) ...@@ -217,13 +215,12 @@ ppp_asynctty_open(struct tty_struct *tty)
static void static void
ppp_asynctty_close(struct tty_struct *tty) ppp_asynctty_close(struct tty_struct *tty)
{ {
unsigned long flags;
struct asyncppp *ap; struct asyncppp *ap;
write_lock_irqsave(&disc_data_lock, flags); write_lock_irq(&disc_data_lock);
ap = tty->disc_data; ap = tty->disc_data;
tty->disc_data = NULL; tty->disc_data = NULL;
write_unlock_irqrestore(&disc_data_lock, flags); write_unlock_irq(&disc_data_lock);
if (!ap) if (!ap)
return; return;
......
...@@ -182,15 +182,13 @@ static DEFINE_RWLOCK(disc_data_lock); ...@@ -182,15 +182,13 @@ static DEFINE_RWLOCK(disc_data_lock);
static struct syncppp *sp_get(struct tty_struct *tty) static struct syncppp *sp_get(struct tty_struct *tty)
{ {
unsigned long flags;
struct syncppp *ap; struct syncppp *ap;
read_lock_irqsave(&disc_data_lock, flags); read_lock(&disc_data_lock);
ap = tty->disc_data; ap = tty->disc_data;
if (ap != NULL) if (ap != NULL)
atomic_inc(&ap->refcnt); atomic_inc(&ap->refcnt);
read_unlock_irqrestore(&disc_data_lock, flags); read_unlock(&disc_data_lock);
return ap; return ap;
} }
...@@ -264,13 +262,12 @@ ppp_sync_open(struct tty_struct *tty) ...@@ -264,13 +262,12 @@ ppp_sync_open(struct tty_struct *tty)
static void static void
ppp_sync_close(struct tty_struct *tty) ppp_sync_close(struct tty_struct *tty)
{ {
unsigned long flags;
struct syncppp *ap; struct syncppp *ap;
write_lock_irqsave(&disc_data_lock, flags); write_lock_irq(&disc_data_lock);
ap = tty->disc_data; ap = tty->disc_data;
tty->disc_data = NULL; tty->disc_data = NULL;
write_unlock_irqrestore(&disc_data_lock, flags); write_unlock_irq(&disc_data_lock);
if (!ap) if (!ap)
return; return;
......
...@@ -856,7 +856,6 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu) ...@@ -856,7 +856,6 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu)
unsigned char *orbuff = strip_info->rx_buff; unsigned char *orbuff = strip_info->rx_buff;
unsigned char *osbuff = strip_info->sx_buff; unsigned char *osbuff = strip_info->sx_buff;
unsigned char *otbuff = strip_info->tx_buff; unsigned char *otbuff = strip_info->tx_buff;
unsigned long flags;
if (new_mtu > MAX_SEND_MTU) { if (new_mtu > MAX_SEND_MTU) {
printk(KERN_ERR printk(KERN_ERR
...@@ -865,11 +864,11 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu) ...@@ -865,11 +864,11 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu)
return -EINVAL; return -EINVAL;
} }
spin_lock_irqsave(&strip_lock, flags); spin_lock_bh(&strip_lock);
if (!allocate_buffers(strip_info, new_mtu)) { if (!allocate_buffers(strip_info, new_mtu)) {
printk(KERN_ERR "%s: unable to grow strip buffers, MTU change cancelled.\n", printk(KERN_ERR "%s: unable to grow strip buffers, MTU change cancelled.\n",
strip_info->dev->name); strip_info->dev->name);
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
return -ENOMEM; return -ENOMEM;
} }
...@@ -893,7 +892,7 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu) ...@@ -893,7 +892,7 @@ static int strip_change_mtu(struct net_device *dev, int new_mtu)
} }
} }
strip_info->tx_head = strip_info->tx_buff; strip_info->tx_head = strip_info->tx_buff;
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
printk(KERN_NOTICE "%s: strip MTU changed fom %d to %d.\n", printk(KERN_NOTICE "%s: strip MTU changed fom %d to %d.\n",
strip_info->dev->name, old_mtu, strip_info->mtu); strip_info->dev->name, old_mtu, strip_info->mtu);
...@@ -984,13 +983,10 @@ static void strip_seq_neighbours(struct seq_file *seq, ...@@ -984,13 +983,10 @@ static void strip_seq_neighbours(struct seq_file *seq,
const MetricomNodeTable * table, const MetricomNodeTable * table,
const char *title) const char *title)
{ {
unsigned long flags; /* We wrap this in a do/while loop, so if the table changes */
/* while we're reading it, we just go around and try again. */
struct timeval t; struct timeval t;
/*
* We wrap this in a do/while loop, so if the table changes
* while we're reading it, we just go around and try again.
*/
do { do {
int i; int i;
t = table->timestamp; t = table->timestamp;
...@@ -999,9 +995,9 @@ static void strip_seq_neighbours(struct seq_file *seq, ...@@ -999,9 +995,9 @@ static void strip_seq_neighbours(struct seq_file *seq,
for (i = 0; i < table->num_nodes; i++) { for (i = 0; i < table->num_nodes; i++) {
MetricomNode node; MetricomNode node;
spin_lock_irqsave(&strip_lock, flags); spin_lock_bh(&strip_lock);
node = table->node[i]; node = table->node[i];
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
seq_printf(seq, " %s\n", node.c); seq_printf(seq, " %s\n", node.c);
} }
} while (table->timestamp.tv_sec != t.tv_sec } while (table->timestamp.tv_sec != t.tv_sec
...@@ -1540,7 +1536,6 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) ...@@ -1540,7 +1536,6 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb)
static int strip_xmit(struct sk_buff *skb, struct net_device *dev) static int strip_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct strip *strip_info = netdev_priv(dev); struct strip *strip_info = netdev_priv(dev);
unsigned long flags;
if (!netif_running(dev)) { if (!netif_running(dev)) {
printk(KERN_ERR "%s: xmit call when iface is down\n", printk(KERN_ERR "%s: xmit call when iface is down\n",
...@@ -1579,11 +1574,11 @@ static int strip_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1579,11 +1574,11 @@ static int strip_xmit(struct sk_buff *skb, struct net_device *dev)
strip_info->dev->name, sx_pps_count / 8); strip_info->dev->name, sx_pps_count / 8);
} }
spin_lock_irqsave(&strip_lock, flags); spin_lock_bh(&strip_lock);
strip_send(strip_info, skb); strip_send(strip_info, skb);
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -2268,13 +2263,12 @@ static void strip_receive_buf(struct tty_struct *tty, const unsigned char *cp, ...@@ -2268,13 +2263,12 @@ static void strip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
{ {
struct strip *strip_info = tty->disc_data; struct strip *strip_info = tty->disc_data;
const unsigned char *end = cp + count; const unsigned char *end = cp + count;
unsigned long flags;
if (!strip_info || strip_info->magic != STRIP_MAGIC if (!strip_info || strip_info->magic != STRIP_MAGIC
|| !netif_running(strip_info->dev)) || !netif_running(strip_info->dev))
return; return;
spin_lock_irqsave(&strip_lock, flags); spin_lock_bh(&strip_lock);
#if 0 #if 0
{ {
struct timeval tv; struct timeval tv;
...@@ -2341,7 +2335,7 @@ static void strip_receive_buf(struct tty_struct *tty, const unsigned char *cp, ...@@ -2341,7 +2335,7 @@ static void strip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
} }
cp++; cp++;
} }
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
} }
...@@ -2529,11 +2523,9 @@ static void strip_dev_setup(struct net_device *dev) ...@@ -2529,11 +2523,9 @@ static void strip_dev_setup(struct net_device *dev)
static void strip_free(struct strip *strip_info) static void strip_free(struct strip *strip_info)
{ {
unsigned long flags; spin_lock_bh(&strip_lock);
spin_lock_irqsave(&strip_lock, flags);
list_del_rcu(&strip_info->list); list_del_rcu(&strip_info->list);
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
strip_info->magic = 0; strip_info->magic = 0;
...@@ -2547,7 +2539,6 @@ static void strip_free(struct strip *strip_info) ...@@ -2547,7 +2539,6 @@ static void strip_free(struct strip *strip_info)
static struct strip *strip_alloc(void) static struct strip *strip_alloc(void)
{ {
struct list_head *n; struct list_head *n;
unsigned long flags;
struct net_device *dev; struct net_device *dev;
struct strip *strip_info; struct strip *strip_info;
...@@ -2571,7 +2562,7 @@ static struct strip *strip_alloc(void) ...@@ -2571,7 +2562,7 @@ static struct strip *strip_alloc(void)
strip_info->idle_timer.function = strip_IdleTask; strip_info->idle_timer.function = strip_IdleTask;
spin_lock_irqsave(&strip_lock, flags); spin_lock_bh(&strip_lock);
rescan: rescan:
/* /*
* Search the list to find where to put our new entry * Search the list to find where to put our new entry
...@@ -2590,7 +2581,7 @@ static struct strip *strip_alloc(void) ...@@ -2590,7 +2581,7 @@ static struct strip *strip_alloc(void)
sprintf(dev->name, "st%ld", dev->base_addr); sprintf(dev->name, "st%ld", dev->base_addr);
list_add_tail_rcu(&strip_info->list, &strip_list); list_add_tail_rcu(&strip_info->list, &strip_list);
spin_unlock_irqrestore(&strip_lock, flags); spin_unlock_bh(&strip_lock);
return strip_info; return strip_info;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment