aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2005-06-26 18:02:44 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-06-26 18:02:44 -0400
commit97f568d8e3dc031b092e6086c0534d5411fb2cf5 (patch)
tree626d9dd89a55cc7515b5c1f070acceb82a72f7a6
parent223d47278a77091b62e7d063e95860f63ca55e20 (diff)
8139cp: safer spin loop for get_statistics
The spin loop in 8139cp is limited to 100 iterations when pulling hardware stats. There is no allowance for processor speed so on a fast machine, the stats may not be available that fast. Also, if the board doesn't return soon enough make sure turn the address back off to prevent later updates when memory has gone away.
-rw-r--r--drivers/net/8139cp.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index ca7746dd164f..e4b3c5c88542 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1516,22 +1516,22 @@ static void cp_get_ethtool_stats (struct net_device *dev,
1516 struct ethtool_stats *estats, u64 *tmp_stats) 1516 struct ethtool_stats *estats, u64 *tmp_stats)
1517{ 1517{
1518 struct cp_private *cp = netdev_priv(dev); 1518 struct cp_private *cp = netdev_priv(dev);
1519 unsigned int work = 100;
1520 int i; 1519 int i;
1521 1520
1521 memset(cp->nic_stats, 0, sizeof(struct cp_dma_stats));
1522
1522 /* begin NIC statistics dump */ 1523 /* begin NIC statistics dump */
1523 cpw32(StatsAddr + 4, (cp->nic_stats_dma >> 16) >> 16); 1524 cpw32(StatsAddr + 4, (cp->nic_stats_dma >> 16) >> 16);
1524 cpw32(StatsAddr, (cp->nic_stats_dma & 0xffffffff) | DumpStats); 1525 cpw32(StatsAddr, (cp->nic_stats_dma & 0xffffffff) | DumpStats);
1525 cpr32(StatsAddr); 1526 cpr32(StatsAddr);
1526 1527
1527 while (work-- > 0) { 1528 for (i = 0; i < 1000; i++) {
1528 if ((cpr32(StatsAddr) & DumpStats) == 0) 1529 if ((cpr32(StatsAddr) & DumpStats) == 0)
1529 break; 1530 break;
1530 cpu_relax(); 1531 udelay(10);
1531 } 1532 }
1532 1533 cpw32(StatsAddr, 0);
1533 if (cpr32(StatsAddr) & DumpStats) 1534 cpw32(StatsAddr + 4, 0);
1534 return /* -EIO */;
1535 1535
1536 i = 0; 1536 i = 0;
1537 tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok); 1537 tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);