提交 0e5d3da4 编写于 作者: J Jacob Keller 提交者: Jeff Kirsher

i40e: use newer generic PM support instead of legacy PM callbacks

Stop using the old legacy PM support, since we now have stable support
for the newer generic PM callbacks.

This has several advantages. First, we no longer have to manage our
own pci_save_state() and power changes, as it's preferred to have the
PCI stack do this. Second, these routines get called for both hibernate
and suspend to ram, so we can have the driver properly handle all the
suspend/resume flows that it needs to.
Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
Tested-by: NAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 c17401a1
...@@ -12050,14 +12050,14 @@ static void i40e_shutdown(struct pci_dev *pdev) ...@@ -12050,14 +12050,14 @@ static void i40e_shutdown(struct pci_dev *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
/** /**
* i40e_suspend - PCI callback for moving to D3 * i40e_suspend - PM callback for moving to D3
* @pdev: PCI device information struct * @dev: generic device information structure
**/ **/
static int i40e_suspend(struct pci_dev *pdev, pm_message_t state) static int i40e_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev);
struct i40e_pf *pf = pci_get_drvdata(pdev); struct i40e_pf *pf = pci_get_drvdata(pdev);
struct i40e_hw *hw = &pf->hw; struct i40e_hw *hw = &pf->hw;
int retval = 0;
set_bit(__I40E_SUSPENDED, pf->state); set_bit(__I40E_SUSPENDED, pf->state);
set_bit(__I40E_DOWN, pf->state); set_bit(__I40E_DOWN, pf->state);
...@@ -12072,41 +12072,17 @@ static int i40e_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -12072,41 +12072,17 @@ static int i40e_suspend(struct pci_dev *pdev, pm_message_t state)
i40e_free_misc_vector(pf); i40e_free_misc_vector(pf);
retval = pci_save_state(pdev); return 0;
if (retval)
return retval;
pci_wake_from_d3(pdev, pf->wol_en);
pci_set_power_state(pdev, PCI_D3hot);
return retval;
} }
/** /**
* i40e_resume - PCI callback for waking up from D3 * i40e_resume - PM callback for waking up from D3
* @pdev: PCI device information struct * @dev: generic device information structure
**/ **/
static int i40e_resume(struct pci_dev *pdev) static int i40e_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev);
struct i40e_pf *pf = pci_get_drvdata(pdev); struct i40e_pf *pf = pci_get_drvdata(pdev);
u32 err;
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
/* pci_restore_state() clears dev->state_saves, so
* call pci_save_state() again 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);
/* no wakeup events while running */
pci_wake_from_d3(pdev, false);
/* handling the reset will rebuild the device state */ /* handling the reset will rebuild the device state */
if (test_and_clear_bit(__I40E_SUSPENDED, pf->state)) { if (test_and_clear_bit(__I40E_SUSPENDED, pf->state)) {
...@@ -12117,22 +12093,26 @@ static int i40e_resume(struct pci_dev *pdev) ...@@ -12117,22 +12093,26 @@ static int i40e_resume(struct pci_dev *pdev)
return 0; return 0;
} }
#endif #endif /* CONFIG_PM */
static const struct pci_error_handlers i40e_err_handler = { static const struct pci_error_handlers i40e_err_handler = {
.error_detected = i40e_pci_error_detected, .error_detected = i40e_pci_error_detected,
.slot_reset = i40e_pci_error_slot_reset, .slot_reset = i40e_pci_error_slot_reset,
.resume = i40e_pci_error_resume, .resume = i40e_pci_error_resume,
}; };
static SIMPLE_DEV_PM_OPS(i40e_pm_ops, i40e_suspend, i40e_resume);
static struct pci_driver i40e_driver = { static struct pci_driver i40e_driver = {
.name = i40e_driver_name, .name = i40e_driver_name,
.id_table = i40e_pci_tbl, .id_table = i40e_pci_tbl,
.probe = i40e_probe, .probe = i40e_probe,
.remove = i40e_remove, .remove = i40e_remove,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = i40e_suspend, .driver = {
.resume = i40e_resume, .pm = &i40e_pm_ops,
#endif },
#endif /* CONFIG_PM */
.shutdown = i40e_shutdown, .shutdown = i40e_shutdown,
.err_handler = &i40e_err_handler, .err_handler = &i40e_err_handler,
.sriov_configure = i40e_pci_sriov_configure, .sriov_configure = i40e_pci_sriov_configure,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册