e1000e: fix accessing to suspended device (bnc#806966).
[opensuse:kernel-source.git] / patches.fixes / e1000e-fix-accessing-to-suspended-device.patch
1 From: Konstantin Khlebnikov <khlebnikov@openvz.org>
2 Date: Tue, 5 Mar 2013 09:43:09 +0000
3 Subject: e1000e: fix accessing to suspended device
4 Patch-mainline: v3.9-rc3
5 Git-commit: e60b22c5b7e59db09a7c9490b1e132c7e49ae904
6 References: bnc#806966
7
8 This patch fixes some annoying messages like 'Error reading PHY register' and
9 'Hardware Erorr' and saves several seconds on reboot.
10
11 Cc: Bruce Allan <bruce.w.allan@intel.com>
12 Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
13 Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
14 Tested-by: Borislav Petkov <bp@suse.de>
15 Tested-by: Aaron Brown <aaron.f.brown@intel.com>
16 Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
17 Signed-off-by: Jiri Slaby <jslaby@suse.cz>
18 ---
19  drivers/net/ethernet/intel/e1000e/ethtool.c |   13 +++++++++++++
20  drivers/net/ethernet/intel/e1000e/netdev.c  |    2 ++
21  2 files changed, 15 insertions(+)
22
23 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c
24 +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
25 @@ -35,6 +35,7 @@
26  #include <linux/slab.h>
27  #include <linux/delay.h>
28  #include <linux/vmalloc.h>
29 +#include <linux/pm_runtime.h>
30  
31  #include "e1000.h"
32  
33 @@ -2053,7 +2054,19 @@ static int e1000_get_rxnfc(struct net_de
34         }
35  }
36  
37 +static int e1000e_ethtool_begin(struct net_device *netdev)
38 +{
39 +       return pm_runtime_get_sync(netdev->dev.parent);
40 +}
41 +
42 +static void e1000e_ethtool_complete(struct net_device *netdev)
43 +{
44 +       pm_runtime_put_sync(netdev->dev.parent);
45 +}
46 +
47  static const struct ethtool_ops e1000_ethtool_ops = {
48 +       .begin                  = e1000e_ethtool_begin,
49 +       .complete               = e1000e_ethtool_complete,
50         .get_settings           = e1000_get_settings,
51         .set_settings           = e1000_set_settings,
52         .get_drvinfo            = e1000_get_drvinfo,
53 --- a/drivers/net/ethernet/intel/e1000e/netdev.c
54 +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
55 @@ -4312,6 +4312,7 @@ static void e1000_phy_read_status(struct
56             (adapter->hw.phy.media_type == e1000_media_type_copper)) {
57                 int ret_val;
58  
59 +               pm_runtime_get_sync(&adapter->pdev->dev);
60                 ret_val  = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
61                 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
62                 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
63 @@ -4322,6 +4323,7 @@ static void e1000_phy_read_status(struct
64                 ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus);
65                 if (ret_val)
66                         e_warn("Error reading PHY register\n");
67 +               pm_runtime_put_sync(&adapter->pdev->dev);
68         } else {
69                 /* Do not read PHY registers if link is not up
70                  * Set values to typical power-on defaults