[PATCH] OPP: Check for bandwidth values before creating icc paths

From: Sibi Sankar
Date: Wed May 27 2020 - 15:24:52 EST


Prevent the core from creating and voting on icc paths when the
opp-table does not have the bandwidth values populated. Currently
this check is performed on the first OPP node.

Signed-off-by: Sibi Sankar <sibis@xxxxxxxxxxxxxx>
---
drivers/opp/of.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 61fce1284f012..95cf6f1312765 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -338,6 +338,21 @@ int dev_pm_opp_of_find_icc_paths(struct device *dev,
struct device_node *np;
int ret = 0, i, count, num_paths;
struct icc_path **paths;
+ struct property *prop;
+
+ /* Check for bandwidth values on the first OPP node */
+ if (opp_table && opp_table->np) {
+ np = of_get_next_available_child(opp_table->np, NULL);
+ if (!np) {
+ dev_err(dev, "Empty OPP table\n");
+ return 0;
+ }
+
+ prop = of_find_property(np, "opp-peak-kBps", NULL);
+ of_node_put(np);
+ if (!prop || !prop->length)
+ return 0;
+ }

np = of_node_get(dev->of_node);
if (!np)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project