Commit e4d18990 authored by David E. Box's avatar David E. Box Committed by Todd Kjos
Browse files

BACKPORT: PCI/ASPM: Save L1 PM Substates Capability for suspend/resume

4ff116d0 ("PCI/ASPM: Save L1 PM Substates Capability for
suspend/resume") restored the L1 PM Substates Capability after resume,
which reduced power consumption by making the ASPM L1.x states work after
resume.

a7152be7 ("Revert "PCI/ASPM: Save L1 PM Substates Capability for
suspend/resume"") reverted 4ff116d0 because resume failed on some
systems, so power consumption after resume increased again.

a7152be7 mentioned that we restore L1 PM substate configuration even
though ASPM L1 may already be enabled. This is due the fact that the
pci_restore_aspm_l1ss_state() was called before pci_restore_pcie_state().

Save and restore the L1 PM Substates Capability, following PCIe r6.1, sec
5.5.4 more closely by:

  1) Do not restore ASPM configuration in pci_restore_pcie_state() but
     do that after PCIe capability is restored in pci_restore_aspm_state()
     following PCIe r6.1, sec 5.5.4.

  2) If BIOS reenables L1SS, particularly L1.2, we need to clear the
     enables in the right order, downstream before upstream. Defer
     restoring the L1SS config until we are at the downstream component.
     Then update the config for both ends of the link in the prescribed
     order.

  3) Program ASPM L1 PM substate configuration before L1 enables.

  4) Program ASPM L1 PM substate enables last, after rest of the fields
     in the capability are programmed.

[bhelgaas: commit log, squash L1SS-related patches, do both LNKCTL restores
in pci_restore_pcie_state()]

Bug: 367893204
Test: build with and without CONFIG_PCIEASPM
Test: lspci -vvv / check L1 substate capabilities
Link: https://lore.kernel.org/r/20240128233212.1139663-3-david.e.box@linux.intel.com
Link: https://lore.kernel.org/r/20240128233212.1139663-4-david.e.box@linux.intel.com
Link: https://lore.kernel.org/r/20240223205851.114931-5-helgaas@kernel.org
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217321
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216782
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216877


Co-developed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Co-developed-by: default avatarDavid E. Box <david.e.box@linux.intel.com>
Reported-by: default avatarKoba Ko <koba.ko@canonical.com>
Change-Id: I430bc95663ebeb77d132918abbae4c6164922adf
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarDavid E. Box <david.e.box@linux.intel.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Tested-by: Tasev Nikola <tasev.stefanoska@skynet.be> # Asus UX305FA
Cc: Mark Enriquez <enriquezmark36@gmail.com>
Cc: Thomas Witt <kernel@witt.link>
Cc: Werner Sembach <wse@tuxedocomputers.com>
Cc: Vidya Sagar <vidyas@nvidia.com>
(cherry picked from commit 17423360)
[Brian:
 * adjust for lack of commit ac160871 ("PCI: Move
   pci_clear_and_set_dword() helper to PCI header") -- I don't want to
   export a new symbol, so I just adapt to using the old local
   definition (pci_clear_and_set_dword()) instead of the later-exported
   pci_clear_and_set_config_dword()
 * keep pci_dev::l1ss field in the same position to avoid ABI change
]
Signed-off-by: default avatarBrian Norris <briannorris@google.com>
parent e1a0a5ae
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment