patch-2.2.19 linux/drivers/net/lanstreamer.c

Next file: linux/drivers/net/lanstreamer.h
Previous file: linux/drivers/net/lance.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/drivers/net/lanstreamer.c linux/drivers/net/lanstreamer.c
@@ -58,6 +58,7 @@
  *            First release to the public
  *  03/03/00 - Merged to kernel, indented -kr -i8 -bri0, fixed some missing
  *		malloc free checks, reviewed code. <alan@redhat.com>
+ *  12/18/00 - Made it SMP safe   - George Staikos <staikos@0wned.org>
  *  
  *  To Do:
  *
@@ -108,6 +109,7 @@
 #include <net/checksum.h>
 
 #include <asm/io.h>
+#include <asm/spinlock.h>
 #include <asm/system.h>
 #include <asm/bitops.h>
 
@@ -285,6 +287,8 @@
 	streamer_priv = (struct streamer_private *) dev->priv;
 	streamer_mmio = streamer_priv->streamer_mmio;
 
+        streamer_priv->lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
+
 	printk("%s \n", version);
 	printk(KERN_INFO "%s: IBM PCI tokenring card. I/O at %hx, MMIO at %p, using irq %d\n",
 			dev->name, (unsigned int) dev->base_addr,
@@ -823,6 +827,7 @@
 	__u16 misr;
 	__u16 sisrmask;
 
+        spin_lock(&(streamer_priv->lock));
 	sisrmask = SISR_MI;
 	writew(~sisrmask, streamer_mmio + SISR_MASK_RUM);
 	sisr = readw(streamer_mmio + SISR);
@@ -831,6 +836,7 @@
 	writew(~misr, streamer_mmio + MISR_RUM);
 
 	if (!sisr) {		/* Interrupt isn't for us */
+                spin_unlock(&(streamer_priv->lock));
 		return;
 	}
 
@@ -919,6 +925,7 @@
 
 	dev->interrupt = 0;
 	writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
+        spin_unlock(&(streamer_priv->lock));
 }
 
 
@@ -927,11 +934,14 @@
 	struct streamer_private *streamer_priv =
 	    (struct streamer_private *) dev->priv;
 	__u8 *streamer_mmio = streamer_priv->streamer_mmio;
+        int flags;
 
 	if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) {
 		return 1;
 	}
 
+        spin_lock_irqsave(&(streamer_priv->lock), flags);
+
 	if (streamer_priv->free_tx_ring_entries) {
 		streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].status = 0;
 		streamer_priv->streamer_tx_ring[streamer_priv->tx_ring_free].bufcnt_framelen = 0x00010000 | skb->len;
@@ -956,8 +966,10 @@
 
 		streamer_priv->tx_ring_free = (streamer_priv->tx_ring_free + 1) & (STREAMER_TX_RING_SIZE - 1);
 		dev->tbusy = 0;
+                spin_unlock_irqrestore(&(streamer_priv->lock), flags);
 		return 0;
 	} else {
+                spin_unlock_irqrestore(&(streamer_priv->lock), flags);
 		return 1;
 	}
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)