mirror of https://gitee.com/openkylin/linux.git
net: hns3: add suspend and resume pm_ops
To implement the system suspend/resume functions, the NIC driver needs to support: 1. When the system enters the suspend mode, the driver needs to implement the suspend callback function of the NIC device. The driver needs to mute the device, stop all RX/TX activities of the device, and unmap the interrupt. 2. When the system enters the resume mode, the driver needs to implement the resume callback function of the NIC device and restore the device to the state before suspension. When the system enters the suspend and resume mode, the NIC driver actually executes the PF function reset process. When the PFs are suspending/resuming, VFs also enter the suspend/resume state because the PFs trigger the VFs to reset, therefore no operation is required when the VF pci_driver is suspending or resuming. Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
bb1890d5f9
commit
715c58e94f
|
@ -2365,6 +2365,32 @@ static void hns3_shutdown(struct pci_dev *pdev)
|
||||||
pci_set_power_state(pdev, PCI_D3hot);
|
pci_set_power_state(pdev, PCI_D3hot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __maybe_unused hns3_suspend(struct device *dev)
|
||||||
|
{
|
||||||
|
struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
if (hns3_is_phys_func(ae_dev->pdev)) {
|
||||||
|
dev_info(dev, "Begin to suspend.\n");
|
||||||
|
if (ae_dev && ae_dev->ops && ae_dev->ops->reset_prepare)
|
||||||
|
ae_dev->ops->reset_prepare(ae_dev, HNAE3_FUNC_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __maybe_unused hns3_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
if (hns3_is_phys_func(ae_dev->pdev)) {
|
||||||
|
dev_info(dev, "Begin to resume.\n");
|
||||||
|
if (ae_dev && ae_dev->ops && ae_dev->ops->reset_done)
|
||||||
|
ae_dev->ops->reset_done(ae_dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static pci_ers_result_t hns3_error_detected(struct pci_dev *pdev,
|
static pci_ers_result_t hns3_error_detected(struct pci_dev *pdev,
|
||||||
pci_channel_state_t state)
|
pci_channel_state_t state)
|
||||||
{
|
{
|
||||||
|
@ -2443,12 +2469,15 @@ static const struct pci_error_handlers hns3_err_handler = {
|
||||||
.reset_done = hns3_reset_done,
|
.reset_done = hns3_reset_done,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static SIMPLE_DEV_PM_OPS(hns3_pm_ops, hns3_suspend, hns3_resume);
|
||||||
|
|
||||||
static struct pci_driver hns3_driver = {
|
static struct pci_driver hns3_driver = {
|
||||||
.name = hns3_driver_name,
|
.name = hns3_driver_name,
|
||||||
.id_table = hns3_pci_tbl,
|
.id_table = hns3_pci_tbl,
|
||||||
.probe = hns3_probe,
|
.probe = hns3_probe,
|
||||||
.remove = hns3_remove,
|
.remove = hns3_remove,
|
||||||
.shutdown = hns3_shutdown,
|
.shutdown = hns3_shutdown,
|
||||||
|
.driver.pm = &hns3_pm_ops,
|
||||||
.sriov_configure = hns3_pci_sriov_configure,
|
.sriov_configure = hns3_pci_sriov_configure,
|
||||||
.err_handler = &hns3_err_handler,
|
.err_handler = &hns3_err_handler,
|
||||||
};
|
};
|
||||||
|
|
|
@ -11094,6 +11094,8 @@ static void hclge_reset_prepare_general(struct hnae3_ae_dev *ae_dev,
|
||||||
|
|
||||||
if (hdev->reset_type == HNAE3_FLR_RESET)
|
if (hdev->reset_type == HNAE3_FLR_RESET)
|
||||||
hdev->rst_stats.flr_rst_cnt++;
|
hdev->rst_stats.flr_rst_cnt++;
|
||||||
|
else if (hdev->reset_type == HNAE3_FUNC_RESET)
|
||||||
|
hdev->rst_stats.pf_rst_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hclge_reset_done(struct hnae3_ae_dev *ae_dev)
|
static void hclge_reset_done(struct hnae3_ae_dev *ae_dev)
|
||||||
|
|
Loading…
Reference in New Issue