UPSTREAM: PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()
After17423360a2("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume"), pci_save_aspm_l1ss_state(dev) saves the L1SS state for "dev", and pci_restore_aspm_l1ss_state(dev) restores the state for both "dev" and its parent. The problem is that unless pci_save_state() has been used in some other path and has already saved the parent L1SS state, we will restore junk to the parent, which means the L1 Substates likely won't work correctly. Save the L1SS config for both the device and its parent in pci_save_aspm_l1ss_state(). When restoring, we need both because L1SS must be enabled at the parent (the Downstream Port) before being enabled at the child (the Upstream Port). Bug: 367893204 Test: build with and without CONFIG_PCIEASPM Test: lspci -vvv / check L1 substate capabilities Link: https://lore.kernel.org/r/20241115072200.37509-3-jhp@endlessos.org Fixes:17423360a2("PCI/ASPM: Save L1 PM Substates Capability for suspend/resume") Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218394 Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Change-Id: I2639abacd417088fb315e35b9af053d0733117b9 Signed-off-by: Jian-Hong Pan <jhp@endlessos.org> [bhelgaas: parallel save/restore structure, simplify commit log, patch at https: //lore.kernel.org/r/20241212230340.GA3267194@bhelgaas] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Jian-Hong Pan <jhp@endlessos.org> # Asus B1400CEAE (cherry picked from commit 1db806ec06b7c6e08e8af57088da067963ddf117) Signed-off-by: Brian Norris <briannorris@google.com> (cherry picked from commit 866b883aada6a80d4698530b540ffe8498790836)
This commit is contained in:
committed by
Treehugger Robot
parent
572fd93b80
commit
f97c8e1021
+29
-6
@@ -81,24 +81,47 @@ void pci_configure_aspm_l1ss(struct pci_dev *pdev)
|
||||
|
||||
void pci_save_aspm_l1ss_state(struct pci_dev *pdev)
|
||||
{
|
||||
struct pci_dev *parent = pdev->bus->self;
|
||||
struct pci_cap_saved_state *save_state;
|
||||
u16 l1ss = pdev->l1ss;
|
||||
u32 *cap;
|
||||
|
||||
/*
|
||||
* If this is a Downstream Port, we never restore the L1SS state
|
||||
* directly; we only restore it when we restore the state of the
|
||||
* Upstream Port below it.
|
||||
*/
|
||||
if (pcie_downstream_port(pdev) || !parent)
|
||||
return;
|
||||
|
||||
if (!pdev->l1ss || !parent->l1ss)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Save L1 substate configuration. The ASPM L0s/L1 configuration
|
||||
* in PCI_EXP_LNKCTL_ASPMC is saved by pci_save_pcie_state().
|
||||
*/
|
||||
if (!l1ss)
|
||||
return;
|
||||
|
||||
save_state = pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_L1SS);
|
||||
if (!save_state)
|
||||
return;
|
||||
|
||||
cap = &save_state->cap.data[0];
|
||||
pci_read_config_dword(pdev, l1ss + PCI_L1SS_CTL2, cap++);
|
||||
pci_read_config_dword(pdev, l1ss + PCI_L1SS_CTL1, cap++);
|
||||
pci_read_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL2, cap++);
|
||||
pci_read_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL1, cap++);
|
||||
|
||||
if (parent->state_saved)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Save parent's L1 substate configuration so we have it for
|
||||
* pci_restore_aspm_l1ss_state(pdev) to restore.
|
||||
*/
|
||||
save_state = pci_find_saved_ext_cap(parent, PCI_EXT_CAP_ID_L1SS);
|
||||
if (!save_state)
|
||||
return;
|
||||
|
||||
cap = &save_state->cap.data[0];
|
||||
pci_read_config_dword(parent, parent->l1ss + PCI_L1SS_CTL2, cap++);
|
||||
pci_read_config_dword(parent, parent->l1ss + PCI_L1SS_CTL1, cap++);
|
||||
}
|
||||
|
||||
void pci_restore_aspm_l1ss_state(struct pci_dev *pdev)
|
||||
|
||||
Reference in New Issue
Block a user