Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions drivers/pci/controller/dwc/pcie-qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,22 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
}
}

static int qcom_pcie_set_max_opp(struct device *dev)
{
unsigned long max_freq = ULONG_MAX;
struct dev_pm_opp *opp;
int ret;

opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
if (IS_ERR(opp))
return PTR_ERR(opp);

ret = dev_pm_opp_set_opp(dev, opp);
dev_pm_opp_put(opp);

return ret;
}

static int qcom_pcie_link_transition_count(struct seq_file *s, void *data)
{
struct qcom_pcie *pcie = (struct qcom_pcie *)dev_get_drvdata(s->private);
Expand Down Expand Up @@ -1924,9 +1940,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
struct qcom_pcie_perst *perst, *tmp_perst;
struct qcom_pcie_port *port, *tmp_port;
const struct qcom_pcie_cfg *pcie_cfg;
unsigned long max_freq = ULONG_MAX;
struct device *dev = &pdev->dev;
struct dev_pm_opp *opp;
struct qcom_pcie *pcie;
struct dw_pcie_rp *pp;
struct resource *res;
Expand Down Expand Up @@ -2030,21 +2044,9 @@ static int qcom_pcie_probe(struct platform_device *pdev)
* probe(), OPP will be updated using qcom_pcie_icc_opp_update().
*/
if (!ret) {
opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
if (IS_ERR(opp)) {
ret = PTR_ERR(opp);
dev_err_probe(pci->dev, ret,
"Unable to find max freq OPP\n");
goto err_pm_runtime_put;
} else {
ret = dev_pm_opp_set_opp(dev, opp);
}

dev_pm_opp_put(opp);
ret = qcom_pcie_set_max_opp(dev);
if (ret) {
dev_err_probe(pci->dev, ret,
"Failed to set OPP for freq %lu\n",
max_freq);
dev_err_probe(dev, ret, "Failed to set max OPP in probe\n");
goto err_pm_runtime_put;
}

Expand Down Expand Up @@ -2189,6 +2191,14 @@ static int qcom_pcie_resume_noirq(struct device *dev)
goto disable_icc_cpu;
}

if (pcie->use_pm_opp) {
ret = qcom_pcie_set_max_opp(dev);
if (ret) {
dev_err(dev, "Failed to set max OPP in resume: %d\n", ret);
return ret;
}
}

/*
* Ignore -ENODEV & -EIO here since it is expected when no endpoint is
* connected to the PCIe link.
Expand All @@ -2198,6 +2208,14 @@ static int qcom_pcie_resume_noirq(struct device *dev)
goto disable_icc_mem;
} else {
if (pm_suspend_target_state != PM_SUSPEND_MEM) {
if (pcie->use_pm_opp) {
ret = qcom_pcie_set_max_opp(dev);
if (ret) {
dev_err(dev, "Failed to set max OPP in resume: %d\n", ret);
return ret;
}
}

ret = icc_enable(pcie->icc_cpu);
if (ret) {
dev_err(dev, "Failed to enable CPU-PCIe interconnect path: %d\n",
Expand Down