Skip to content

Commit 7cc5e1e

Browse files
committed
Merge branch 'pci/aspm'
- Enable all ClockPM and ASPM states for devicetree platforms, since there's typically no firmware that enables ASPM (Manivannan Sadhasivam) - Remove the qcom code that enabled ASPM (Manivannan Sadhasivam) * pci/aspm: PCI: qcom: Remove custom ASPM enablement code PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms
2 parents a0d0cad + a729c16 commit 7cc5e1e

2 files changed

Lines changed: 43 additions & 34 deletions

File tree

drivers/pci/controller/dwc/pcie-qcom.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ struct qcom_pcie_ops {
247247
int (*get_resources)(struct qcom_pcie *pcie);
248248
int (*init)(struct qcom_pcie *pcie);
249249
int (*post_init)(struct qcom_pcie *pcie);
250-
void (*host_post_init)(struct qcom_pcie *pcie);
251250
void (*deinit)(struct qcom_pcie *pcie);
252251
void (*ltssm_enable)(struct qcom_pcie *pcie);
253252
int (*config_sid)(struct qcom_pcie *pcie);
@@ -1040,25 +1039,6 @@ static int qcom_pcie_post_init_2_7_0(struct qcom_pcie *pcie)
10401039
return 0;
10411040
}
10421041

1043-
static int qcom_pcie_enable_aspm(struct pci_dev *pdev, void *userdata)
1044-
{
1045-
/*
1046-
* Downstream devices need to be in D0 state before enabling PCI PM
1047-
* substates.
1048-
*/
1049-
pci_set_power_state_locked(pdev, PCI_D0);
1050-
pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL);
1051-
1052-
return 0;
1053-
}
1054-
1055-
static void qcom_pcie_host_post_init_2_7_0(struct qcom_pcie *pcie)
1056-
{
1057-
struct dw_pcie_rp *pp = &pcie->pci->pp;
1058-
1059-
pci_walk_bus(pp->bridge->bus, qcom_pcie_enable_aspm, NULL);
1060-
}
1061-
10621042
static void qcom_pcie_deinit_2_7_0(struct qcom_pcie *pcie)
10631043
{
10641044
struct qcom_pcie_resources_2_7_0 *res = &pcie->res.v2_7_0;
@@ -1358,19 +1338,9 @@ static void qcom_pcie_host_deinit(struct dw_pcie_rp *pp)
13581338
pcie->cfg->ops->deinit(pcie);
13591339
}
13601340

1361-
static void qcom_pcie_host_post_init(struct dw_pcie_rp *pp)
1362-
{
1363-
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
1364-
struct qcom_pcie *pcie = to_qcom_pcie(pci);
1365-
1366-
if (pcie->cfg->ops->host_post_init)
1367-
pcie->cfg->ops->host_post_init(pcie);
1368-
}
1369-
13701341
static const struct dw_pcie_host_ops qcom_pcie_dw_ops = {
13711342
.init = qcom_pcie_host_init,
13721343
.deinit = qcom_pcie_host_deinit,
1373-
.post_init = qcom_pcie_host_post_init,
13741344
};
13751345

13761346
/* Qcom IP rev.: 2.1.0 Synopsys IP rev.: 4.01a */
@@ -1432,7 +1402,6 @@ static const struct qcom_pcie_ops ops_1_9_0 = {
14321402
.get_resources = qcom_pcie_get_resources_2_7_0,
14331403
.init = qcom_pcie_init_2_7_0,
14341404
.post_init = qcom_pcie_post_init_2_7_0,
1435-
.host_post_init = qcom_pcie_host_post_init_2_7_0,
14361405
.deinit = qcom_pcie_deinit_2_7_0,
14371406
.ltssm_enable = qcom_pcie_2_3_2_ltssm_enable,
14381407
.config_sid = qcom_pcie_config_sid_1_9_0,
@@ -1443,7 +1412,6 @@ static const struct qcom_pcie_ops ops_1_21_0 = {
14431412
.get_resources = qcom_pcie_get_resources_2_7_0,
14441413
.init = qcom_pcie_init_2_7_0,
14451414
.post_init = qcom_pcie_post_init_2_7_0,
1446-
.host_post_init = qcom_pcie_host_post_init_2_7_0,
14471415
.deinit = qcom_pcie_deinit_2_7_0,
14481416
.ltssm_enable = qcom_pcie_2_3_2_ltssm_enable,
14491417
};

drivers/pci/pcie/aspm.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/math.h>
1616
#include <linux/module.h>
1717
#include <linux/moduleparam.h>
18+
#include <linux/of.h>
1819
#include <linux/pci.h>
1920
#include <linux/pci_regs.h>
2021
#include <linux/errno.h>
@@ -235,13 +236,15 @@ struct pcie_link_state {
235236
u32 aspm_support:7; /* Supported ASPM state */
236237
u32 aspm_enabled:7; /* Enabled ASPM state */
237238
u32 aspm_capable:7; /* Capable ASPM state with latency */
238-
u32 aspm_default:7; /* Default ASPM state by BIOS */
239+
u32 aspm_default:7; /* Default ASPM state by BIOS or
240+
override */
239241
u32 aspm_disable:7; /* Disabled ASPM state */
240242

241243
/* Clock PM state */
242244
u32 clkpm_capable:1; /* Clock PM capable? */
243245
u32 clkpm_enabled:1; /* Current Clock PM state */
244-
u32 clkpm_default:1; /* Default Clock PM state by BIOS */
246+
u32 clkpm_default:1; /* Default Clock PM state by BIOS or
247+
override */
245248
u32 clkpm_disable:1; /* Clock PM disabled */
246249
};
247250

@@ -373,6 +376,18 @@ static void pcie_set_clkpm(struct pcie_link_state *link, int enable)
373376
pcie_set_clkpm_nocheck(link, enable);
374377
}
375378

379+
static void pcie_clkpm_override_default_link_state(struct pcie_link_state *link,
380+
int enabled)
381+
{
382+
struct pci_dev *pdev = link->downstream;
383+
384+
/* For devicetree platforms, enable ClockPM by default */
385+
if (of_have_populated_dt() && !enabled) {
386+
link->clkpm_default = 1;
387+
pci_info(pdev, "ASPM: DT platform, enabling ClockPM\n");
388+
}
389+
}
390+
376391
static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
377392
{
378393
int capable = 1, enabled = 1;
@@ -395,6 +410,7 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
395410
}
396411
link->clkpm_enabled = enabled;
397412
link->clkpm_default = enabled;
413+
pcie_clkpm_override_default_link_state(link, enabled);
398414
link->clkpm_capable = capable;
399415
link->clkpm_disable = blacklist ? 1 : 0;
400416
}
@@ -788,6 +804,29 @@ static void aspm_l1ss_init(struct pcie_link_state *link)
788804
aspm_calc_l12_info(link, parent_l1ss_cap, child_l1ss_cap);
789805
}
790806

807+
#define FLAG(x, y, d) (((x) & (PCIE_LINK_STATE_##y)) ? d : "")
808+
809+
static void pcie_aspm_override_default_link_state(struct pcie_link_state *link)
810+
{
811+
struct pci_dev *pdev = link->downstream;
812+
u32 override;
813+
814+
/* For devicetree platforms, enable all ASPM states by default */
815+
if (of_have_populated_dt()) {
816+
link->aspm_default = PCIE_LINK_STATE_ASPM_ALL;
817+
override = link->aspm_default & ~link->aspm_enabled;
818+
if (override)
819+
pci_info(pdev, "ASPM: DT platform, enabling%s%s%s%s%s%s%s\n",
820+
FLAG(override, L0S_UP, " L0s-up"),
821+
FLAG(override, L0S_DW, " L0s-dw"),
822+
FLAG(override, L1, " L1"),
823+
FLAG(override, L1_1, " ASPM-L1.1"),
824+
FLAG(override, L1_2, " ASPM-L1.2"),
825+
FLAG(override, L1_1_PCIPM, " PCI-PM-L1.1"),
826+
FLAG(override, L1_2_PCIPM, " PCI-PM-L1.2"));
827+
}
828+
}
829+
791830
static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
792831
{
793832
struct pci_dev *child = link->downstream, *parent = link->pdev;
@@ -868,6 +907,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
868907
/* Save default state */
869908
link->aspm_default = link->aspm_enabled;
870909

910+
pcie_aspm_override_default_link_state(link);
911+
871912
/* Setup initial capable state. Will be updated later */
872913
link->aspm_capable = link->aspm_support;
873914

0 commit comments

Comments
 (0)