Skip to content

Commit 1e11b54

Browse files
debox1bjorn-helgaas
authored andcommitted
PCI/ASPM: Move pci_save_ltr_state() to aspm.c
Even when CONFIG_PCIEASPM is not set, we save and restore the LTR Capability so that if ASPM L1.2 and LTR were configured by the platform, ASPM L1.2 will still work after suspend/resume, when that platform configuration may be lost. See dbbfadf ("PCI/ASPM: Save LTR Capability for suspend/resume"). Since ASPM L1.2 depends on the LTR Capability, move the save/restore code to the part of aspm.c that is always compiled regardless of CONFIG_PCIEASPM. No functional change intended. Suggested-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected] [bhelgaas: commit log, reorder to make this a pure move] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: David E. Box <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent f3994bb commit 1e11b54

File tree

3 files changed

+45
-40
lines changed

3 files changed

+45
-40
lines changed

drivers/pci/pci.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,46 +1689,6 @@ static void pci_restore_pcix_state(struct pci_dev *dev)
16891689
pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]);
16901690
}
16911691

1692-
static void pci_save_ltr_state(struct pci_dev *dev)
1693-
{
1694-
int ltr;
1695-
struct pci_cap_saved_state *save_state;
1696-
u32 *cap;
1697-
1698-
if (!pci_is_pcie(dev))
1699-
return;
1700-
1701-
ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR);
1702-
if (!ltr)
1703-
return;
1704-
1705-
save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR);
1706-
if (!save_state) {
1707-
pci_err(dev, "no suspend buffer for LTR; ASPM issues possible after resume\n");
1708-
return;
1709-
}
1710-
1711-
/* Some broken devices only support dword access to LTR */
1712-
cap = &save_state->cap.data[0];
1713-
pci_read_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, cap);
1714-
}
1715-
1716-
static void pci_restore_ltr_state(struct pci_dev *dev)
1717-
{
1718-
struct pci_cap_saved_state *save_state;
1719-
int ltr;
1720-
u32 *cap;
1721-
1722-
save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR);
1723-
ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR);
1724-
if (!save_state || !ltr)
1725-
return;
1726-
1727-
/* Some broken devices only support dword access to LTR */
1728-
cap = &save_state->cap.data[0];
1729-
pci_write_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, *cap);
1730-
}
1731-
17321692
/**
17331693
* pci_save_state - save the PCI configuration space of a device before
17341694
* suspending

drivers/pci/pci.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
567567

568568
bool pcie_wait_for_link(struct pci_dev *pdev, bool active);
569569
int pcie_retrain_link(struct pci_dev *pdev, bool use_lt);
570+
571+
/* ASPM-related functionality we need even without CONFIG_PCIEASPM */
572+
void pci_save_ltr_state(struct pci_dev *dev);
573+
void pci_restore_ltr_state(struct pci_dev *dev);
574+
570575
#ifdef CONFIG_PCIEASPM
571576
void pcie_aspm_init_link_state(struct pci_dev *pdev);
572577
void pcie_aspm_exit_link_state(struct pci_dev *pdev);

drivers/pci/pcie/aspm.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,46 @@
2424

2525
#include "../pci.h"
2626

27+
void pci_save_ltr_state(struct pci_dev *dev)
28+
{
29+
int ltr;
30+
struct pci_cap_saved_state *save_state;
31+
u32 *cap;
32+
33+
if (!pci_is_pcie(dev))
34+
return;
35+
36+
ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR);
37+
if (!ltr)
38+
return;
39+
40+
save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR);
41+
if (!save_state) {
42+
pci_err(dev, "no suspend buffer for LTR; ASPM issues possible after resume\n");
43+
return;
44+
}
45+
46+
/* Some broken devices only support dword access to LTR */
47+
cap = &save_state->cap.data[0];
48+
pci_read_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, cap);
49+
}
50+
51+
void pci_restore_ltr_state(struct pci_dev *dev)
52+
{
53+
struct pci_cap_saved_state *save_state;
54+
int ltr;
55+
u32 *cap;
56+
57+
save_state = pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_LTR);
58+
ltr = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR);
59+
if (!save_state || !ltr)
60+
return;
61+
62+
/* Some broken devices only support dword access to LTR */
63+
cap = &save_state->cap.data[0];
64+
pci_write_config_dword(dev, ltr + PCI_LTR_MAX_SNOOP_LAT, *cap);
65+
}
66+
2767
#ifdef CONFIG_PCIEASPM
2868

2969
#ifdef MODULE_PARAM_PREFIX

0 commit comments

Comments
 (0)