Skip to contentSkip to conversation

PCI: qcom: Set max OPP before DBI access during resume

PATCH Applied Qiang Yu 4 participants 4 messages Apr 17 – May 12

Subsystems (4)
lore
Share & tools
lore

Qiang Yu

author
#0 lore raw

PATCH 1/1 PCI: qcom: Set max OPP before DBI access during resume

During resume, qcom_pcie_icc_opp_update() may access DBI registers before the OPP votes are restored, which can trigger NoC errors.

Set the PCIe controller to the maximum OPP first in resume_noirq(), then proceed with link/DBI accesses. The OPP is later updated again based on the actual link bandwidth requirements.

Also introduce a small helper to reuse the max-OPP setup path shared with probe.

Fixes 5b6272e0efd5 ("PCI: qcom: Add OPP support to scale performance")
---
 drivers/pci/controller/dwc/pcie-qcom.c | 42 +++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +26 -16
index 9fdfc88ac15120b2b01cad746772ae612a2c9690..c9b201a1c033a9849e97db9ee4d07d26655d5a6c 100644
@@ -1613,6 +1613,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);
@@ -1845,9 +1861,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;
@@ -1951,21 +1965,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;
 		}
 
@@ -2100,6 +2102,14 @@ static int qcom_pcie_resume_noirq(struct device *dev)
 		return 0;
 
 	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", ret);

---
base-commit: 33a76fc3c3e61386524479b99f35423bd3d9a895
change-id: 20260416-setmaxopp-7a4f49fb90b5

Best regards,

Signature · 1 line
Qiang Yu <[email protected]>
#1 lore raw
Quoted 21 lines · Qiang Yu

During resume, qcom_pcie_icc_opp_update() may access DBI registers before the OPP votes are restored, which can trigger NoC errors.

Set the PCIe controller to the maximum OPP first in resume_noirq(), then proceed with link/DBI accesses. The OPP is later updated again based on the actual link bandwidth requirements.

Also introduce a small helper to reuse the max-OPP setup path shared with probe.

Fixes 5b6272e0efd5 ("PCI: qcom: Add OPP support to scale performance")
---
 drivers/pci/controller/dwc/pcie-qcom.c | 42 +++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +0 -0
index 9fdfc88ac15120b2b01cad746772ae612a2c9690..c9b201a1c033a9849e97db9ee4d07d26655d5a6c 100644

drivers/pci/controller/dwc/pcie-qcom.c static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie) · line 1616

Quoted 4 lines
drivers/pci/controller/dwc/pcie-qcom.c +1 -0
@@ -1613,6 +1613,22 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
 	}
 }
 
+static int qcom_pcie_set_max_opp(struct device *dev)

Can this be a small non-zero vote instead?

Konrad

#2 lore raw
Quoted 25 lines · Konrad Dybcio
Quoted 24 lines · Qiang Yu

During resume, qcom_pcie_icc_opp_update() may access DBI registers before the OPP votes are restored, which can trigger NoC errors.

Set the PCIe controller to the maximum OPP first in resume_noirq(), then proceed with link/DBI accesses. The OPP is later updated again based on the actual link bandwidth requirements.

Also introduce a small helper to reuse the max-OPP setup path shared with probe.

Fixes 5b6272e0efd5 ("PCI: qcom: Add OPP support to scale performance")
---
 drivers/pci/controller/dwc/pcie-qcom.c | 42 +++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +0 -0
index 9fdfc88ac15120b2b01cad746772ae612a2c9690..c9b201a1c033a9849e97db9ee4d07d26655d5a6c 100644
@@ -1613,6 +1613,22 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
 	}
 }
 
Quoted 4 lines

drivers/pci/controller/dwc/pcie-qcom.c static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie) · line 1616

Quoted 1 line
drivers/pci/controller/dwc/pcie-qcom.c +1 -0
+static int qcom_pcie_set_max_opp(struct device *dev)

Can this be a small non-zero vote instead?

It won't make a difference. We are going to update the vote right after it. Furthermore, it will allow us to group the logic into one helper and call from both probe() and resume().

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#3 lore raw
In reply to Qiang Yu
Quoted 8 lines · Qiang Yu

During resume, qcom_pcie_icc_opp_update() may access DBI registers before the OPP votes are restored, which can trigger NoC errors.

Set the PCIe controller to the maximum OPP first in resume_noirq(), then proceed with link/DBI accesses. The OPP is later updated again based on the actual link bandwidth requirements.

[...]

Applied, thanks!

[1/1] PCI: qcom: Set max OPP before DBI access during resume

      commit: 44ec2e81ab3758718105b62cb8623060c0aca7bb

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>