Skip to contentSkip to conversation

PCI/ASPM: Save downstream port L1ss control when saving for upstream

PATCH In review Ajay Agarwal 2 participants 2 messages Nov 27, 2024 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/ASPM: Save downstream port L1ss control when saving for upstream

It is possible that the downstream port's L1ss registers were not saved after the initial configuration performed in the function aspm_calc_l12_info() during the child bus probe. If the upstream port config space is saved-restored due to some reason, the downstream port L1ss registers will be overwritten with stale configuration due to the logic present in pci_restore_aspm_l1ss_state(). So, attempt to save the downstream port L1ss registers when we are at the upstream component.

---
 drivers/pci/pcie/aspm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/pcie/aspm.c +13 -0
index cee2365e54b8..769a305fad63 100644
@@ -99,6 +99,19 @@ void pci_save_aspm_l1ss_state(struct pci_dev *pdev)
 	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++);
+
+	/*
+	 * It is possible that the downstream port's L1ss registers were not
+	 * saved after the initial configuration performed in the function
+	 * aspm_calc_l12_info() during the child bus probe. If the upstream port
+	 * config space is saved-restored due to some reason, the downstream
+	 * port L1ss registers will be overwritten with stale configuration due
+	 * to the logic present in pci_restore_aspm_l1ss_state(). So, attempt to
+	 * save the downstream port L1ss registers when we are at the upstream
+	 * component.
+	 */
+	if (!pcie_downstream_port(pdev))
+		pci_save_aspm_l1ss_state(pdev->bus->self);
 }
 
 void pci_restore_aspm_l1ss_state(struct pci_dev *pdev)
Signature · 1 line
2.47.0.338.g60cca15819-goog
#1 lore raw

Adding Jian-Hong.

There's already another patch under discussion to the same problem:

https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/

Signature · 1 line
 i.
Quoted 39 lines · Ajay Agarwal

It is possible that the downstream port's L1ss registers were not saved after the initial configuration performed in the function aspm_calc_l12_info() during the child bus probe. If the upstream port config space is saved-restored due to some reason, the downstream port L1ss registers will be overwritten with stale configuration due to the logic present in pci_restore_aspm_l1ss_state(). So, attempt to save the downstream port L1ss registers when we are at the upstream component.

---
 drivers/pci/pcie/aspm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/pci/pcie/aspm.c +13 -0
index cee2365e54b8..769a305fad63 100644
@@ -99,6 +99,19 @@ void pci_save_aspm_l1ss_state(struct pci_dev *pdev)
 	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++);
+
+	/*
+	 * It is possible that the downstream port's L1ss registers were not
+	 * saved after the initial configuration performed in the function
+	 * aspm_calc_l12_info() during the child bus probe. If the upstream port
+	 * config space is saved-restored due to some reason, the downstream
+	 * port L1ss registers will be overwritten with stale configuration due
+	 * to the logic present in pci_restore_aspm_l1ss_state(). So, attempt to
+	 * save the downstream port L1ss registers when we are at the upstream
+	 * component.
+	 */
+	if (!pcie_downstream_port(pdev))
+		pci_save_aspm_l1ss_state(pdev->bus->self);
 }
 
 void pci_restore_aspm_l1ss_state(struct pci_dev *pdev)