Skip to content

Commit 45679f9

Browse files
Sibi Sankarvireshk
authored andcommitted
opp: Don't parse icc paths unnecessarily
The DT node of the device may contain interconnect paths while the OPP table doesn't have the bandwidth values. There is no need to parse the paths in such cases. Signed-off-by: Sibi Sankar <[email protected]> Tested-by: Sibi Sankar <[email protected]> Reviewed-by: Sibi Sankar <[email protected]> [ Viresh: Support the case of !opp_table and massaged changelog ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent b00e667 commit 45679f9

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

drivers/opp/of.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,56 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table,
332332
return ret;
333333
}
334334

335+
static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table)
336+
{
337+
struct device_node *np, *opp_np;
338+
struct property *prop;
339+
340+
if (!opp_table) {
341+
np = of_node_get(dev->of_node);
342+
if (!np)
343+
return -ENODEV;
344+
345+
opp_np = _opp_of_get_opp_desc_node(np, 0);
346+
of_node_put(np);
347+
} else {
348+
opp_np = of_node_get(opp_table->np);
349+
}
350+
351+
/* Lets not fail in case we are parsing opp-v1 bindings */
352+
if (!opp_np)
353+
return 0;
354+
355+
/* Checking only first OPP is sufficient */
356+
np = of_get_next_available_child(opp_np, NULL);
357+
if (!np) {
358+
dev_err(dev, "OPP table empty\n");
359+
return -EINVAL;
360+
}
361+
of_node_put(opp_np);
362+
363+
prop = of_find_property(np, "opp-peak-kBps", NULL);
364+
of_node_put(np);
365+
366+
if (!prop || !prop->length)
367+
return 0;
368+
369+
return 1;
370+
}
371+
335372
int dev_pm_opp_of_find_icc_paths(struct device *dev,
336373
struct opp_table *opp_table)
337374
{
338375
struct device_node *np;
339-
int ret = 0, i, count, num_paths;
376+
int ret, i, count, num_paths;
340377
struct icc_path **paths;
341378

379+
ret = _bandwidth_supported(dev, opp_table);
380+
if (ret <= 0)
381+
return ret;
382+
383+
ret = 0;
384+
342385
np = of_node_get(dev->of_node);
343386
if (!np)
344387
return 0;

0 commit comments

Comments
 (0)