diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2005-06-27 00:02:44 +0200 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-06-27 00:02:44 +0200 |
commit | 97f568d8e3dc031b092e6086c0534d5411fb2cf5 (patch) | |
tree | 626d9dd89a55cc7515b5c1f070acceb82a72f7a6 /drivers/net/8139cp.c | |
parent | gianfar: Update Marvell PHY name (diff) | |
download | linux-97f568d8e3dc031b092e6086c0534d5411fb2cf5.tar.xz linux-97f568d8e3dc031b092e6086c0534d5411fb2cf5.zip |
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.
Diffstat (limited to 'drivers/net/8139cp.c')
-rw-r--r-- | drivers/net/8139cp.c | 12 |
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, struct ethtool_stats *estats, u64 *tmp_stats) { struct cp_private *cp = netdev_priv(dev); - unsigned int work = 100; int i; + memset(cp->nic_stats, 0, sizeof(struct cp_dma_stats)); + /* begin NIC statistics dump */ cpw32(StatsAddr + 4, (cp->nic_stats_dma >> 16) >> 16); cpw32(StatsAddr, (cp->nic_stats_dma & 0xffffffff) | DumpStats); cpr32(StatsAddr); - while (work-- > 0) { + for (i = 0; i < 1000; i++) { if ((cpr32(StatsAddr) & DumpStats) == 0) break; - cpu_relax(); + udelay(10); } - - if (cpr32(StatsAddr) & DumpStats) - return /* -EIO */; + cpw32(StatsAddr, 0); + cpw32(StatsAddr + 4, 0); i = 0; tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok); |