Commit 6f82b255 authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by Tony Nguyen

ixgbe: use generic power management

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.

ixgbe_suspend() calls __ixgbe_shutdown() to perform intermediate tasks.
__ixgbe_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.

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent e9c971bd
...@@ -6877,32 +6877,20 @@ int ixgbe_close(struct net_device *netdev) ...@@ -6877,32 +6877,20 @@ int ixgbe_close(struct net_device *netdev)
return 0; return 0;
} }
#ifdef CONFIG_PM static int __maybe_unused ixgbe_resume(struct device *dev_d)
static int ixgbe_resume(struct pci_dev *pdev)
{ {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); struct ixgbe_adapter *adapter = pci_get_drvdata(pdev);
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
u32 err; u32 err;
adapter->hw.hw_addr = adapter->io_addr; adapter->hw.hw_addr = adapter->io_addr;
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
/*
* pci_restore_state clears dev->state_saved so call
* pci_save_state to restore it.
*/
pci_save_state(pdev);
err = pci_enable_device_mem(pdev);
if (err) {
e_dev_err("Cannot enable PCI device from suspend\n");
return err;
}
smp_mb__before_atomic(); smp_mb__before_atomic();
clear_bit(__IXGBE_DISABLED, &adapter->state); clear_bit(__IXGBE_DISABLED, &adapter->state);
pci_set_master(pdev); pci_set_master(pdev);
pci_wake_from_d3(pdev, false); device_wakeup_disable(dev_d);
ixgbe_reset(adapter); ixgbe_reset(adapter);
...@@ -6920,7 +6908,6 @@ static int ixgbe_resume(struct pci_dev *pdev) ...@@ -6920,7 +6908,6 @@ static int ixgbe_resume(struct pci_dev *pdev)
return err; return err;
} }
#endif /* CONFIG_PM */
static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake) static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
{ {
...@@ -6929,9 +6916,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake) ...@@ -6929,9 +6916,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_hw *hw = &adapter->hw;
u32 ctrl; u32 ctrl;
u32 wufc = adapter->wol; u32 wufc = adapter->wol;
#ifdef CONFIG_PM
int retval = 0;
#endif
rtnl_lock(); rtnl_lock();
netif_device_detach(netdev); netif_device_detach(netdev);
...@@ -6942,12 +6926,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake) ...@@ -6942,12 +6926,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
ixgbe_clear_interrupt_scheme(adapter); ixgbe_clear_interrupt_scheme(adapter);
rtnl_unlock(); rtnl_unlock();
#ifdef CONFIG_PM
retval = pci_save_state(pdev);
if (retval)
return retval;
#endif
if (hw->mac.ops.stop_link_on_d3) if (hw->mac.ops.stop_link_on_d3)
hw->mac.ops.stop_link_on_d3(hw); hw->mac.ops.stop_link_on_d3(hw);
...@@ -7002,26 +6980,18 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake) ...@@ -7002,26 +6980,18 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
return 0; return 0;
} }
#ifdef CONFIG_PM static int __maybe_unused ixgbe_suspend(struct device *dev_d)
static int ixgbe_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
struct pci_dev *pdev = to_pci_dev(dev_d);
int retval; int retval;
bool wake; bool wake;
retval = __ixgbe_shutdown(pdev, &wake); retval = __ixgbe_shutdown(pdev, &wake);
if (retval)
return retval;
if (wake) { device_set_wakeup_enable(dev_d, wake);
pci_prepare_to_sleep(pdev);
} else {
pci_wake_from_d3(pdev, false);
pci_set_power_state(pdev, PCI_D3hot);
}
return 0; return retval;
} }
#endif /* CONFIG_PM */
static void ixgbe_shutdown(struct pci_dev *pdev) static void ixgbe_shutdown(struct pci_dev *pdev)
{ {
...@@ -11383,15 +11353,14 @@ static const struct pci_error_handlers ixgbe_err_handler = { ...@@ -11383,15 +11353,14 @@ static const struct pci_error_handlers ixgbe_err_handler = {
.resume = ixgbe_io_resume, .resume = ixgbe_io_resume,
}; };
static SIMPLE_DEV_PM_OPS(ixgbe_pm_ops, ixgbe_suspend, ixgbe_resume);
static struct pci_driver ixgbe_driver = { static struct pci_driver ixgbe_driver = {
.name = ixgbe_driver_name, .name = ixgbe_driver_name,
.id_table = ixgbe_pci_tbl, .id_table = ixgbe_pci_tbl,
.probe = ixgbe_probe, .probe = ixgbe_probe,
.remove = ixgbe_remove, .remove = ixgbe_remove,
#ifdef CONFIG_PM .driver.pm = &ixgbe_pm_ops,
.suspend = ixgbe_suspend,
.resume = ixgbe_resume,
#endif
.shutdown = ixgbe_shutdown, .shutdown = ixgbe_shutdown,
.sriov_configure = ixgbe_pci_sriov_configure, .sriov_configure = ixgbe_pci_sriov_configure,
.err_handler = &ixgbe_err_handler .err_handler = &ixgbe_err_handler
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment