diff mbox series

[1/2] e1000e: Do not wake up the system via WOL if device wakeup is disabled

Message ID 9f7ede2e2e8152704258fc11ba3755ae93f50741.1590081982.git.yu.c.chen@intel.com
State Accepted
Delegated to: Jeff Kirsher
Headers show
Series Make WOL of e1000e consistent with sysfs device wakeup | expand

Commit Message

Chen Yu May 21, 2020, 5:59 p.m. UTC
Currently the system will be woken up via WOL(Wake On Lan) even if the
device wakeup ability has been disabled via sysfs:
 cat /sys/devices/pci0000:00/0000:00:1f.6/power/wakeup
 disabled

The system should not be woken up if the user has explicitly
disabled the wake up ability for this device.

This patch clears the WOL ability of this network device if the
user has disabled the wake up ability in sysfs.

Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver")
Reported-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Sasha Levin May 26, 2020, 12:23 a.m. UTC | #1
Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)").

The bot has tested the following trees: v5.6.14, v5.4.42, v4.19.124, v4.14.181, v4.9.224, v4.4.224.

v5.6.14: Build OK!
v5.4.42: Build OK!
v4.19.124: Build OK!
v4.14.181: Build OK!
v4.9.224: Failed to apply! Possible dependencies:
    c8744f44aeae ("e1000e: Add Support for CannonLake")

v4.4.224: Failed to apply! Possible dependencies:
    16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt")
    18dd23920703 ("e1000e: use BIT() macro for bit defines")
    74f31299a41e ("e1000e: Increase PHY PLL clock gate timing")
    c8744f44aeae ("e1000e: Add Support for CannonLake")
    f3ed935de059 ("e1000e: initial support for i219-LM (3)")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?
Chen Yu May 26, 2020, 3:34 a.m. UTC | #2
Hi Sasha,
On Tue, May 26, 2020 at 12:23:55AM +0000, Sasha Levin wrote:
> Hi
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a "Fixes:" tag
> fixing commit: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)").
> 
> The bot has tested the following trees: v5.6.14, v5.4.42, v4.19.124, v4.14.181, v4.9.224, v4.4.224.
> 
> v5.6.14: Build OK!
> v5.4.42: Build OK!
> v4.19.124: Build OK!
> v4.14.181: Build OK!
> v4.9.224: Failed to apply! Possible dependencies:
>     c8744f44aeae ("e1000e: Add Support for CannonLake")
> 
> v4.4.224: Failed to apply! Possible dependencies:
>     16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt")
>     18dd23920703 ("e1000e: use BIT() macro for bit defines")
>     74f31299a41e ("e1000e: Increase PHY PLL clock gate timing")
>     c8744f44aeae ("e1000e: Add Support for CannonLake")
>     f3ed935de059 ("e1000e: initial support for i219-LM (3)")
> 
> 
> NOTE: The patch will not be queued to stable trees until it is upstream.
> 
> How should we proceed with this patch?
> 
We could discard the change for v4.9 and v4.4 IMO, as their impact should be
minor.

Thanks,
Chenyu
> -- 
> Thanks
> Sasha
Brown, Aaron F June 15, 2020, 6:51 p.m. UTC | #3
> From: Chen Yu <yu.c.chen@intel.com>
> Sent: Thursday, May 21, 2020 10:59 AM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; David S. Miller
> <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>; Kok, Auke-jan H
> <auke-jan.h.kok@intel.com>; Jeff Garzik <jeff@garzik.org>
> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; Brown, Len <len.brown@intel.com>; Rafael J. Wysocki
> <rjw@rjwysocki.net>; Shevchenko, Andriy <andriy.shevchenko@intel.com>;
> Neftin, Sasha <sasha.neftin@intel.com>; Lifshits, Vitaly
> <vitaly.lifshits@intel.com>; Chen, Yu C <yu.c.chen@intel.com>;
> Stable@vger.kernel.org
> Subject: [PATCH 1/2] e1000e: Do not wake up the system via WOL if device
> wakeup is disabled
> 
> Currently the system will be woken up via WOL(Wake On Lan) even if the
> device wakeup ability has been disabled via sysfs:
>  cat /sys/devices/pci0000:00/0000:00:1f.6/power/wakeup
>  disabled
> 
> The system should not be woken up if the user has explicitly
> disabled the wake up ability for this device.
> 
> This patch clears the WOL ability of this network device if the
> user has disabled the wake up ability in sysfs.
> 
> Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver")
> Reported-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: <Stable@vger.kernel.org>
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
>  drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Chen Yu June 16, 2020, 7:01 a.m. UTC | #4
On Tue, Jun 16, 2020 at 02:51:27AM +0800, Brown, Aaron F wrote:
> > From: Chen Yu <yu.c.chen@intel.com>
> > Sent: Thursday, May 21, 2020 10:59 AM
> > To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; David S. Miller
> > <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>; Kok, Auke-jan H
> > <auke-jan.h.kok@intel.com>; Jeff Garzik <jeff@garzik.org>
> > Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; linux-
> > kernel@vger.kernel.org; Brown, Len <len.brown@intel.com>; Rafael J. Wysocki
> > <rjw@rjwysocki.net>; Shevchenko, Andriy <andriy.shevchenko@intel.com>;
> > Neftin, Sasha <sasha.neftin@intel.com>; Lifshits, Vitaly
> > <vitaly.lifshits@intel.com>; Chen, Yu C <yu.c.chen@intel.com>;
> > Stable@vger.kernel.org
> > Subject: [PATCH 1/2] e1000e: Do not wake up the system via WOL if device
> > wakeup is disabled
> >
> > Currently the system will be woken up via WOL(Wake On Lan) even if the
> > device wakeup ability has been disabled via sysfs:
> >  cat /sys/devices/pci0000:00/0000:00:1f.6/power/wakeup
> >  disabled
> >
> > The system should not be woken up if the user has explicitly
> > disabled the wake up ability for this device.
> >
> > This patch clears the WOL ability of this network device if the
> > user has disabled the wake up ability in sysfs.
> >
> > Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver")
> > Reported-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: <Stable@vger.kernel.org>
> > Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> > ---
> >  drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++++++++----
> >  1 file changed, 10 insertions(+), 4 deletions(-)
> >
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> 
Thanks for testing, Aaron.

Best,
Chenyu
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 177c6da80c57..f6f730388705 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -6516,11 +6516,17 @@  static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct e1000_adapter *adapter = netdev_priv(netdev);
 	struct e1000_hw *hw = &adapter->hw;
-	u32 ctrl, ctrl_ext, rctl, status;
-	/* Runtime suspend should only enable wakeup for link changes */
-	u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
+	u32 ctrl, ctrl_ext, rctl, status, wufc;
 	int retval = 0;
 
+	/* Runtime suspend should only enable wakeup for link changes */
+	if (runtime)
+		wufc = E1000_WUFC_LNKC;
+	else if (device_may_wakeup(&pdev->dev))
+		wufc = adapter->wol;
+	else
+		wufc = 0;
+
 	status = er32(STATUS);
 	if (status & E1000_STATUS_LU)
 		wufc &= ~E1000_WUFC_LNKC;
@@ -6577,7 +6583,7 @@  static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 	if (adapter->hw.phy.type == e1000_phy_igp_3) {
 		e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
 	} else if (hw->mac.type >= e1000_pch_lpt) {
-		if (!(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC)))
+		if (wufc && !(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC)))
 			/* ULP does not support wake from unicast, multicast
 			 * or broadcast.
 			 */