]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
sfc: Wait for the link to stay up before running loopback selftest
authorSteve Hodgson <shodgson@solarflare.com>
Tue, 1 Jun 2010 11:18:28 +0000 (11:18 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Jun 2010 09:21:07 +0000 (02:21 -0700)
It's been observed that some phys (such as the qt2025c) can
do down-up-down-up transitions, presumably as pcs block lock
settles down.

The loopback selftest will start sending data immediately
after the link comes up. Work around this by waiting for
the link state to stay up for two consecutive polls, rather
than one.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/sfc/selftest.c

index 371e86cc090f3c93eb1fad2775012af54ef0547f..52ac14af83a4f6b1a23c1f3e56c83381ca8126a3 100644 (file)
@@ -545,7 +545,7 @@ efx_test_loopback(struct efx_tx_queue *tx_queue,
 static int efx_wait_for_link(struct efx_nic *efx)
 {
        struct efx_link_state *link_state = &efx->link_state;
-       int count;
+       int count, link_up_count = 0;
        bool link_up;
 
        for (count = 0; count < 40; count++) {
@@ -567,8 +567,12 @@ static int efx_wait_for_link(struct efx_nic *efx)
                        link_up = !efx->mac_op->check_fault(efx);
                mutex_unlock(&efx->mac_lock);
 
-               if (link_up)
-                       return 0;
+               if (link_up) {
+                       if (++link_up_count == 2)
+                               return 0;
+               } else {
+                       link_up_count = 0;
+               }
        }
 
        return -ETIMEDOUT;