[aadk-commits] dbailey: uClinux/trunk r87 - /uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/...

aadk-commits at lists.digium.com aadk-commits at lists.digium.com
Wed Dec 27 13:03:24 MST 2006


Author: dbailey
Date: Wed Dec 27 14:03:23 2006
New Revision: 87

URL: http://svn.digium.com/view/aadk?view=rev&rev=87
Log:
Added mutex protection to hard start transmit function.  Got rid of spinlock

Modified:
    uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.c
    uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.h

Modified: uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.c
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.c?view=diff&rev=87&r1=86&r2=87
==============================================================================
--- uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.c (original)
+++ uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.c Wed Dec 27 14:03:23 2006
@@ -20,7 +20,6 @@
 #include <linux/ioport.h>
 #include <linux/crc32.h>
 #include <linux/device.h>
-#include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 
@@ -36,6 +35,7 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
+#include <asm/semaphore.h>
 #include <linux/dma-mapping.h>
 
 #include "bfin_mac.h"
@@ -47,6 +47,9 @@
 MODULE_LICENSE("GPL");
 
 #define CARDNAME "bfin_mac"
+
+/* This mutex is used to insure only one thread is active within the hard xmit function at any time */
+DECLARE_MUTEX(hard_trans_access);
 
 /* Enable "TRACE_PACKETS" to use the error counters to report
    the number of fast routed versus non-fast routed packets */
@@ -536,6 +539,15 @@
     unsigned int data;
   /* warning: printk in this function may cause error */
 
+	/* Test to see if this function is currently active */ 
+	/* NOTE: this cannot sleep as this function is run in atomic context */
+	if(down_trylock(&hard_trans_access)) {	
+#ifdef TRACE_PACKETS
+		lp->stats.tx_dropped++;
+#endif
+		return 1;	/* Indicate that a retry is needed - Bad form but simple*/
+	}
+	
 /* Do we need some sort of protection against reentrancy since eth0 and eth1 are using this function */
     current_tx_ptr->skb = skb;		/* attach the skb to the DMA buffer descriptor */
 
@@ -591,6 +603,9 @@
     dev->trans_start = jiffies;
     lp->stats.tx_packets++;
     lp->stats.tx_bytes += (skb->len);
+	
+	up(&hard_trans_access);
+
 	return 0;
 }
 
@@ -900,7 +915,6 @@
   lp->FlowControl = 0;
   lp->landev = ldev;
   lp->amlan = ldev ? 0 : 1;
-  spin_lock_init(&lp->lock);
 }
 
 static void bf537_dev_setup(struct net_device *dev)

Modified: uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.h
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.h?view=diff&rev=87&r1=86&r2=87
==============================================================================
--- uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.h (original)
+++ uClinux/trunk/uClinux-dist/linux-2.6.x/drivers/net/bfin_mac.h Wed Dec 27 14:03:23 2006
@@ -98,6 +98,5 @@
   int amlan;			// Am I a LAN interface
 	unsigned short IntMask;	// interrupt mask
 	unsigned char Mac[6];	// MAC address of the board
-	spinlock_t lock;
 };
 



More information about the aadk-commits mailing list