diff options
author | Amit Daniel Kachhap <amit.kachhap@arm.com> | 2018-12-20 17:18:16 +0530 |
---|---|---|
committer | Amit Daniel Kachhap <amit.kachhap@arm.com> | 2018-12-20 17:18:16 +0530 |
commit | e90db7903f9bd57aca214d64dc75002c05bd7e1a (patch) | |
tree | 7713232b0e08475123e5cc55e88a098be2789a1a | |
parent | a35b82aa253a959d2935f154081c3819793123a7 (diff) | |
parent | 1fa836fc2b999c81aaae5ded9e3e06109bf8df6e (diff) |
Merge branch 'latest-armlt-misc' into latest-armlt
-rw-r--r-- | drivers/net/ethernet/marvell/sky2.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 697d9b374f5e..77012649cb4e 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -3909,6 +3909,18 @@ static void sky2_get_stats(struct net_device *dev, unsigned int start; u64 _bytes, _packets; + /* Try and check if device if off. If it is, abort gathering stats as + * any attempt to read hardware registers will generate a bus fault. + * This test is hacky and racy as there's nothing stopping the device + * being powered off immediately after the test. + */ + if (hw->pdev->pm_cap) { + u16 pmcsr; + int ret = pci_read_config_word(hw->pdev, hw->pdev->pm_cap + PCI_PM_CTRL, &pmcsr); + if (ret || (pmcsr & PCI_PM_CTRL_STATE_MASK) > PCI_D2) + return; /* Can't read power state or it's state D3 (off) */ + } + do { start = u64_stats_fetch_begin_irq(&sky2->rx_stats.syncp); _bytes = sky2->rx_stats.bytes; |