]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/igb-fix-warn_once-on-runtime-suspend.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / igb-fix-warn_once-on-runtime-suspend.patch
1 From 98f5404955e18393fae252c228edf61cbfb9ca09 Mon Sep 17 00:00:00 2001
2 From: Arvind Sankar <niveditas98@gmail.com>
3 Date: Sat, 2 Mar 2019 11:01:17 -0500
4 Subject: igb: Fix WARN_ONCE on runtime suspend
5
6 [ Upstream commit dabb8338be533c18f50255cf39ff4f66d4dabdbe ]
7
8 The runtime_suspend device callbacks are not supposed to save
9 configuration state or change the power state. Commit fb29f76cc566
10 ("igb: Fix an issue that PME is not enabled during runtime suspend")
11 changed the driver to not save configuration state during runtime
12 suspend, however the driver callback still put the device into a
13 low-power state. This causes a warning in the pci pm core and results in
14 pci_pm_runtime_suspend not calling pci_save_state or pci_finish_runtime_suspend.
15
16 Fix this by not changing the power state either, leaving that to pci pm
17 core, and make the same change for suspend callback as well.
18
19 Also move a couple of defines into the appropriate header file instead
20 of inline in the .c file.
21
22 Fixes: fb29f76cc566 ("igb: Fix an issue that PME is not enabled during runtime suspend")
23 Signed-off-by: Arvind Sankar <niveditas98@gmail.com>
24 Reviewed-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
25 Tested-by: Aaron Brown <aaron.f.brown@intel.com>
26 Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
27 Signed-off-by: Sasha Levin <sashal@kernel.org>
28 ---
29 .../net/ethernet/intel/igb/e1000_defines.h | 2 +
30 drivers/net/ethernet/intel/igb/igb_main.c | 57 +++----------------
31 2 files changed, 10 insertions(+), 49 deletions(-)
32
33 diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
34 index b1915043bc0c..7b9fb71137da 100644
35 --- a/drivers/net/ethernet/intel/igb/e1000_defines.h
36 +++ b/drivers/net/ethernet/intel/igb/e1000_defines.h
37 @@ -193,6 +193,8 @@
38 /* enable link status from external LINK_0 and LINK_1 pins */
39 #define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
40 #define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
41 +#define E1000_CTRL_ADVD3WUC 0x00100000 /* D3 WUC */
42 +#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000 /* PHY PM enable */
43 #define E1000_CTRL_SDP0_DIR 0x00400000 /* SDP0 Data direction */
44 #define E1000_CTRL_SDP1_DIR 0x00800000 /* SDP1 Data direction */
45 #define E1000_CTRL_RST 0x04000000 /* Global reset */
46 diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
47 index c1796aa2dde5..70ed5e5c3514 100644
48 --- a/drivers/net/ethernet/intel/igb/igb_main.c
49 +++ b/drivers/net/ethernet/intel/igb/igb_main.c
50 @@ -7325,9 +7325,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
51 struct e1000_hw *hw = &adapter->hw;
52 u32 ctrl, rctl, status;
53 u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
54 -#ifdef CONFIG_PM
55 - int retval = 0;
56 -#endif
57 + bool wake;
58
59 rtnl_lock();
60 netif_device_detach(netdev);
61 @@ -7338,14 +7336,6 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
62 igb_clear_interrupt_scheme(adapter);
63 rtnl_unlock();
64
65 -#ifdef CONFIG_PM
66 - if (!runtime) {
67 - retval = pci_save_state(pdev);
68 - if (retval)
69 - return retval;
70 - }
71 -#endif
72 -
73 status = rd32(E1000_STATUS);
74 if (status & E1000_STATUS_LU)
75 wufc &= ~E1000_WUFC_LNKC;
76 @@ -7362,10 +7352,6 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
77 }
78
79 ctrl = rd32(E1000_CTRL);
80 - /* advertise wake from D3Cold */
81 - #define E1000_CTRL_ADVD3WUC 0x00100000
82 - /* phy power management enable */
83 - #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
84 ctrl |= E1000_CTRL_ADVD3WUC;
85 wr32(E1000_CTRL, ctrl);
86
87 @@ -7379,12 +7365,15 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
88 wr32(E1000_WUFC, 0);
89 }
90
91 - *enable_wake = wufc || adapter->en_mng_pt;
92 - if (!*enable_wake)
93 + wake = wufc || adapter->en_mng_pt;
94 + if (!wake)
95 igb_power_down_link(adapter);
96 else
97 igb_power_up_link(adapter);
98
99 + if (enable_wake)
100 + *enable_wake = wake;
101 +
102 /* Release control of h/w to f/w. If f/w is AMT enabled, this
103 * would have already happened in close and is redundant.
104 */
105 @@ -7399,22 +7388,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
106 #ifdef CONFIG_PM_SLEEP
107 static int igb_suspend(struct device *dev)
108 {
109 - int retval;
110 - bool wake;
111 - struct pci_dev *pdev = to_pci_dev(dev);
112 -
113 - retval = __igb_shutdown(pdev, &wake, 0);
114 - if (retval)
115 - return retval;
116 -
117 - if (wake) {
118 - pci_prepare_to_sleep(pdev);
119 - } else {
120 - pci_wake_from_d3(pdev, false);
121 - pci_set_power_state(pdev, PCI_D3hot);
122 - }
123 -
124 - return 0;
125 + return __igb_shutdown(to_pci_dev(dev), NULL, 0);
126 }
127 #endif /* CONFIG_PM_SLEEP */
128
129 @@ -7483,22 +7457,7 @@ static int igb_runtime_idle(struct device *dev)
130
131 static int igb_runtime_suspend(struct device *dev)
132 {
133 - struct pci_dev *pdev = to_pci_dev(dev);
134 - int retval;
135 - bool wake;
136 -
137 - retval = __igb_shutdown(pdev, &wake, 1);
138 - if (retval)
139 - return retval;
140 -
141 - if (wake) {
142 - pci_prepare_to_sleep(pdev);
143 - } else {
144 - pci_wake_from_d3(pdev, false);
145 - pci_set_power_state(pdev, PCI_D3hot);
146 - }
147 -
148 - return 0;
149 + return __igb_shutdown(to_pci_dev(dev), NULL, 1);
150 }
151
152 static int igb_runtime_resume(struct device *dev)
153 --
154 2.20.1
155