Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI/PM: Replace pci_set_power_state() in pci_pm_thaw_noirq()

Calling pci_set_power_state() to put the given device into D0 in
pci_pm_thaw_noirq() may cause it to restore the device's BARs, which is
redundant before calling pci_restore_state(), so replace it with a direct
pci_power_up() call followed by pci_update_current_state() if it returns a
nonzero value, in analogy with pci_pm_default_resume_early().

Avoid code duplication by introducing a wrapper function to contain the
repeating pattern and calling it in both places.

Link: https://lore.kernel.org/r/3639079.MHq7AAxBmi@kreacher
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Rafael J. Wysocki and committed by
Bjorn Helgaas
0f40ac35 3cc2a2b2

+7 -2
+7 -2
drivers/pci/pci-driver.c
··· 556 556 pci_enable_wake(pci_dev, PCI_D0, false); 557 557 } 558 558 559 - static void pci_pm_default_resume_early(struct pci_dev *pci_dev) 559 + static void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev) 560 560 { 561 561 pci_power_up(pci_dev); 562 562 pci_update_current_state(pci_dev, PCI_D0); 563 + } 564 + 565 + static void pci_pm_default_resume_early(struct pci_dev *pci_dev) 566 + { 567 + pci_pm_power_up_and_verify_state(pci_dev); 563 568 pci_restore_state(pci_dev); 564 569 pci_pme_restore(pci_dev); 565 570 } ··· 1089 1084 * in case the driver's "freeze" callbacks put it into a low-power 1090 1085 * state. 1091 1086 */ 1092 - pci_set_power_state(pci_dev, PCI_D0); 1087 + pci_pm_power_up_and_verify_state(pci_dev); 1093 1088 pci_restore_state(pci_dev); 1094 1089 1095 1090 if (pci_has_legacy_pm_support(pci_dev))