All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe W Damasio <felipewd@terra.com.br>
To: rnp@netlink.co.nz
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix SMP support on 3c527 net driver
Date: Sun, 31 Aug 2003 00:06:02 -0300	[thread overview]
Message-ID: <3F51661A.1000800@terra.com.br> (raw)

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

	Hi Richard,

	Patch against 2.6.0-test4

	This is a first try to fix SMP support on the 3c527 net driver, by 
removing cli/sti and replacing them with proper locking.

	Since the critical section that used cli/save_flags to serialize its 
access had "sleep_on" in it, I added a per-device semaphore to it, and 
used this lock instead. Also, the down/up function doesn't seem to be 
used in interrupt context, so I think it will work.

	Compile fine, but I don't have the hardware to test it.

	Please review this patch and consider applying if it looks good,

	Thanks.

Felipe
-- 
It's most certainly GNU/Linux, not Linux. Read more at
http://www.gnu.org/gnu/why-gnu-linux.html

[-- Attachment #2: 3c527-smp.patch --]
[-- Type: text/plain, Size: 2773 bytes --]

--- linux-2.6.0-test4/drivers/net/3c527.c	Fri Aug 22 20:56:34 2003
+++ linux-2.6.0-test4-fwd/drivers/net/3c527.c	Sat Aug 30 23:57:25 2003
@@ -17,8 +17,8 @@
  */
 
 #define DRV_NAME		"3c527"
-#define DRV_VERSION		"0.6a"
-#define DRV_RELDATE		"2001/11/17"
+#define DRV_VERSION		"0.6b"
+#define DRV_RELDATE		"2003/08/31"
 
 static const char *version =
 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Proctor (rnp@netlink.co.nz)\n";
@@ -174,6 +174,8 @@
 
 	struct mc32_ring_desc tx_ring[TX_RING_LEN];	/* Host Transmit ring */
 	struct mc32_ring_desc rx_ring[RX_RING_LEN];	/* Host Receive ring */
+	
+	struct semaphore mc32_sem;
 
 	u16 tx_ring_tail;       /* index to tx de-queue end */
 	u16 tx_ring_head;       /* index to tx en-queue end */
@@ -615,16 +617,14 @@
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
 	int ioaddr = dev->base_addr;
-	unsigned long flags;
 	int ret = 0;
 	
 	/*
 	 *	Wait for a command
 	 */
 	 
-	save_flags(flags);
-	cli();
-	 
+	down(&lp->mc32_sem);
+	
 	while(lp->exec_pending)
 		sleep_on(&lp->event);
 		
@@ -634,7 +634,7 @@
 
 	lp->exec_pending=1;
 	
-	restore_flags(flags);
+	up(&lp->mc32_sem);
 	
 	lp->exec_box->mbox=0;
 	lp->exec_box->mbox=cmd;
@@ -645,13 +645,12 @@
 	while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR));
 	outb(1<<6, ioaddr+HOST_CMD);	
 
-	save_flags(flags);
-	cli();
+	down(&lp->mc32_sem);
 
 	while(lp->exec_pending!=2)
 		sleep_on(&lp->event);
 	lp->exec_pending=0;
-	restore_flags(flags);
+	up(&lp->mc32_sem);
 	
 	if(lp->exec_box->mbox&(1<<13))
 		ret = -1;
@@ -725,7 +724,6 @@
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
 	int ioaddr = dev->base_addr;
-	unsigned long flags;
 
 	mc32_ready_poll(dev);	
 
@@ -735,14 +733,13 @@
 	outb(HOST_CMD_SUSPND_RX, ioaddr+HOST_CMD);			
 	mc32_ready_poll(dev); 
 	outb(HOST_CMD_SUSPND_TX, ioaddr+HOST_CMD);	
-		
-	save_flags(flags);
-	cli();
+	
+	down(&lp->mc32_sem);
 		
 	while(lp->xceiver_state!=HALTED) 
 		sleep_on(&lp->event); 
 		
-	restore_flags(flags);	
+	up(&lp->mc32_sem);
 } 
 
 
@@ -1008,6 +1005,7 @@
 		return -ENOBUFS;
 	}
 
+	init_MUTEX(&lp->mc32_sem);
 	lp->desired_state = RUNNING; 
 	
 	/* And finally, set the ball rolling... */
@@ -1056,18 +1054,16 @@
 static int mc32_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
-	unsigned long flags;
 
 	volatile struct skb_header *p, *np;
 
 	netif_stop_queue(dev);
 
-	save_flags(flags);
-	cli();
+	down(&lp->mc32_sem);
 		
 	if(atomic_read(&lp->tx_count)==0)
 	{
-		restore_flags(flags);
+		up(&lp->mc32_sem);
 		return 1;
 	}
 
@@ -1098,7 +1094,7 @@
 		
 	p->control     &= ~CONTROL_EOL;     /* Clear EOL on p */ 
 out:	
-	restore_flags(flags);
+	up(&lp->mc32_sem);
 
 	netif_wake_queue(dev);
 	return 0;

             reply	other threads:[~2003-08-31  3:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-31  3:06 Felipe W Damasio [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-08-31  8:28 [PATCH] Fix SMP support on 3c527 net driver Manfred Spraul
2003-08-31 16:50 ` Felipe W Damasio
2003-08-31 17:30   ` Manfred Spraul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F51661A.1000800@terra.com.br \
    --to=felipewd@terra.com.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rnp@netlink.co.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.