Power management fix for 5.2-rc6

Prevent PCI bridges in general (and PCIe ports in particular)
 from being put into low-power states during system-wide suspend
 transitions if there are any devices in D0 below them and refine
 the handling of PCI devices in D0 during suspend-to-idle cycles.
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl0KAdUSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxejIQAIoR8FCLoKcxD4wJ6sDp5CtGVaw65pc9
 i0WaTGlQWiBcr3bkxCRERl+NNjolVrUu7aAVrrUNe5SUQduFXZuGsreF0q3SPMUh
 OZwSb+EpN6gSM3GTjrsF2P9nyvlJ80r5t9HI6vG1hAEFBU8T15gGVS6bnwm4ci7I
 +KuIb4zwkOQ+LCwjqwkGjn6s4ZHmx2KxGnI58GBTAd4KsvV3G7QIaa7Lfa/js88C
 pDhz8BiQqs/HTU0gHY52hsEvhKPeefMKH3QDpBFhoR0p1ZOkMoqK1jA+Kc5r/JF+
 36Fj/rPlD26pmqYMZA7bZi4Ij0M+vR8SWCdefcvzPqUZpzkHh9y7/foi01DVNjsf
 QGhlJODgGUl78mjEQwdPXz/ntzj4DEyo/3Re9Xf/SZ09sMeoyhbNi5Qolri05LqV
 8hAshCNcFLbOzF1emcAa+Yq76tggWnW78q3oKAsfUqg4Olyvcbxy6J3GDRpzTwPz
 D/4lEM7jtSqbcgprqWUcANB/zE3Jw93et0QtQNUfdOJ6a+LsS2XAhqenkQn2JQpk
 7ZjaVfNNm3YDQlKt6nPaWCCxVv/g6KHSYXDeWB5VJpCOrSVhdXAZgPU+UCGrk9TU
 3TqdqFoKi0LVZJVuWT+oyNfwzfolGZ7gd7TJVndFxVM8kbcLTzrj1ZQgpwP1l/tI
 Xs12WM7cw1dy
 =n3GG
 -----END PGP SIGNATURE-----

Merge tag 'pm-5.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fix from Rafael Wysocki:
 "Prevent PCI bridges in general (and PCIe ports in particular) from
  being put into low-power states during system-wide suspend transitions
  if there are any devices in D0 below them and refine the handling of
  PCI devices in D0 during suspend-to-idle cycles"

* tag 'pm-5.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PCI: PM: Skip devices in D0 for suspend-to-idle
This commit is contained in:
Linus Torvalds 2019-06-19 11:44:04 -07:00
commit abf02e2964

View File

@ -524,7 +524,6 @@ static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
pci_power_up(pci_dev);
pci_restore_state(pci_dev);
pci_pme_restore(pci_dev);
pci_fixup_device(pci_fixup_resume_early, pci_dev);
}
/*
@ -831,18 +830,16 @@ static int pci_pm_suspend_noirq(struct device *dev)
if (pci_dev->skip_bus_pm) {
/*
* The function is running for the second time in a row without
* Either the device is a bridge with a child in D0 below it, or
* the function is running for the second time in a row without
* going through full resume, which is possible only during
* suspend-to-idle in a spurious wakeup case. Moreover, the
* device was originally left in D0, so its power state should
* not be changed here and the device register values saved
* originally should be restored on resume again.
* suspend-to-idle in a spurious wakeup case. The device should
* be in D0 at this point, but if it is a bridge, it may be
* necessary to save its state.
*/
pci_dev->state_saved = true;
} else if (pci_dev->state_saved) {
if (pci_dev->current_state == PCI_D0)
pci_dev->skip_bus_pm = true;
} else {
if (!pci_dev->state_saved)
pci_save_state(pci_dev);
} else if (!pci_dev->state_saved) {
pci_save_state(pci_dev);
if (pci_power_manageable(pci_dev))
pci_prepare_to_sleep(pci_dev);
@ -851,6 +848,22 @@ static int pci_pm_suspend_noirq(struct device *dev)
dev_dbg(dev, "PCI PM: Suspend power state: %s\n",
pci_power_name(pci_dev->current_state));
if (pci_dev->current_state == PCI_D0) {
pci_dev->skip_bus_pm = true;
/*
* Per PCI PM r1.2, table 6-1, a bridge must be in D0 if any
* downstream device is in D0, so avoid changing the power state
* of the parent bridge by setting the skip_bus_pm flag for it.
*/
if (pci_dev->bus->self)
pci_dev->bus->self->skip_bus_pm = true;
}
if (pci_dev->skip_bus_pm && !pm_suspend_via_firmware()) {
dev_dbg(dev, "PCI PM: Skipped\n");
goto Fixup;
}
pci_pm_set_unknown_state(pci_dev);
/*
@ -898,7 +911,16 @@ static int pci_pm_resume_noirq(struct device *dev)
if (dev_pm_smart_suspend_and_suspended(dev))
pm_runtime_set_active(dev);
pci_pm_default_resume_early(pci_dev);
/*
* In the suspend-to-idle case, devices left in D0 during suspend will
* stay in D0, so it is not necessary to restore or update their
* configuration here and attempting to put them into D0 again may
* confuse some firmware, so avoid doing that.
*/
if (!pci_dev->skip_bus_pm || pm_suspend_via_firmware())
pci_pm_default_resume_early(pci_dev);
pci_fixup_device(pci_fixup_resume_early, pci_dev);
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev);
@ -1194,6 +1216,7 @@ static int pci_pm_restore_noirq(struct device *dev)
}
pci_pm_default_resume_early(pci_dev);
pci_fixup_device(pci_fixup_resume_early, pci_dev);
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_resume_early(dev);