netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Meelis Roos <mroos@linux.ee>
To: netdev@vger.kernel.org
Subject: [PATCH] tms380tr: fix long delays in initialization
Date: Sun, 3 Oct 2010 22:34:30 +0300 (EEST)	[thread overview]
Message-ID: <alpine.SOC.1.00.1010032228450.28867@math.ut.ee> (raw)

tms380tr driver tries to use udelay (meaning busy loop) for several half 
second delays during hardware initialization. Crazy overly long busy 
wait delays mean no delay at all so driver initialization fails without 
waiting. Fix it by using msleep() for long delays and leave it to 
udelay() for short delays.

Signed-off-by: Meelis Roos <mroos@linux.ee>

---
 drivers/net/tokenring/tms380tr.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index aaec637..e6dc2df 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -177,6 +177,7 @@ static void 	tms380tr_update_rcv_stats(struct net_local *tp,
 			unsigned char DataPtr[], unsigned int Length);
 /* "W" */
 void	 	tms380tr_wait(unsigned long time);
+static void	tms380tr_wait_long(unsigned long time);
 static void 	tms380tr_write_rpl_status(RPL *rpl, unsigned int Status);
 static void 	tms380tr_write_tpl_status(TPL *tpl, unsigned int Status);
 
@@ -1216,20 +1217,19 @@ static void tms380tr_set_multicast_list(struct net_device *dev)
 }
 
 /*
- * Wait for some time (microseconds)
+ * Wait for some time (microseconds) - busy wait
  */
 void tms380tr_wait(unsigned long time)
 {
-#if 0
-	long tmp;
-	
-	tmp = jiffies + time/(1000000/HZ);
-	do {
-		tmp = schedule_timeout_interruptible(tmp);
-	} while(time_after(tmp, jiffies));
-#else
 	udelay(time);
-#endif
+}
+
+/*
+ * Wait for long time (microseconds) - schedule
+ */
+static void tms380tr_wait_long(unsigned long time)
+{
+	msleep(time / 1000);
 }
 
 /*
@@ -1352,9 +1352,9 @@ static int tms380tr_bringup_diags(struct net_device *dev)
 	int loop_cnt, retry_cnt;
 	unsigned short Status;
 
-	tms380tr_wait(HALF_SECOND);
+	tms380tr_wait_long(HALF_SECOND);
 	tms380tr_exec_sifcmd(dev, EXEC_SOFT_RESET);
-	tms380tr_wait(HALF_SECOND);
+	tms380tr_wait_long(HALF_SECOND);
 
 	retry_cnt = BUD_MAX_RETRIES;	/* maximal number of retrys */
 
@@ -1365,7 +1365,7 @@ static int tms380tr_bringup_diags(struct net_device *dev)
 		loop_cnt = BUD_MAX_LOOPCNT;	/* maximum: three seconds*/
 		do {			/* Inspect BUD results */
 			loop_cnt--;
-			tms380tr_wait(HALF_SECOND);
+			tms380tr_wait_long(HALF_SECOND);
 			Status = SIFREADW(SIFSTS);
 			Status &= STS_MASK;
 
@@ -1384,7 +1384,7 @@ static int tms380tr_bringup_diags(struct net_device *dev)
 			printk(KERN_INFO "%s: Adapter Software Reset.\n", 
 				dev->name);
 			tms380tr_exec_sifcmd(dev, EXEC_SOFT_RESET);
-			tms380tr_wait(HALF_SECOND);
+			tms380tr_wait_long(HALF_SECOND);
 		}
 	} while(retry_cnt > 0);
 
@@ -1457,7 +1457,7 @@ static int tms380tr_init_adapter(struct net_device *dev)
 		do {
 			Status = 0;
 			loop_cnt--;
-			tms380tr_wait(HALF_SECOND);
+			tms380tr_wait_long(HALF_SECOND);
 
 			/* Mask interesting status bits */
 			Status = SIFREADW(SIFSTS);
@@ -1506,7 +1506,7 @@ static int tms380tr_init_adapter(struct net_device *dev)
 				{
 					/* Reset adapter and try init again */
 					tms380tr_exec_sifcmd(dev, EXEC_SOFT_RESET);
-					tms380tr_wait(HALF_SECOND);
+					tms380tr_wait_long(HALF_SECOND);
 				}
 			}
 		}
-- 
1.7.1


-- 
Meelis Roos (mroos@linux.ee)

             reply	other threads:[~2010-10-03 19:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-03 19:34 Meelis Roos [this message]
2010-10-04  3:01 ` [PATCH] tms380tr: fix long delays in initialization David Miller
2010-10-04  8:39   ` Meelis Roos
2010-10-04 16:42     ` David Miller
2010-10-04 21:15       ` Meelis Roos
2010-10-04 21:33         ` David Miller

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=alpine.SOC.1.00.1010032228450.28867@math.ut.ee \
    --to=mroos@linux.ee \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).