r8169: add checking driver's runtime pm status in rtl8169_get_ethtool_stats()
authorChun-Hao Lin <hau@realtek.com>
Fri, 29 Jul 2016 08:37:55 +0000 (16:37 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Aug 2016 03:34:05 +0000 (20:34 -0700)
Not to call rtl8169_update_counters() to dump tally counter when driver
is in runtime suspend state.

Calling rtl8169_update_counters() in runtime suspend state will produce
warning message "rtl_counters_cond == 1 (loop: 1000, delay: 10)".

Signed-off-by: Chunhao Lin <hau@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/realtek/r8169.c

index 00c387bf41b7256b0a1a9145d4262028a7ed62f2..d0b5cae2825f42f5e0bfedc08a366f89cf04fd89 100644 (file)
@@ -2308,11 +2308,17 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
                                      struct ethtool_stats *stats, u64 *data)
 {
        struct rtl8169_private *tp = netdev_priv(dev);
+       struct device *d = &tp->pci_dev->dev;
        struct rtl8169_counters *counters = tp->counters;
 
        ASSERT_RTNL();
 
-       rtl8169_update_counters(dev);
+       pm_runtime_get_noresume(d);
+
+       if (pm_runtime_active(d))
+               rtl8169_update_counters(dev);
+
+       pm_runtime_put_noidle(d);
 
        data[0] = le64_to_cpu(counters->tx_packets);
        data[1] = le64_to_cpu(counters->rx_packets);