提交 11a8d877 编写于 作者: B Bjorn Helgaas

agp/nvidia: Convert to generic power management

Convert agpgart-nvidia from legacy PCI power management to the generic
power management framework.

Previously agpgart-nvidia used legacy PCI power management, and
agp_nvidia_suspend() and agp_nvidia_resume() were responsible for both
device-specific things and generic PCI things:

  agp_nvidia_suspend
    pci_save_state                         <-- generic PCI
    pci_set_power_state(PCI_D3hot)         <-- generic PCI

  agp_nvidia_resume
    pci_set_power_state(PCI_D0)            <-- generic PCI
    pci_restore_state                      <-- generic PCI
    nvidia_configure                       <-- device-specific

Convert to generic power management where the PCI bus PM methods do the
generic PCI things, and the driver needs only the device-specific part,
i.e.,

  suspend_devices_and_enter
    dpm_suspend_start(PMSG_SUSPEND)
      pci_pm_suspend                       # PCI bus .suspend() method
        agp_nvidia_suspend                 <-- not needed at all; removed
    suspend_enter
      dpm_suspend_noirq(PMSG_SUSPEND)
        pci_pm_suspend_noirq               # PCI bus .suspend_noirq() method
          pci_save_state                   <-- generic PCI
          pci_prepare_to_sleep             <-- generic PCI
            pci_set_power_state
    ...
    dpm_resume_end(PMSG_RESUME)
      pci_pm_resume                        # PCI bus .resume() method
        pci_restore_standard_config
          pci_set_power_state(PCI_D0)      <-- generic PCI
          pci_restore_state                <-- generic PCI
        agp_nvidia_resume                  # driver->pm->resume
          nvidia_configure                 <-- device-specific

Based on 0aeddbd0 ("via-agp: convert to generic power management") by
Vaibhav Gupta <vaibhavgupta40@gmail.com>.

Link: https://lore.kernel.org/r/20221025203852.681822-6-helgaas@kernel.orgSigned-off-by: NBjorn Helgaas <bhelgaas@google.com>
Acked-by: NDave Airlie <airlied@redhat.com>
上级 6a1274ea
...@@ -404,28 +404,13 @@ static void agp_nvidia_remove(struct pci_dev *pdev) ...@@ -404,28 +404,13 @@ static void agp_nvidia_remove(struct pci_dev *pdev)
agp_put_bridge(bridge); agp_put_bridge(bridge);
} }
#ifdef CONFIG_PM static int agp_nvidia_resume(struct device *dev)
static int agp_nvidia_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
pci_save_state(pdev);
pci_set_power_state(pdev, PCI_D3hot);
return 0;
}
static int agp_nvidia_resume(struct pci_dev *pdev)
{
/* set power state 0 and restore PCI space */
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
/* reconfigure AGP hardware again */ /* reconfigure AGP hardware again */
nvidia_configure(); nvidia_configure();
return 0; return 0;
} }
#endif
static const struct pci_device_id agp_nvidia_pci_table[] = { static const struct pci_device_id agp_nvidia_pci_table[] = {
{ {
...@@ -449,15 +434,14 @@ static const struct pci_device_id agp_nvidia_pci_table[] = { ...@@ -449,15 +434,14 @@ static const struct pci_device_id agp_nvidia_pci_table[] = {
MODULE_DEVICE_TABLE(pci, agp_nvidia_pci_table); MODULE_DEVICE_TABLE(pci, agp_nvidia_pci_table);
static DEFINE_SIMPLE_DEV_PM_OPS(agp_nvidia_pm_ops, NULL, agp_nvidia_resume);
static struct pci_driver agp_nvidia_pci_driver = { static struct pci_driver agp_nvidia_pci_driver = {
.name = "agpgart-nvidia", .name = "agpgart-nvidia",
.id_table = agp_nvidia_pci_table, .id_table = agp_nvidia_pci_table,
.probe = agp_nvidia_probe, .probe = agp_nvidia_probe,
.remove = agp_nvidia_remove, .remove = agp_nvidia_remove,
#ifdef CONFIG_PM .driver.pm = &agp_nvidia_pm_ops,
.suspend = agp_nvidia_suspend,
.resume = agp_nvidia_resume,
#endif
}; };
static int __init agp_nvidia_init(void) static int __init agp_nvidia_init(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册