Skip to content

Commit 50433f6

Browse files
PCI: qcom: Use frequency and level based OPP lookup
PCIe link configurations such as 8GT/s x2 and 16GT/s x1 may operate at the same frequency, but differ in other characteristics like RPMh votes. But the existing OPP selection which is solely based on frequency (the 'opp-hz' DT property) cannot distinguish between such cases. Hence, use the newly introduced dev_pm_opp_find_key_exact() API to match both frequency and level (the 'opp-level' property) when selecting an OPP, here level indicates PCIe data rate. To support older device trees where opp-level is not defined, check if opp-level is present or not using dev_pm_opp_find_level_exact(). If not present fallback to frequency only match. Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com> [mani: zero initialize dev_pm_opp_key struct] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> [bhelgaas: add 'opp-hz' and 'opp-level' in commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20251013-opp_pcie-v5-5-eb64db2b4bd3@oss.qualcomm.com
1 parent 3a86608 commit 50433f6

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
15651565
{
15661566
u32 offset, status, width, speed;
15671567
struct dw_pcie *pci = pcie->pci;
1568+
struct dev_pm_opp_key key = {};
15681569
unsigned long freq_kbps;
15691570
struct dev_pm_opp *opp;
15701571
int ret, freq_mbps;
@@ -1592,8 +1593,20 @@ static void qcom_pcie_icc_opp_update(struct qcom_pcie *pcie)
15921593
return;
15931594

15941595
freq_kbps = freq_mbps * KILO;
1595-
opp = dev_pm_opp_find_freq_exact(pci->dev, freq_kbps * width,
1596-
true);
1596+
opp = dev_pm_opp_find_level_exact(pci->dev, speed);
1597+
if (IS_ERR(opp)) {
1598+
/* opp-level is not defined use only frequency */
1599+
opp = dev_pm_opp_find_freq_exact(pci->dev, freq_kbps * width,
1600+
true);
1601+
} else {
1602+
/* put opp-level OPP */
1603+
dev_pm_opp_put(opp);
1604+
1605+
key.freq = freq_kbps * width;
1606+
key.level = speed;
1607+
key.bw = 0;
1608+
opp = dev_pm_opp_find_key_exact(pci->dev, &key, true);
1609+
}
15971610
if (!IS_ERR(opp)) {
15981611
ret = dev_pm_opp_set_opp(pci->dev, opp);
15991612
if (ret)

0 commit comments

Comments
 (0)