sfc: Wait at most 10ms for the MC to finish reading out MAC statistics
authorBen Hutchings <bhutchings@solarflare.com>
Wed, 28 Apr 2010 09:00:35 +0000 (09:00 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 28 Apr 2010 19:18:26 +0000 (12:18 -0700)
The original code would wait indefinitely if MAC stats DMA failed.

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

index 38dcc42c4f790648fb2add771b0610ee394e3380..e0c46f59d1f8793d365710d1e80d6c51ae469b9d 100644 (file)
@@ -456,8 +456,17 @@ static int siena_try_update_nic_stats(struct efx_nic *efx)
 
 static void siena_update_nic_stats(struct efx_nic *efx)
 {
-       while (siena_try_update_nic_stats(efx) == -EAGAIN)
-               cpu_relax();
+       int retry;
+
+       /* If we're unlucky enough to read statistics wduring the DMA, wait
+        * up to 10ms for it to finish (typically takes <500us) */
+       for (retry = 0; retry < 100; ++retry) {
+               if (siena_try_update_nic_stats(efx) == 0)
+                       return;
+               udelay(100);
+       }
+
+       /* Use the old values instead */
 }
 
 static void siena_start_nic_stats(struct efx_nic *efx)