ethernet: intel: e1000: Convert to dev_pm_ops
Subsystems (2)
PATCH 1/1 ethernet: intel: e1000: Convert to dev_pm_ops
Convert the legacy callback .suspend() and .resume() to the generic ones.
--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_main.c +12 -35
@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct net_device *netdev,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); +static int e1000_suspend (struct device *dev); +static int e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);
@@ -179,16 +179,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 };
@@ -5052,9 +5052,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);
@@ -5068,12 +5065,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 ;
@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int 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); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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
Signature · 6 lines
2.26.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Hi Vaibhav,
Thanks for the patch. Minor procedural nits:
1) Use "git log --oneline drivers/net/ethernet/intel/e1000/e1000_main.c" and match the prefix to the convention for the file. The e1000-specific commits all start with "e1000: "
2) The subject should say something about the overall goal and why we want this, so "dev_pm_ops" is a little too low-level. I like "Convert to generic power management", e.g.,
e1000: Convert to generic power management
When you eventually post this to netdev, I think you should post several patches as a series, e.g., maybe all the Intel drivers together. In this case it's not because they depend on each other, but because the patches will be similar and the same set of people will review them, so it's convenient for them to look at them all at once.
Quoted 2 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
This should mention "power management" somehow. I think 77b84bb306fd ("xen-platform: Convert to generic power management") is a good template (of course, since I wrote it :)).
I have other questions, so no need to repost this until we work through those a little bit.
Bjorn
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 4 lines
1) Use "git log --oneline
drivers/net/ethernet/intel/e1000/e1000_main.c" and match the prefix to the convention for the file. The e1000-specific commits all start with "e1000: "
Okay, will do that!
Quoted 6 lines
2) The subject should say something about the overall goal and why we want this, so "
dev_pm_ops" is a little too low-level. I like "Convert to generic power management", e.g.,e1000: Convert to generic power management
Okay!
Quoted 7 lines
When you eventually post this to netdev, I think you should post several patches as a series, e.g., maybe all the Intel drivers together. In this case it's not because they depend on each other, but because the patches will be similar and the same set of people will review them, so it's convenient for them to look at them all at once.
Yes, when I will send it to netdev, will send the patch-set for whole intel family. This patch is for RFC.
Quoted 3 lines
This should mention "power management" somehow. I think
77b84bb306fd("xen-platform: Convert to generic power management") is a good template (of course, since I wrote it :)).
Sure, I will follow that.
Quoted 4 lines
I have other questions, so no need to repost this until we work through those a little bit.
Okay! Thanks!
--Vaibhav Gupta
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 6 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++--------------
drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) · line 5075
Quoted 8 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5@@ -5068,12 +5065,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
__e1000_shutdown() is used in both by both e1000_suspend() and e1000_shutdown(). Suspend is obviously for power management, but I don't understand the connection between shutdown and PM. Why would something in the shutdown path would depend on CONFIG_PM?
If we're in the shutdown path, we're either going to power off the whole machine or reboot (or kexec a new kernel). In any event, I don't think the pci_save_state() is needed, so removing it shouldn't hurt shutdown.
But I'm curious about this common idiom in e1000 and other network drivers:
e1000_shutdown()
{
...
if (system_state == SYSTEM_POWER_OFF) {
pci_wake_from_d3(pdev, wake);
pci_set_power_state(pdev, PCI_D3hot);
}
}The pci_wake_from_d3() part sort of makes sense -- we want to configure the device for wake-on-lan. But all the drivers that do this are network drivers. USB, keyboard, etc drivers also need that functionality, but none of them use pci_wake_from_d3(). Why?
And why do we need the pci_set_power_state()? Seems like if we're going to power off the whole machine we wouldn't need to set devices to D3hot. Almost all the pci_set_power_state(pdev, PCI_D3hot) calls are from legacy suspend functions (which makes sense to me) or network driver shutdown functions, and I don't understand why network drivers do this differently than others.
Bjorn
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Rafael, do you have any thoughts on this?
Quoted 21 lines · Bjorn Helgaas
Quoted 6 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++--------------drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) · line 5075
Quoted 8 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5@@ -5068,12 +5065,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
__e1000_shutdown()is used in both by bothe1000_suspend()ande1000_shutdown(). Suspend is obviously for power management, but I don't understand the connection between shutdown and PM. Why would something in the shutdown path would depend onCONFIG_PM?
Quoted 4 lines
If we're in the shutdown path, we're either going to power off the whole machine or reboot (or kexec a new kernel). In any event, I don't think the
pci_save_state()is needed, so removing it shouldn't hurt shutdown.
I think it's OK to remove the pci_save_state() because I don't think we ever needed it in the .shutdown() path, and we shouldn't need it in the new generic .suspend() path.
But the commit log should probably mention the fact that it's being removed from .shutdown().
Quoted 17 lines
But I'm curious about this common idiom in e1000 and other network drivers:
e1000_shutdown() { ... if (system_state == SYSTEM_POWER_OFF) { pci_wake_from_d3(pdev, wake); pci_set_power_state(pdev, PCI_D3hot); } }The
pci_wake_from_d3()part sort of makes sense -- we want to configure the device for wake-on-lan. But all the drivers that do this are network drivers. USB, keyboard, etc drivers also need that functionality, but none of them usepci_wake_from_d3(). Why?
Quoted 6 lines
And why do we need the
pci_set_power_state()? Seems like if we're going to power off the whole machine we wouldn't need to set devices to D3hot. Almost all thepci_set_power_state(pdev, PCI_D3hot)calls are from legacy suspend functions (which makes sense to me) or network driver shutdown functions, and I don't understand why network drivers do this differently than others.
This part is a tangent. Most NIC drivers don't have this code, so I suspect it's not quite right, but you're not changing this part of .shutdown(), so we can just let sleeping dogs lie for now.
Bjorn
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
[+cc Jeff, Jesse]
Quoted 77 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
Signed-off-by Vaibhav Gupta <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)drivers/net/ethernet/intel/e1000/e1000_main.c +9
-18@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct net_device *netdev,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); +static int e1000_suspend (struct device *dev); +static int e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);@@ -179,16 +179,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 };@@ -5052,9 +5052,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);@@ -5068,12 +5065,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 ;@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int e1000_suspend (struct device *dev) { -int retval; +struct pci_dev *pdev =to_pci_dev (dev);
drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) · line 5150
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-8bool wake; - retval =__e1000_shutdown (pdev, &wake); -if (retval) -return retval; - -if (wake) { -pci_prepare_to_sleep (pdev); - }else { -pci_wake_from_d3 (pdev, false);
I think there's a case where this changes the behavior because we normally set the device wakeup enable to adapter->wol, but the "wake" returned from __e1000_shutdown() is sometimes different.
e1000_probe
adapter->wol = adapter->eeprom_wol; # assume adapter->wol == 1
device_set_wakeup_enable(adapter->wol);Existing code:
e1000_suspend
__e1000_shutdown(&wake) # assume returns wake == 0
pci_wake_from_d3(false)
pci_enable_wake(PCI_D3hot, false) # <-- compare New code using generic PM ops:
pci_pm_suspend
e1000_suspend
__e1000_shutdown(&wake) # returns wake == 0 (ignored)
pci_pm_suspend_noirq
pci_prepare_to_sleep
wakeup = device_may_wakeup() # returns 1
pci_enable_wake(PCI_D3hot, true) # <-- different!
I sort of suspect that __e1000_shutdown() should call device_set_wakeup_enable() when it updates the chip's wake-on-lan registers, but the driver maintainers would know better.
Quoted 26 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +3
-9-pci_set_power_state (pdev, PCI_D3hot); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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 Signature · 1 line
2.26.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 11 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, May 1, 2020 13:58
To: Vaibhav Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Kirsher, Jeffrey T <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: Re: [Linux-kernel-mentees] [PATCH v1] ethernet: intel: e1000: Convert todev_pm_ops
Quoted 11 lines
[+cc Jeff, Jesse]
Quoted 8 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
Signed-off-by Vaibhav Gupta <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)
[Kirsher, Jeffrey T]
Was there a reason why this patch was not at least CC'd to [email protected] mailing list for all Intel wired LAN driver changes? Thank you Bjorn for at least adding Jesse and myself to the thread.
On top of the potential issues Bjorn pointed out, this could cause regression issues that can not fully be validated since this driver is really old and all supported devices may no longer be available to test against.
Quoted 130 lines
drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers
Quoted 19 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-0@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct
net_device*netdev, static voide1000_restore_vlan(struct e1000_adapter *adapter);#ifdef
CONFIG_PMdrivers/net/ethernet/intel/e1000/e1000_main.c +2
-2-static int e1000_suspend (struct pci_dev *pdev,pm_message_t state); -static int e1000_resume (struct pci_dev *pdev); +static int e1000_suspend (struct device *dev);static int +e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);@@ -179,16 +179,16 @@ static const struct pci_error_handlers
e1000_err_handler= {drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers e1000_err_handler = {
Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +1
-0.resume = e1000_io_resume, }; +static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend,
e1000_resume);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev,
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +4
-5+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 };@@ -5052,9 +5052,6 @@ static int __e1000_shutdown(struct pci_dev *pdev,bool
*enable_wake)drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-3struct 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);@@ -5068,12 +5065,6 @@ static int __e1000_shutdown(struct pci_dev*pdev, bool
*enable_wake)Quoted 21 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +2
-8e1000_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 ;@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int e1000_suspend (struct device *dev) { -int retval; +struct pci_dev *pdev =to_pci_dev (dev);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev · line 5150
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-8bool wake; - retval =__e1000_shutdown (pdev, &wake); -if (retval) -return retval; - -if (wake) { -pci_prepare_to_sleep (pdev); - }else { -pci_wake_from_d3 (pdev, false);I think there's a case where this changes the behavior because we normally set the device wakeup enable to
adapter->wol, but the "wake"
returned from__e1000_shutdown()is sometimes different.e1000_probe adapter->wol = adapter->eeprom_wol; # assume adapter->wol == 1 device_set_wakeup_enable(adapter->wol);Existing code:
e1000_suspend __e1000_shutdown(&wake) # assume returns wake == 0 pci_wake_from_d3(false) pci_enable_wake(PCI_D3hot, false) # <-- compareNew code using generic PM ops:
pci_pm_suspend
e1000_suspend
__e1000_shutdown(&wake)# returns wake == 0 (ignored)
pci_pm_suspend_noirq
pci_prepare_to_sleep
wakeup =device_may_wakeup()# returns 1
pci_enable_wake(PCI_D3hot, true)# <-- different!I sort of suspect that
__e1000_shutdown()should calldevice_set_wakeup_enable()when it updates the chip's wake-on-lan registers, but the driver maintainers would know better.Quoted 16 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +3
-5-pci_set_power_state (pdev, PCI_D3hot); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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;
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5-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 --2.26.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 22 lines · Jeffrey T
Quoted 11 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, May 1, 2020 13:58
To: Vaibhav Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Kirsher, Jeffrey T <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: Re: [Linux-kernel-mentees] [PATCH v1] ethernet: intel: e1000: Convert todev_pm_opsQuoted 11 lines
[+cc Jeff, Jesse]
Quoted 8 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
Signed-off-by Vaibhav Gupta <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)
Quoted 6 lines
[Kirsher, Jeffrey T]
Was there a reason why this patch was not at least CC'd to [email protected] mailing list for all Intel wired LAN driver changes? Thank you Bjorn for at least adding Jesse and myself to the thread.
Don't worry, this is potentially part of a mentoring project, and we're just trying to shake out trivial issues first before throwing Vaibhav straight into the lions' den, so to speak.
Quoted 4 lines
On top of the potential issues Bjorn pointed out, this could cause regression issues that can not fully be validated since this driver is really old and all supported devices may no longer be available to test against.
Understood. The problem we're trying to solve is that the PCI core carries quite a bit of code to support both the legacy power management and the "new" (now 10 year-old) generic scheme. That extra code is its own source of bugs since it's hard to keep both paths up to date and tested.
Quoted 109 lines
Quoted 109 lines
drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-0@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct
net_device*netdev, static voide1000_restore_vlan(struct e1000_adapter *adapter);#ifdef
CONFIG_PMdrivers/net/ethernet/intel/e1000/e1000_main.c +2
-2-static int e1000_suspend (struct pci_dev *pdev,pm_message_t state); -static int e1000_resume (struct pci_dev *pdev); +static int e1000_suspend (struct device *dev);static int +e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);@@ -179,16 +179,16 @@ static const struct pci_error_handlers
e1000_err_handler= {drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers e1000_err_handler = {
Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +1
-0.resume = e1000_io_resume, }; +static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend,
e1000_resume);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev,
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +4
-5+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 };@@ -5052,9 +5052,6 @@ static int __e1000_shutdown(struct pci_dev *pdev,bool
*enable_wake)drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-3struct 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);@@ -5068,12 +5065,6 @@ static int __e1000_shutdown(struct pci_dev*pdev, bool
*enable_wake)Quoted 21 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +2
-8e1000_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 ;@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int e1000_suspend (struct device *dev) { -int retval; +struct pci_dev *pdev =to_pci_dev (dev);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev · line 5150
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-8bool wake; - retval =__e1000_shutdown (pdev, &wake); -if (retval) -return retval; - -if (wake) { -pci_prepare_to_sleep (pdev); - }else { -pci_wake_from_d3 (pdev, false);I think there's a case where this changes the behavior because we normally set the device wakeup enable to
adapter->wol, but the "wake"
returned from__e1000_shutdown()is sometimes different.e1000_probe adapter->wol = adapter->eeprom_wol; # assume adapter->wol == 1 device_set_wakeup_enable(adapter->wol);Existing code:
e1000_suspend __e1000_shutdown(&wake) # assume returns wake == 0 pci_wake_from_d3(false) pci_enable_wake(PCI_D3hot, false) # <-- compareNew code using generic PM ops:
pci_pm_suspend
e1000_suspend
__e1000_shutdown(&wake)# returns wake == 0 (ignored)
pci_pm_suspend_noirq
pci_prepare_to_sleep
wakeup =device_may_wakeup()# returns 1
pci_enable_wake(PCI_D3hot, true)# <-- different!
Quoted 3 lines
Quoted 3 lines
I sort of suspect that
__e1000_shutdown()should calldevice_set_wakeup_enable()when it updates the chip's wake-on-lan registers, but the driver maintainers would know better.
If you have any ideas about this, or maybe patterns in newer Intel drivers that could be followed here, we'd love to hear them.
If you think it's impossible to update e1000 to generic power management, it'd be useful to know that, too, so we can move on to other drivers.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +3
-5-pci_set_power_state (pdev, PCI_D3hot); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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;
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5-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 --2.26.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 159 lines · Bjorn Helgaas
Quoted 22 lines · Jeffrey T
Quoted 11 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, May 1, 2020 13:58
To: Vaibhav Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Kirsher, Jeffrey T <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: Re: [Linux-kernel-mentees] [PATCH v1] ethernet: intel: e1000: Convert todev_pm_opsQuoted 11 lines
[+cc Jeff, Jesse]
Quoted 8 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
Signed-off-by Vaibhav Gupta <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)Quoted 6 lines
[Kirsher, Jeffrey T]
Was there a reason why this patch was not at least CC'd to [email protected] mailing list for all Intel wired LAN driver changes? Thank you Bjorn for at least adding Jesse and myself to the thread.
Don't worry, this is potentially part of a mentoring project, and we're just trying to shake out trivial issues first before throwing Vaibhav straight into the lions' den, so to speak.
Quoted 4 lines
On top of the potential issues Bjorn pointed out, this could cause regression issues that can not fully be validated since this driver is really old and all supported devices may no longer be available to test against.
Understood. The problem we're trying to solve is that the PCI core carries quite a bit of code to support both the legacy power management and the "new" (now 10 year-old) generic scheme. That extra code is its own source of bugs since it's hard to keep both paths up to date and tested.
Quoted 109 lines
Quoted 109 lines
drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-0@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct
net_device*netdev, static voide1000_restore_vlan(struct e1000_adapter *adapter);#ifdef
CONFIG_PMdrivers/net/ethernet/intel/e1000/e1000_main.c +2
-2-static int e1000_suspend (struct pci_dev *pdev,pm_message_t state); -static int e1000_resume (struct pci_dev *pdev); +static int e1000_suspend (struct device *dev);static int +e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);@@ -179,16 +179,16 @@ static const struct pci_error_handlers
e1000_err_handler= {drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers e1000_err_handler = {
Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +1
-0.resume = e1000_io_resume, }; +static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend,
e1000_resume);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev,
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +4
-5+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 };@@ -5052,9 +5052,6 @@ static int __e1000_shutdown(struct pci_dev *pdev,bool
*enable_wake)drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-3struct 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);@@ -5068,12 +5065,6 @@ static int __e1000_shutdown(struct pci_dev*pdev, bool
*enable_wake)Quoted 21 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +2
-8e1000_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 ;@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int e1000_suspend (struct device *dev) { -int retval; +struct pci_dev *pdev =to_pci_dev (dev);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev · line 5150
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-8bool wake; - retval =__e1000_shutdown (pdev, &wake); -if (retval) -return retval; - -if (wake) { -pci_prepare_to_sleep (pdev); - }else { -pci_wake_from_d3 (pdev, false);I think there's a case where this changes the behavior because we normally set the device wakeup enable to
adapter->wol, but the "wake"
returned from__e1000_shutdown()is sometimes different.e1000_probe adapter->wol = adapter->eeprom_wol; # assume adapter->wol == 1 device_set_wakeup_enable(adapter->wol);Existing code:
e1000_suspend __e1000_shutdown(&wake) # assume returns wake == 0 pci_wake_from_d3(false) pci_enable_wake(PCI_D3hot, false) # <-- compareNew code using generic PM ops:
pci_pm_suspend
e1000_suspend
__e1000_shutdown(&wake)# returns wake == 0 (ignored)
pci_pm_suspend_noirq
pci_prepare_to_sleep
wakeup =device_may_wakeup()# returns 1
pci_enable_wake(PCI_D3hot, true)# <-- different!Quoted 3 lines
Quoted 3 lines
I sort of suspect that
__e1000_shutdown()should calldevice_set_wakeup_enable()when it updates the chip's wake-on-lan registers, but the driver maintainers would know better.
Quoted 6 lines
If you have any ideas about this, or maybe patterns in newer Intel drivers that could be followed here, we'd love to hear them.
If you think it's impossible to update e1000 to generic power management, it'd be useful to know that, too, so we can move on to other drivers.
Is it safe to assume that we should leave e1000 for now? As the thread seems to be discontinued.
--Vaibhav Gupta
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +3
-5-pci_set_power_state (pdev, PCI_D3hot); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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;
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5-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 --2.26.0
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 162 lines · Vaibhav Gupta
Quoted 161 lines · Bjorn Helgaas
Quoted 22 lines · Jeffrey T
Quoted 11 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, May 1, 2020 13:58
To: Vaibhav Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Kirsher, Jeffrey T <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: Re: [Linux-kernel-mentees] [PATCH v1] ethernet: intel: e1000: Convert todev_pm_opsQuoted 11 lines
[+cc Jeff, Jesse]
Quoted 8 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
Signed-off-by Vaibhav Gupta <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)Quoted 6 lines
[Kirsher, Jeffrey T]
Was there a reason why this patch was not at least CC'd to [email protected] mailing list for all Intel wired LAN driver changes? Thank you Bjorn for at least adding Jesse and myself to the thread.
Don't worry, this is potentially part of a mentoring project, and we're just trying to shake out trivial issues first before throwing Vaibhav straight into the lions' den, so to speak.
Quoted 4 lines
On top of the potential issues Bjorn pointed out, this could cause regression issues that can not fully be validated since this driver is really old and all supported devices may no longer be available to test against.
Understood. The problem we're trying to solve is that the PCI core carries quite a bit of code to support both the legacy power management and the "new" (now 10 year-old) generic scheme. That extra code is its own source of bugs since it's hard to keep both paths up to date and tested.
Quoted 109 lines
Quoted 109 lines
drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-0@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct
net_device*netdev, static voide1000_restore_vlan(struct e1000_adapter *adapter);#ifdef
CONFIG_PMdrivers/net/ethernet/intel/e1000/e1000_main.c +2
-2-static int e1000_suspend (struct pci_dev *pdev,pm_message_t state); -static int e1000_resume (struct pci_dev *pdev); +static int e1000_suspend (struct device *dev);static int +e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);@@ -179,16 +179,16 @@ static const struct pci_error_handlers
e1000_err_handler= {drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers e1000_err_handler = {
Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +1
-0.resume = e1000_io_resume, }; +static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend,
e1000_resume);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev,
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +4
-5+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 };@@ -5052,9 +5052,6 @@ static int __e1000_shutdown(struct pci_dev *pdev,bool
*enable_wake)drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-3struct 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);@@ -5068,12 +5065,6 @@ static int __e1000_shutdown(struct pci_dev*pdev, bool
*enable_wake)Quoted 21 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +2
-8e1000_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 ;@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int e1000_suspend (struct device *dev) { -int retval; +struct pci_dev *pdev =to_pci_dev (dev);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev · line 5150
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-8bool wake; - retval =__e1000_shutdown (pdev, &wake); -if (retval) -return retval; - -if (wake) { -pci_prepare_to_sleep (pdev); - }else { -pci_wake_from_d3 (pdev, false);I think there's a case where this changes the behavior because we normally set the device wakeup enable to
adapter->wol, but the "wake"
returned from__e1000_shutdown()is sometimes different.e1000_probe adapter->wol = adapter->eeprom_wol; # assume adapter->wol == 1 device_set_wakeup_enable(adapter->wol);Existing code:
e1000_suspend __e1000_shutdown(&wake) # assume returns wake == 0 pci_wake_from_d3(false) pci_enable_wake(PCI_D3hot, false) # <-- compareNew code using generic PM ops:
pci_pm_suspend
e1000_suspend
__e1000_shutdown(&wake)# returns wake == 0 (ignored)
pci_pm_suspend_noirq
pci_prepare_to_sleep
wakeup =device_may_wakeup()# returns 1
pci_enable_wake(PCI_D3hot, true)# <-- different!Quoted 3 lines
Quoted 3 lines
I sort of suspect that
__e1000_shutdown()should calldevice_set_wakeup_enable()when it updates the chip's wake-on-lan registers, but the driver maintainers would know better.If you have any ideas about this, or maybe patterns in newer Intel drivers that could be followed here, we'd love to hear them.
Quoted 6 lines
Quoted 3 lines
If you think it's impossible to update e1000 to generic power management, it'd be useful to know that, too, so we can move on to other drivers.
Is it safe to assume that we should leave e1000 for now? As the thread seems to be discontinued.
My suggestion: update the patch to reflect my feedback above, and post what we believe to be the correct thing to the appropriate upstream lists:
Jeff Kirsher <[email protected]>
Jesse Brandeburg <[email protected]>
David S. Miller <[email protected]>
Rafael J. Wysocki <[email protected]>
[email protected]
[email protected]
[email protected]
[email protected]
The maintainers may want to defer it for now because it's old hardware that's hard to test, and that's OK. But at least we'll have the patch available, and if/when we get to the point of removing legacy PM from the PCI core, we can revisit this.
What we learn about wake-on-LAN here will probably apply to other drivers as well.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +3
-5-pci_set_power_state (pdev, PCI_D3hot); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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;
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5-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 --2.26.0
Quoted 4 lines
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 184 lines · Bjorn Helgaas
Quoted 162 lines · Vaibhav Gupta
Quoted 161 lines · Bjorn Helgaas
Quoted 22 lines · Jeffrey T
Quoted 11 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, May 1, 2020 13:58
To: Vaibhav Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Kirsher, Jeffrey T <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: Re: [Linux-kernel-mentees] [PATCH v1] ethernet: intel: e1000: Convert todev_pm_opsQuoted 11 lines
[+cc Jeff, Jesse]
Quoted 8 lines · Vaibhav Gupta
Convert the legacy callback .suspend() and .resume() to the generic ones.
Signed-off-by Vaibhav Gupta <[email protected]>--- drivers/net/ethernet/intel/e1000/e1000_main.c | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-)Quoted 6 lines
[Kirsher, Jeffrey T]
Was there a reason why this patch was not at least CC'd to [email protected] mailing list for all Intel wired LAN driver changes? Thank you Bjorn for at least adding Jesse and myself to the thread.
Don't worry, this is potentially part of a mentoring project, and we're just trying to shake out trivial issues first before throwing Vaibhav straight into the lions' den, so to speak.
Quoted 4 lines
On top of the potential issues Bjorn pointed out, this could cause regression issues that can not fully be validated since this driver is really old and all supported devices may no longer be available to test against.
Understood. The problem we're trying to solve is that the PCI core carries quite a bit of code to support both the legacy power management and the "new" (now 10 year-old) generic scheme. That extra code is its own source of bugs since it's hard to keep both paths up to date and tested.
Quoted 109 lines
Quoted 109 lines
drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-0@@ -152,8 +152,8 @@ static int e1000_vlan_rx_kill_vid(struct
net_device*netdev, static voide1000_restore_vlan(struct e1000_adapter *adapter);#ifdef
CONFIG_PMdrivers/net/ethernet/intel/e1000/e1000_main.c +2
-2-static int e1000_suspend (struct pci_dev *pdev,pm_message_t state); -static int e1000_resume (struct pci_dev *pdev); +static int e1000_suspend (struct device *dev);static int +e1000_resume (struct device *dev);#endif static void e1000_shutdown (struct pci_dev *pdev);@@ -179,16 +179,16 @@ static const struct pci_error_handlers
e1000_err_handler= {drivers/net/ethernet/intel/e1000/e1000_main.c static const struct pci_error_handlers e1000_err_handler = {
Quoted 4 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +1
-0.resume = e1000_io_resume, }; +static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend,
e1000_resume);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev *pdev,
Quoted 18 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +4
-5+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 };@@ -5052,9 +5052,6 @@ static int __e1000_shutdown(struct pci_dev *pdev,bool
*enable_wake)drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-3struct 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);@@ -5068,12 +5065,6 @@ static int __e1000_shutdown(struct pci_dev*pdev, bool
*enable_wake)Quoted 21 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +2
-8e1000_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 ;@@ -5135,36 +5126,22 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) }#ifdef CONFIG_PM -static int e1000_suspend (struct pci_dev *pdev,pm_message_t state) +static int e1000_suspend (struct device *dev) { -int retval; +struct pci_dev *pdev =to_pci_dev (dev);drivers/net/ethernet/intel/e1000/e1000_main.c static int __e1000_shutdown(struct pci_dev · line 5150
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-8bool wake; - retval =__e1000_shutdown (pdev, &wake); -if (retval) -return retval; - -if (wake) { -pci_prepare_to_sleep (pdev); - }else { -pci_wake_from_d3 (pdev, false);I think there's a case where this changes the behavior because we normally set the device wakeup enable to
adapter->wol, but the "wake"
returned from__e1000_shutdown()is sometimes different.e1000_probe adapter->wol = adapter->eeprom_wol; # assume adapter->wol == 1 device_set_wakeup_enable(adapter->wol);Existing code:
e1000_suspend __e1000_shutdown(&wake) # assume returns wake == 0 pci_wake_from_d3(false) pci_enable_wake(PCI_D3hot, false) # <-- compareNew code using generic PM ops:
pci_pm_suspend
e1000_suspend
__e1000_shutdown(&wake)# returns wake == 0 (ignored)
pci_pm_suspend_noirq
pci_prepare_to_sleep
wakeup =device_may_wakeup()# returns 1
pci_enable_wake(PCI_D3hot, true)# <-- different!Quoted 3 lines
Quoted 3 lines
I sort of suspect that
__e1000_shutdown()should calldevice_set_wakeup_enable()when it updates the chip's wake-on-lan registers, but the driver maintainers would know better.If you have any ideas about this, or maybe patterns in newer Intel drivers that could be followed here, we'd love to hear them.
Quoted 6 lines
Quoted 3 lines
If you think it's impossible to update e1000 to generic power management, it'd be useful to know that, too, so we can move on to other drivers.
Is it safe to assume that we should leave e1000 for now? As the thread seems to be discontinued.
My suggestion: update the patch to reflect my feedback above, and post what we believe to be the correct thing to the appropriate upstream lists:
Jeff Kirsher <[email protected]>
Jesse Brandeburg <[email protected]>
David S. Miller <[email protected]>
Rafael J. Wysocki <[email protected]>
[email protected]
[email protected]
[email protected]
[email protected]
Quoted 7 lines
The maintainers may want to defer it for now because it's old hardware that's hard to test, and that's OK. But at least we'll have the patch available, and if/when we get to the point of removing legacy PM from the PCI core, we can revisit this.
What we learn about wake-on-LAN here will probably apply to other drivers as well.
Sure! Thanks !
--Vaibhav Gupta
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +3
-5-pci_set_power_state (pdev, PCI_D3hot); - } - -return 0 ; +return __e1000_shutdown (pdev, &wake); } -static int e1000_resume (struct pci_dev *pdev) +static int 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;
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/intel/e1000/e1000_main.c +0
-5-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 --2.26.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees