Skip to content

Commit ec4e4a6

Browse files
VARoDeKbjorn-helgaas
authored andcommitted
amd64-agp: convert to generic power management
Convert amd64-agp from legacy PCI power management to the generic power management framework. Previously, amd64-agp used legacy PCI power management, and agp_amd64_suspend() and agp_amd64_resume() were responsible for both device-specific things and generic PCI things: agp_amd64_suspend pci_save_state(pdev) <-- generic PCI pci_set_power_state(pdev, pci_choose_state(pdev, state)) <-- generic PCI agp_amd64_resume pci_set_power_state(pdev, PCI_D0) <-- generic PCI pci_restore_state(pdev) <-- generic PCI nforce3_agp_init() <-- device-specific amd_8151_configure() <-- device-specific With generic power management, 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_amd64_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_amd64_resume # dev->driver->pm->resume nforce3_agp_init() <-- device-specific amd_8151_configure() <-- device-specific [bhelgaas: commit log] Link: https://lore.kernel.org/r/20211208193305.147072-2-helgaas@kernel.org Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Dave Airlie <airlied@redhat.com>
1 parent fa55b7d commit ec4e4a6

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

drivers/char/agp/amd64-agp.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -588,29 +588,18 @@ static void agp_amd64_remove(struct pci_dev *pdev)
588588
agp_bridges_found--;
589589
}
590590

591-
#ifdef CONFIG_PM
591+
#define agp_amd64_suspend NULL
592592

593-
static int agp_amd64_suspend(struct pci_dev *pdev, pm_message_t state)
593+
static int __maybe_unused agp_amd64_resume(struct device *dev)
594594
{
595-
pci_save_state(pdev);
596-
pci_set_power_state(pdev, pci_choose_state(pdev, state));
597-
598-
return 0;
599-
}
600-
601-
static int agp_amd64_resume(struct pci_dev *pdev)
602-
{
603-
pci_set_power_state(pdev, PCI_D0);
604-
pci_restore_state(pdev);
595+
struct pci_dev *pdev = to_pci_dev(dev);
605596

606597
if (pdev->vendor == PCI_VENDOR_ID_NVIDIA)
607598
nforce3_agp_init(pdev);
608599

609600
return amd_8151_configure();
610601
}
611602

612-
#endif /* CONFIG_PM */
613-
614603
static const struct pci_device_id agp_amd64_pci_table[] = {
615604
{
616605
.class = (PCI_CLASS_BRIDGE_HOST << 8),
@@ -738,15 +727,14 @@ static const struct pci_device_id agp_amd64_pci_promisc_table[] = {
738727
{ }
739728
};
740729

730+
static SIMPLE_DEV_PM_OPS(agp_amd64_pm_ops, agp_amd64_suspend, agp_amd64_resume);
731+
741732
static struct pci_driver agp_amd64_pci_driver = {
742733
.name = "agpgart-amd64",
743734
.id_table = agp_amd64_pci_table,
744735
.probe = agp_amd64_probe,
745736
.remove = agp_amd64_remove,
746-
#ifdef CONFIG_PM
747-
.suspend = agp_amd64_suspend,
748-
.resume = agp_amd64_resume,
749-
#endif
737+
.driver.pm = &agp_amd64_pm_ops,
750738
};
751739

752740

0 commit comments

Comments
 (0)