Skip to content

Commit 4257f7e

Browse files
Vidya Sagarbjorn-helgaas
authored andcommitted
PCI/ASPM: Save/restore L1SS Capability for suspend/resume
Previously ASPM L1 Substates control registers (CTL1 and CTL2) weren't saved and restored during suspend/resume leading to L1 Substates configuration being lost post-resume. Save the L1 Substates control registers so that the configuration is retained post-resume. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vidya Sagar <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent f8394f2 commit 4257f7e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

drivers/pci/pci.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ int pci_save_state(struct pci_dev *dev)
15641564
return i;
15651565

15661566
pci_save_ltr_state(dev);
1567+
pci_save_aspm_l1ss_state(dev);
15671568
pci_save_dpc_state(dev);
15681569
pci_save_aer_state(dev);
15691570
return pci_save_vc_state(dev);
@@ -1669,6 +1670,7 @@ void pci_restore_state(struct pci_dev *dev)
16691670
* LTR itself (in the PCIe capability).
16701671
*/
16711672
pci_restore_ltr_state(dev);
1673+
pci_restore_aspm_l1ss_state(dev);
16721674

16731675
pci_restore_pcie_state(dev);
16741676
pci_restore_pasid_state(dev);
@@ -3332,6 +3334,11 @@ void pci_allocate_cap_save_buffers(struct pci_dev *dev)
33323334
if (error)
33333335
pci_err(dev, "unable to allocate suspend buffer for LTR\n");
33343336

3337+
error = pci_add_ext_cap_save_buffer(dev, PCI_EXT_CAP_ID_L1SS,
3338+
2 * sizeof(u32));
3339+
if (error)
3340+
pci_err(dev, "unable to allocate suspend buffer for ASPM-L1SS\n");
3341+
33353342
pci_allocate_vc_save_buffers(dev);
33363343
}
33373344

drivers/pci/pci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,15 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev);
564564
void pcie_aspm_exit_link_state(struct pci_dev *pdev);
565565
void pcie_aspm_pm_state_change(struct pci_dev *pdev);
566566
void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
567+
void pci_save_aspm_l1ss_state(struct pci_dev *dev);
568+
void pci_restore_aspm_l1ss_state(struct pci_dev *dev);
567569
#else
568570
static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { }
569571
static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { }
570572
static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { }
571573
static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { }
574+
static inline void pci_save_aspm_l1ss_state(struct pci_dev *dev) { }
575+
static inline void pci_restore_aspm_l1ss_state(struct pci_dev *dev) { }
572576
#endif
573577

574578
#ifdef CONFIG_PCIE_ECRC

drivers/pci/pcie/aspm.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,50 @@ static void pcie_config_aspm_l1ss(struct pcie_link_state *link, u32 state)
734734
PCI_L1SS_CTL1_L1SS_MASK, val);
735735
}
736736

737+
void pci_save_aspm_l1ss_state(struct pci_dev *dev)
738+
{
739+
int aspm_l1ss;
740+
struct pci_cap_saved_state *save_state;
741+
u32 *cap;
742+
743+
if (!pci_is_pcie(dev))
744+
return;
745+
746+
aspm_l1ss = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_L1SS);
747+
if (!aspm_l1ss)
748+
return;
749+
750+
save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_L1SS);
751+
if (!save_state)
752+
return;
753+
754+
cap = (u32 *)&save_state->cap.data[0];
755+
pci_read_config_dword(dev, aspm_l1ss + PCI_L1SS_CTL1, cap++);
756+
pci_read_config_dword(dev, aspm_l1ss + PCI_L1SS_CTL2, cap++);
757+
}
758+
759+
void pci_restore_aspm_l1ss_state(struct pci_dev *dev)
760+
{
761+
int aspm_l1ss;
762+
struct pci_cap_saved_state *save_state;
763+
u32 *cap;
764+
765+
if (!pci_is_pcie(dev))
766+
return;
767+
768+
aspm_l1ss = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_L1SS);
769+
if (!aspm_l1ss)
770+
return;
771+
772+
save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_L1SS);
773+
if (!save_state)
774+
return;
775+
776+
cap = (u32 *)&save_state->cap.data[0];
777+
pci_write_config_dword(dev, aspm_l1ss + PCI_L1SS_CTL1, *cap++);
778+
pci_write_config_dword(dev, aspm_l1ss + PCI_L1SS_CTL2, *cap++);
779+
}
780+
737781
static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)
738782
{
739783
pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL,

0 commit comments

Comments
 (0)