Commit 7b738b55 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

sundance: get_stats proper locking

sundance get_stats() should not be run concurrently, add a lock to avoid
potential losses.

Note: Remove unused rx_lock field
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2259dca3
...@@ -365,7 +365,6 @@ struct netdev_private { ...@@ -365,7 +365,6 @@ struct netdev_private {
struct timer_list timer; /* Media monitoring timer. */ struct timer_list timer; /* Media monitoring timer. */
/* Frequently used values: keep some adjacent for cache effect. */ /* Frequently used values: keep some adjacent for cache effect. */
spinlock_t lock; spinlock_t lock;
spinlock_t rx_lock; /* Group with Tx control cache line. */
int msg_enable; int msg_enable;
int chip_id; int chip_id;
unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indices */ unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indices */
...@@ -390,6 +389,7 @@ struct netdev_private { ...@@ -390,6 +389,7 @@ struct netdev_private {
unsigned char phys[MII_CNT]; /* MII device addresses, only first one used. */ unsigned char phys[MII_CNT]; /* MII device addresses, only first one used. */
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
void __iomem *base; void __iomem *base;
spinlock_t statlock;
}; };
/* The station address location in the EEPROM. */ /* The station address location in the EEPROM. */
...@@ -514,6 +514,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev, ...@@ -514,6 +514,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
np->chip_id = chip_idx; np->chip_id = chip_idx;
np->msg_enable = (1 << debug) - 1; np->msg_enable = (1 << debug) - 1;
spin_lock_init(&np->lock); spin_lock_init(&np->lock);
spin_lock_init(&np->statlock);
tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev); tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev);
tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev); tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev);
...@@ -1486,10 +1487,9 @@ static struct net_device_stats *get_stats(struct net_device *dev) ...@@ -1486,10 +1487,9 @@ static struct net_device_stats *get_stats(struct net_device *dev)
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base; void __iomem *ioaddr = np->base;
int i; int i;
unsigned long flags;
/* We should lock this segment of code for SMP eventually, although spin_lock_irqsave(&np->statlock, flags);
the vulnerability window is very small and statistics are
non-critical. */
/* The chip only need report frame silently dropped. */ /* The chip only need report frame silently dropped. */
dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed); dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed);
dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK); dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK);
...@@ -1506,6 +1506,8 @@ static struct net_device_stats *get_stats(struct net_device *dev) ...@@ -1506,6 +1506,8 @@ static struct net_device_stats *get_stats(struct net_device *dev)
dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow); dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow);
dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsHigh) << 16; dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsHigh) << 16;
spin_unlock_irqrestore(&np->statlock, flags);
return &dev->stats; return &dev->stats;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment