Subject: Re: [PATCH 1/7] netpoll: shorten carrier detect timeout

From: Patrick McHardy <[email-masked]>
Date: Sun, 06 Mar 2005 01:09:28 +0100

Matt Mackall wrote:
> Shorten carrier detect timeout to 4 seconds.

The carrier detection looks partially broken to me. The current logic
detects an instantly available carrier as flaky because
netif_carrier_ok() takes less than 1/10s. This patch does what
I assume is intended, make sure the carrier is stable for 1/10s.

Signed-off-by: Patrick McHardy <[email-masked]>
===== net/core/netpoll.c 1.27 vs edited =====
--- 1.27/net/core/netpoll.c	2005-01-26 06:32:56 +01:00
+++ edited/net/core/netpoll.c	2005-03-06 01:07:16 +01:00
@@ -592,8 +592,7 @@
 		}
 		rtnl_shunlock();
 
-		atleast = jiffies + HZ/10;
- 		atmost = jiffies + 10*HZ;
+ 		atmost = jiffies + 4*HZ;
 		while (!netif_carrier_ok(ndev)) {
 			if (time_after(jiffies, atmost)) {
 				printk(KERN_NOTICE
@@ -604,9 +603,15 @@
 			cond_resched();
 		}
 
+		atleast = jiffies + HZ/10;
+		while (netif_carrier_ok(ndev)) {
+			if (time_after(jiffies, atleast))
+				break;
+			cond_resched();
+		}
 		if (time_before(jiffies, atleast)) {
 			printk(KERN_NOTICE "%s: carrier detect appears flaky,"
-			       " waiting 10 seconds\n",
+			       " waiting 4 seconds\n",
 			       np->name);
 			while (time_before(jiffies, atmost))
 				cond_resched();