Commit 8249c47c authored by Jacob Keller's avatar Jacob Keller Committed by Jeff Kirsher

fm10k: use generic PM hooks instead of legacy PCIe power hooks

Replace the PCI specific legacy power management hooks with the new
generic power management hooks which work properly for both suspend and
hibernate. The new generic system is better and properly handles the
lower level PCIe power management rather than forcing the driver to
handle it.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarKrishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent b4fcd436
...@@ -2264,36 +2264,19 @@ static int fm10k_handle_resume(struct fm10k_intfc *interface) ...@@ -2264,36 +2264,19 @@ static int fm10k_handle_resume(struct fm10k_intfc *interface)
#ifdef CONFIG_PM #ifdef CONFIG_PM
/** /**
* fm10k_resume - Restore device to pre-sleep state * fm10k_resume - Generic PM resume hook
* @pdev: PCI device information struct * @dev: generic device structure
* *
* fm10k_resume is called after the system has powered back up from a sleep * Generic PM hook used when waking the device from a low power state after
* state and is ready to resume operation. This function is meant to restore * suspend or hibernation. This function does not need to handle lower PCIe
* the device back to its pre-sleep state. * device state as the stack takes care of that for us.
**/ **/
static int fm10k_resume(struct pci_dev *pdev) static int fm10k_resume(struct device *dev)
{ {
struct fm10k_intfc *interface = pci_get_drvdata(pdev); struct fm10k_intfc *interface = pci_get_drvdata(to_pci_dev(dev));
struct net_device *netdev = interface->netdev; struct net_device *netdev = interface->netdev;
struct fm10k_hw *hw = &interface->hw; struct fm10k_hw *hw = &interface->hw;
u32 err; int err;
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) {
dev_err(&pdev->dev, "Cannot enable PCI device from suspend\n");
return err;
}
pci_set_master(pdev);
pci_wake_from_d3(pdev, false);
/* refresh hw_addr in case it was dropped */ /* refresh hw_addr in case it was dropped */
hw->hw_addr = interface->uc_addr; hw->hw_addr = interface->uc_addr;
...@@ -2308,36 +2291,27 @@ static int fm10k_resume(struct pci_dev *pdev) ...@@ -2308,36 +2291,27 @@ static int fm10k_resume(struct pci_dev *pdev)
} }
/** /**
* fm10k_suspend - Prepare the device for a system sleep state * fm10k_suspend - Generic PM suspend hook
* @pdev: PCI device information struct * @dev: generic device structure
* *
* fm10k_suspend is meant to shutdown the device prior to the system entering * Generic PM hook used when setting the device into a low power state for
* a sleep state. The fm10k hardware does not support wake on lan so the * system suspend or hibernation. This function does not need to handle lower
* driver simply needs to shut down the device so it is in a low power state. * PCIe device state as the stack takes care of that for us.
**/ **/
static int fm10k_suspend(struct pci_dev *pdev, static int fm10k_suspend(struct device *dev)
pm_message_t __always_unused state)
{ {
struct fm10k_intfc *interface = pci_get_drvdata(pdev); struct fm10k_intfc *interface = pci_get_drvdata(to_pci_dev(dev));
struct net_device *netdev = interface->netdev; struct net_device *netdev = interface->netdev;
int err = 0;
netif_device_detach(netdev); netif_device_detach(netdev);
fm10k_prepare_suspend(interface); fm10k_prepare_suspend(interface);
err = pci_save_state(pdev);
if (err)
return err;
pci_disable_device(pdev);
pci_wake_from_d3(pdev, false);
pci_set_power_state(pdev, PCI_D3hot);
return 0; return 0;
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
/** /**
* fm10k_io_error_detected - called when PCI error is detected * fm10k_io_error_detected - called when PCI error is detected
* @pdev: Pointer to PCI device * @pdev: Pointer to PCI device
...@@ -2447,15 +2421,18 @@ static const struct pci_error_handlers fm10k_err_handler = { ...@@ -2447,15 +2421,18 @@ static const struct pci_error_handlers fm10k_err_handler = {
.reset_done = fm10k_io_reset_done, .reset_done = fm10k_io_reset_done,
}; };
static SIMPLE_DEV_PM_OPS(fm10k_pm_ops, fm10k_suspend, fm10k_resume);
static struct pci_driver fm10k_driver = { static struct pci_driver fm10k_driver = {
.name = fm10k_driver_name, .name = fm10k_driver_name,
.id_table = fm10k_pci_tbl, .id_table = fm10k_pci_tbl,
.probe = fm10k_probe, .probe = fm10k_probe,
.remove = fm10k_remove, .remove = fm10k_remove,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = fm10k_suspend, .driver = {
.resume = fm10k_resume, .pm = &fm10k_pm_ops,
#endif },
#endif /* CONFIG_PM */
.sriov_configure = fm10k_iov_configure, .sriov_configure = fm10k_iov_configure,
.err_handler = &fm10k_err_handler .err_handler = &fm10k_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