diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-10-08 22:17:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-09 12:22:54 -0400 |
commit | 7b738b55b2ec0e95a5030037c45b3c312e385789 (patch) | |
tree | 344ce2da410f2a9b37bc73511bce8cf16fa5dcd9 /drivers/net/sundance.c | |
parent | 2259dca36a2f0226596ea37132a46338fcff6722 (diff) |
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: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sundance.c')
-rw-r--r-- | drivers/net/sundance.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index 27d69aaba486..4283cc52a8c9 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c | |||
@@ -365,7 +365,6 @@ struct netdev_private { | |||
365 | struct timer_list timer; /* Media monitoring timer. */ | 365 | struct timer_list timer; /* Media monitoring timer. */ |
366 | /* Frequently used values: keep some adjacent for cache effect. */ | 366 | /* Frequently used values: keep some adjacent for cache effect. */ |
367 | spinlock_t lock; | 367 | spinlock_t lock; |
368 | spinlock_t rx_lock; /* Group with Tx control cache line. */ | ||
369 | int msg_enable; | 368 | int msg_enable; |
370 | int chip_id; | 369 | int chip_id; |
371 | unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indices */ | 370 | unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indices */ |
@@ -390,6 +389,7 @@ struct netdev_private { | |||
390 | unsigned char phys[MII_CNT]; /* MII device addresses, only first one used. */ | 389 | unsigned char phys[MII_CNT]; /* MII device addresses, only first one used. */ |
391 | struct pci_dev *pci_dev; | 390 | struct pci_dev *pci_dev; |
392 | void __iomem *base; | 391 | void __iomem *base; |
392 | spinlock_t statlock; | ||
393 | }; | 393 | }; |
394 | 394 | ||
395 | /* The station address location in the EEPROM. */ | 395 | /* The station address location in the EEPROM. */ |
@@ -514,6 +514,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev, | |||
514 | np->chip_id = chip_idx; | 514 | np->chip_id = chip_idx; |
515 | np->msg_enable = (1 << debug) - 1; | 515 | np->msg_enable = (1 << debug) - 1; |
516 | spin_lock_init(&np->lock); | 516 | spin_lock_init(&np->lock); |
517 | spin_lock_init(&np->statlock); | ||
517 | tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev); | 518 | tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev); |
518 | tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev); | 519 | tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev); |
519 | 520 | ||
@@ -1486,10 +1487,9 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
1486 | struct netdev_private *np = netdev_priv(dev); | 1487 | struct netdev_private *np = netdev_priv(dev); |
1487 | void __iomem *ioaddr = np->base; | 1488 | void __iomem *ioaddr = np->base; |
1488 | int i; | 1489 | int i; |
1490 | unsigned long flags; | ||
1489 | 1491 | ||
1490 | /* We should lock this segment of code for SMP eventually, although | 1492 | spin_lock_irqsave(&np->statlock, flags); |
1491 | the vulnerability window is very small and statistics are | ||
1492 | non-critical. */ | ||
1493 | /* The chip only need report frame silently dropped. */ | 1493 | /* The chip only need report frame silently dropped. */ |
1494 | dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed); | 1494 | dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed); |
1495 | dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK); | 1495 | dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK); |
@@ -1506,6 +1506,8 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
1506 | dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow); | 1506 | dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow); |
1507 | dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsHigh) << 16; | 1507 | dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsHigh) << 16; |
1508 | 1508 | ||
1509 | spin_unlock_irqrestore(&np->statlock, flags); | ||
1510 | |||
1509 | return &dev->stats; | 1511 | return &dev->stats; |
1510 | } | 1512 | } |
1511 | 1513 | ||