All of lore.kernel.org
 help / color / mirror / Atom feed
* [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16
@ 2020-06-16 22:53 Jeff Kirsher
  2020-06-16 22:53 ` [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled Jeff Kirsher
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jeff Kirsher @ 2020-06-16 22:53 UTC (permalink / raw)
  To: davem; +Cc: Jeff Kirsher, netdev, nhorman, sassmann

This series contains fixes to e1000 and e1000e.

Chen fixes an e1000e issue where systems could be waken via WoL, even
though the user has disabled the wakeup bit via sysfs.

Vaibhav Gupta updates the e1000 driver to clean up the legacy Power
Management hooks.

Arnd Bergmann cleans up the inconsistent use CONFIG_PM_SLEEP
preprocessor tags, which also resolves the compiler warnings about the
possibility of unused structure.

The following are changes since commit b8ad540dd4e40566c520dff491fc06c71ae6b989:
  mptcp: fix memory leak in mptcp_subflow_create_socket()
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue 1GbE

Arnd Bergmann (1):
  e1000e: fix unused-function warning

Chen Yu (1):
  e1000e: Do not wake up the system via WOL if device wakeup is disabled

Vaibhav Gupta (1):
  e1000: use generic power management

 drivers/net/ethernet/intel/e1000/e1000_main.c | 49 +++++--------------
 drivers/net/ethernet/intel/e1000e/netdev.c    | 30 ++++++------
 2 files changed, 28 insertions(+), 51 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled
  2020-06-16 22:53 [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 Jeff Kirsher
@ 2020-06-16 22:53 ` Jeff Kirsher
  2020-06-18 13:18   ` Sasha Levin
  2020-06-16 22:53 ` [net 2/3] e1000: use generic power management Jeff Kirsher
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Jeff Kirsher @ 2020-06-16 22:53 UTC (permalink / raw)
  To: davem
  Cc: Chen Yu, netdev, nhorman, sassmann, Rafael J. Wysocki,
	Andy Shevchenko, Stable, Aaron Brown, Jeff Kirsher

From: Chen Yu <yu.c.chen@intel.com>

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>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index a279f4fa9962..e2ad3f38c75c 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -6611,11 +6611,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;
@@ -6672,7 +6678,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.
 			 */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net 2/3] e1000: use generic power management
  2020-06-16 22:53 [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 Jeff Kirsher
  2020-06-16 22:53 ` [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled Jeff Kirsher
@ 2020-06-16 22:53 ` Jeff Kirsher
  2020-06-16 22:53 ` [net 3/3] e1000e: fix unused-function warning Jeff Kirsher
  2020-06-16 23:16 ` [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Jeff Kirsher @ 2020-06-16 22:53 UTC (permalink / raw)
  To: davem; +Cc: Vaibhav Gupta, netdev, nhorman, sassmann, Aaron Brown, Jeff Kirsher

From: Vaibhav Gupta <vaibhavgupta40@gmail.com>

With legacy PM hooks, it was the responsibility of a driver to manage PCI
states and also the device's power state. The generic approach is to let PCI
core handle the work.

e1000_suspend() calls __e1000_shutdown() to perform intermediate tasks.
__e1000_shutdown() modifies the value of "wake" (device should be wakeup
enabled or not), responsible for controlling the flow of legacy PM.

Since, PCI core has no idea about the value of "wake", new code for generic
PM may produce unexpected results. Thus, use "device_set_wakeup_enable()"
to wakeup-enable the device accordingly.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 49 +++++--------------
 1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index d9fa4600f745..4b2de08137be 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -151,10 +151,8 @@ static int e1000_vlan_rx_kill_vid(struct net_device *netdev,
 				  __be16 proto, u16 vid);
 static void e1000_restore_vlan(struct e1000_adapter *adapter);
 
-#ifdef CONFIG_PM
-static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
-static int e1000_resume(struct pci_dev *pdev);
-#endif
+static int __maybe_unused e1000_suspend(struct device *dev);
+static int __maybe_unused e1000_resume(struct device *dev);
 static void e1000_shutdown(struct pci_dev *pdev);
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -179,16 +177,16 @@ static const struct pci_error_handlers e1000_err_handler = {
 	.resume = e1000_io_resume,
 };
 
+static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend, e1000_resume);
+
 static struct pci_driver e1000_driver = {
 	.name     = e1000_driver_name,
 	.id_table = e1000_pci_tbl,
 	.probe    = e1000_probe,
 	.remove   = e1000_remove,
-#ifdef CONFIG_PM
-	/* Power Management Hooks */
-	.suspend  = e1000_suspend,
-	.resume   = e1000_resume,
-#endif
+	.driver = {
+		.pm = &e1000_pm_ops,
+	},
 	.shutdown = e1000_shutdown,
 	.err_handler = &e1000_err_handler
 };
@@ -5060,9 +5058,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
 	struct e1000_hw *hw = &adapter->hw;
 	u32 ctrl, ctrl_ext, rctl, status;
 	u32 wufc = adapter->wol;
-#ifdef CONFIG_PM
-	int retval = 0;
-#endif
 
 	netif_device_detach(netdev);
 
@@ -5076,12 +5071,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
 		e1000_down(adapter);
 	}
 
-#ifdef CONFIG_PM
-	retval = pci_save_state(pdev);
-	if (retval)
-		return retval;
-#endif
-
 	status = er32(STATUS);
 	if (status & E1000_STATUS_LU)
 		wufc &= ~E1000_WUFC_LNKC;
@@ -5142,37 +5131,26 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused e1000_suspend(struct device *dev)
 {
 	int retval;
+	struct pci_dev *pdev = to_pci_dev(dev);
 	bool wake;
 
 	retval = __e1000_shutdown(pdev, &wake);
-	if (retval)
-		return retval;
-
-	if (wake) {
-		pci_prepare_to_sleep(pdev);
-	} else {
-		pci_wake_from_d3(pdev, false);
-		pci_set_power_state(pdev, PCI_D3hot);
-	}
+	device_set_wakeup_enable(dev, wake);
 
-	return 0;
+	return retval;
 }
 
-static int e1000_resume(struct pci_dev *pdev)
+static int __maybe_unused e1000_resume(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct e1000_adapter *adapter = netdev_priv(netdev);
 	struct e1000_hw *hw = &adapter->hw;
 	u32 err;
 
-	pci_set_power_state(pdev, PCI_D0);
-	pci_restore_state(pdev);
-	pci_save_state(pdev);
-
 	if (adapter->need_ioport)
 		err = pci_enable_device(pdev);
 	else
@@ -5209,7 +5187,6 @@ static int e1000_resume(struct pci_dev *pdev)
 
 	return 0;
 }
-#endif
 
 static void e1000_shutdown(struct pci_dev *pdev)
 {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [net 3/3] e1000e: fix unused-function warning
  2020-06-16 22:53 [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 Jeff Kirsher
  2020-06-16 22:53 ` [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled Jeff Kirsher
  2020-06-16 22:53 ` [net 2/3] e1000: use generic power management Jeff Kirsher
@ 2020-06-16 22:53 ` Jeff Kirsher
  2020-06-16 23:16 ` [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Jeff Kirsher @ 2020-06-16 22:53 UTC (permalink / raw)
  To: davem; +Cc: Arnd Bergmann, netdev, nhorman, sassmann, Aaron Brown, Jeff Kirsher

From: Arnd Bergmann <arnd@arndb.de>

The CONFIG_PM_SLEEP #ifdef checks in this file are inconsistent,
leading to a warning about sometimes unused function:

drivers/net/ethernet/intel/e1000e/netdev.c:137:13: error: unused function 'e1000e_check_me' [-Werror,-Wunused-function]

Rather than adding more #ifdefs, just remove them completely
and mark the PM functions as __maybe_unused to let the compiler
work it out on it own.

Fixes: e086ba2fccda ("e1000e: disable s0ix entry and exit flows for ME systems")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index e2ad3f38c75c..6f6479ca1267 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -6349,7 +6349,6 @@ static void e1000e_flush_lpic(struct pci_dev *pdev)
 	pm_runtime_put_sync(netdev->dev.parent);
 }
 
-#ifdef CONFIG_PM_SLEEP
 /* S0ix implementation */
 static void e1000e_s0ix_entry_flow(struct e1000_adapter *adapter)
 {
@@ -6571,7 +6570,6 @@ static void e1000e_s0ix_exit_flow(struct e1000_adapter *adapter)
 	mac_data &= ~E1000_CTRL_EXT_FORCE_SMBUS;
 	ew32(CTRL_EXT, mac_data);
 }
-#endif /* CONFIG_PM_SLEEP */
 
 static int e1000e_pm_freeze(struct device *dev)
 {
@@ -6875,7 +6873,6 @@ static int e1000e_pm_thaw(struct device *dev)
 	return rc;
 }
 
-#ifdef CONFIG_PM
 static int __e1000_resume(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
@@ -6941,8 +6938,7 @@ static int __e1000_resume(struct pci_dev *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int e1000e_pm_suspend(struct device *dev)
+static __maybe_unused int e1000e_pm_suspend(struct device *dev)
 {
 	struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
 	struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -6966,7 +6962,7 @@ static int e1000e_pm_suspend(struct device *dev)
 	return rc;
 }
 
-static int e1000e_pm_resume(struct device *dev)
+static __maybe_unused int e1000e_pm_resume(struct device *dev)
 {
 	struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
 	struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -6985,9 +6981,8 @@ static int e1000e_pm_resume(struct device *dev)
 
 	return e1000e_pm_thaw(dev);
 }
-#endif /* CONFIG_PM_SLEEP */
 
-static int e1000e_pm_runtime_idle(struct device *dev)
+static __maybe_unused int e1000e_pm_runtime_idle(struct device *dev)
 {
 	struct net_device *netdev = dev_get_drvdata(dev);
 	struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -7003,7 +6998,7 @@ static int e1000e_pm_runtime_idle(struct device *dev)
 	return -EBUSY;
 }
 
-static int e1000e_pm_runtime_resume(struct device *dev)
+static __maybe_unused int e1000e_pm_runtime_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct net_device *netdev = pci_get_drvdata(pdev);
@@ -7020,7 +7015,7 @@ static int e1000e_pm_runtime_resume(struct device *dev)
 	return rc;
 }
 
-static int e1000e_pm_runtime_suspend(struct device *dev)
+static __maybe_unused int e1000e_pm_runtime_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct net_device *netdev = pci_get_drvdata(pdev);
@@ -7045,7 +7040,6 @@ static int e1000e_pm_runtime_suspend(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
 
 static void e1000_shutdown(struct pci_dev *pdev)
 {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16
  2020-06-16 22:53 [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 Jeff Kirsher
                   ` (2 preceding siblings ...)
  2020-06-16 22:53 ` [net 3/3] e1000e: fix unused-function warning Jeff Kirsher
@ 2020-06-16 23:16 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-06-16 23:16 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, nhorman, sassmann

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Tue, 16 Jun 2020 15:53:51 -0700

> This series contains fixes to e1000 and e1000e.
> 
> Chen fixes an e1000e issue where systems could be waken via WoL, even
> though the user has disabled the wakeup bit via sysfs.
> 
> Vaibhav Gupta updates the e1000 driver to clean up the legacy Power
> Management hooks.
> 
> Arnd Bergmann cleans up the inconsistent use CONFIG_PM_SLEEP
> preprocessor tags, which also resolves the compiler warnings about the
> possibility of unused structure.
> 
> The following are changes since commit b8ad540dd4e40566c520dff491fc06c71ae6b989:
>   mptcp: fix memory leak in mptcp_subflow_create_socket()
> and are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue 1GbE

Pulled, thanks Jeff.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled
  2020-06-16 22:53 ` [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled Jeff Kirsher
@ 2020-06-18 13:18   ` Sasha Levin
  0 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2020-06-18 13:18 UTC (permalink / raw)
  To: Sasha Levin, Jeff Kirsher, Chen Yu, davem; +Cc: Chen Yu, netdev, Stable, stable

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.7.2, v5.4.46, v4.19.128, v4.14.184, v4.9.227, v4.4.227.

v5.7.2: Build OK!
v5.4.46: Build OK!
v4.19.128: Build OK!
v4.14.184: Build OK!
v4.9.227: Failed to apply! Possible dependencies:
    c8744f44aeaee ("e1000e: Add Support for CannonLake")

v4.4.227: Failed to apply! Possible dependencies:
    16ecba59bc333 ("e1000e: Do not read ICR in Other interrupt")
    18dd239207038 ("e1000e: use BIT() macro for bit defines")
    74f31299a41e7 ("e1000e: Increase PHY PLL clock gate timing")
    c8744f44aeaee ("e1000e: Add Support for CannonLake")
    f3ed935de059b ("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?

-- 
Thanks
Sasha

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-18 13:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 22:53 [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 Jeff Kirsher
2020-06-16 22:53 ` [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled Jeff Kirsher
2020-06-18 13:18   ` Sasha Levin
2020-06-16 22:53 ` [net 2/3] e1000: use generic power management Jeff Kirsher
2020-06-16 22:53 ` [net 3/3] e1000e: fix unused-function warning Jeff Kirsher
2020-06-16 23:16 ` [net 0/3][pull request] Intel Wired LAN Driver Updates 2020-06-16 David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.