public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.5: ewrk3 cli/sti removal by VDA
@ 2002-10-19  2:13 Adam Kropelin
  2002-10-19  2:46 ` Adam Kropelin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Adam Kropelin @ 2002-10-19  2:13 UTC (permalink / raw)
  To: jgarzik; +Cc: VDA, linux-kernel

Below is a patch from Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua> which
removes cli/sti in the ewrk3 driver. It tests out fine here with SMP & preempt.

Applies against 2.5.34 + ewrk3-ethtool patch. Also applies without ethtool patch
with some offsets.

(Denis, I took the liberty of forwarding this to Jeff since it works fine for me
and the driver is pretty much useless without it. Scream if you don't want it
applied...)

--Adam
 
--- linux-2.5.43-mm1/drivers/net/ewrk3.c.orig	Fri Oct 18 21:55:44 2002
+++ linux-2.5.43-mm1/drivers/net/ewrk3.c	Fri Oct 18 22:02:41 2002
@@ -940,6 +940,7 @@
 	spin_unlock(&lp->hw_lock);
 }
 
+/* Called with lp->hw_lock held */
 static int ewrk3_rx(struct net_device *dev)
 {
 	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
@@ -1065,8 +1066,9 @@
 }
 
 /*
-   ** Buffer sent - check for TX buffer errors.
- */
+** Buffer sent - check for TX buffer errors.
+** Called with lp->hw_lock held
+*/
 static int ewrk3_tx(struct net_device *dev)
 {
 	struct ewrk3_private *lp = (struct ewrk3_private *) dev->priv;
@@ -1830,6 +1832,7 @@
 	u_long iobase = dev->base_addr;
 	int i, j, status = 0;
 	u_char csr;
+	unsigned long flags;
 	union ewrk3_addr {
 		u_char addr[HASH_TABLE_LEN * ETH_ALEN];
 		u_short val[(HASH_TABLE_LEN * ETH_ALEN) >> 1];
@@ -1953,19 +1956,26 @@
 		}
 
 		break;
-	case EWRK3_GET_STATS:	/* Get the driver statistics */
-		cli();
-		ioc->len = sizeof(lp->pktStats);
-		if (copy_to_user(ioc->data, &lp->pktStats, ioc->len))
-			status = -EFAULT;
-		sti();
+	case EWRK3_GET_STATS: { /* Get the driver statistics */
+		typeof(lp->pktStats) *tmp_stats =
+        		kmalloc(sizeof(lp->pktStats), GFP_KERNEL);
+		if (!tmp_stats) return -ENOMEM;
 
+		spin_lock_irqsave(&lp->hw_lock, flags);
+		memcpy(tmp_stats, &lp->pktStats, sizeof(lp->pktStats));
+		spin_unlock_irqrestore(&lp->hw_lock, flags);
+
+		ioc->len = sizeof(lp->pktStats);
+		if (copy_to_user(ioc->data, tmp_stats, sizeof(lp->pktStats)))
+    			status = -EFAULT;
+		kfree(tmp_stats);
 		break;
+	}
 	case EWRK3_CLR_STATS:	/* Zero out the driver statistics */
 		if (capable(CAP_NET_ADMIN)) {
-			cli();
+			spin_lock_irqsave(&lp->hw_lock, flags);
 			memset(&lp->pktStats, 0, sizeof(lp->pktStats));
-			sti();
+			spin_unlock_irqrestore(&lp->hw_lock,flags);
 		} else {
 			status = -EPERM;
 		}


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-11-01 21:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-19  2:13 [PATCH] 2.5: ewrk3 cli/sti removal by VDA Adam Kropelin
2002-10-19  2:46 ` Adam Kropelin
2002-10-19 14:55 ` Denis Vlasenko
2002-10-22  0:36 ` Jeff Garzik
2002-10-22  2:09   ` Adam Kropelin
2002-10-22  2:16     ` Jeff Garzik
2002-10-25 22:45     ` Jeff Garzik
2002-10-25 22:54       ` Adam Kropelin
2002-11-01 21:17       ` Adam Kropelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox