OPP: Check for bandwidth values before creating icc paths
Subsystems (2)
PATCH 1/1 OPP: Check for bandwidth values before creating icc paths
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.
--- drivers/opp/of.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/opp/of.c +15 -0
@@ -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)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 22 lines · Sibi Sankar
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 <[email protected]>--- drivers/opp/of.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/opp/of.c +5
-0@@ -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 );
drivers/opp/of.c int dev_pm_opp_of_find_icc_paths(struct device *dev, · line 355
Quoted 10 lines
drivers/opp/of.c +10
-0+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 ; + }
This doesn't support the call made from cpufreq-dt driver. Pushed this, please give this a try:
From: Sibi Sankar <[email protected]>
Date: Thu, 28 May 2020 00:54:18 +0530
Subject: [PATCH] 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.
--- drivers/opp/of.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/opp/of.c +44 -1
@@ -332,13 +332,56 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table,return ret; } +static int _bandwidth_supported (struct device *dev,struct opp_table *opp_table) +{ +struct device_node *np, *opp_np; +struct property *prop; + +if (!opp_table) { + np =of_node_get (dev->of_node); +if (!np) +return -ENODEV ; + + opp_np =_opp_of_get_opp_desc_node (np,0 ); +of_node_put (np); + +/* Lets not fail in case we are parsing opp-v1 bindings */ +if (!opp_np) +return 0 ; + }else { + opp_np =of_node_get (opp_table->np); + } + +/* Checking only first OPP is sufficient */ + np =of_get_next_available_child (opp_np,NULL ); +if (!np) { +dev_err (dev,"OPP table empty\n" ); +return -EINVAL ; + } +of_node_put (opp_np); + + prop =of_find_property (np,"opp-peak-kBps" ,NULL ); +of_node_put (np); + +if (!prop || !prop->length) +return 0 ; + +return 1 ; +} +int dev_pm_opp_of_find_icc_paths (struct device *dev,struct opp_table *opp_table) {struct device_node *np; -int ret =0 , i, count, num_paths; +int ret, i, count, num_paths;struct icc_path **paths; + ret =_bandwidth_supported (dev, opp_table); +if (ret <=0 ) +return ret; + + ret =0 ; + np =of_node_get (dev->of_node);if (!np)return 0 ;
Signature · 1 line
viresh
Quoted 29 lines · Viresh Kumar
Quoted 28 lines · Sibi Sankar
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 <[email protected]>--- drivers/opp/of.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/opp/of.c +10
-0@@ -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 ; + } +
Quoted 8 lines
drivers/opp/of.c static int _of_opp_alloc_required_opps(struct opp_table *opp_table, · line 370
Quoted 5 lines
drivers/opp/of.c +5
-0+ prop =of_find_property (np,"opp-peak-kBps" ,NULL ); +of_node_put (np); +if (!prop || !prop->length) +return 0 ; + }This doesn't support the call made from cpufreq-dt driver. Pushed this, please give this a try:
Viresh,
Thanks for the patch!
Quoted 34 lines
From: Sibi Sankar <[email protected]>
Date: Thu, 28 May 2020 00:54:18 +0530
Subject: [PATCH] opp: Don't parse icc paths unnecessarilyThe 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]>[ Viresh: Support the case of !opp_table and massaged changelog ]Signed-off-by Viresh Kumar <[email protected]>--- drivers/opp/of.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)drivers/opp/of.c +8
-0@@ -332,13 +332,56 @@ static int _of_opp_alloc_required_opps(structopp_table *opp_table, return ret; } +static int _bandwidth_supported (struct device *dev,struct opp_table *opp_table) +{ +struct device_node *np, *opp_np; +struct property *prop; + +if (!opp_table) { + np =of_node_get (dev->of_node); +if (!np)
drivers/opp/of.c static int _of_opp_alloc_required_opps(struct · line 354
Quoted 10 lines
drivers/opp/of.c +10
-0+return -ENODEV ; + + opp_np =_opp_of_get_opp_desc_node (np,0 ); +of_node_put (np); + +/* Lets not fail in case we are parsing opp-v1 bindings */ +if (!opp_np) +return 0 ; + }else { + opp_np =of_node_get (opp_table->np);
opp_np needs to be subjected
to NULL check as well. Lets
move "if (!opp_np)" to outside
the if/else. With the above
change in place:
Quoted 36 lines
drivers/opp/of.c +26
-1+ } + +/* Checking only first OPP is sufficient */ + np =of_get_next_available_child (opp_np,NULL ); +if (!np) { +dev_err (dev,"OPP table empty\n" ); +return -EINVAL ; + } +of_node_put (opp_np); + + prop =of_find_property (np,"opp-peak-kBps" ,NULL ); +of_node_put (np); + +if (!prop || !prop->length) +return 0 ; + +return 1 ; +} +int dev_pm_opp_of_find_icc_paths (struct device *dev,struct opp_table *opp_table) {struct device_node *np; -int ret =0 , i, count, num_paths; +int ret, i, count, num_paths;struct icc_path **paths; + ret =_bandwidth_supported (dev, opp_table); +if (ret <=0 ) +return ret; + + ret =0 ; + np =of_node_get (dev->of_node);drivers/opp/of.c +0
-0if (!np)return 0 ;
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 2 lines · Sibi Sankar
opp_npneeds to be subjected
to NULL check as well.
No, it isn't. It should already be valid and is set by the OPP core. Actually we don't need to do of_node_get(opp_table->np) and just use np, I did that to not have a special case while putting the resource.
Quoted 2 lines
Tested-by Sibi Sankar <[email protected]>Reviewed-by Sibi Sankar <[email protected]>
Thanks.
Signature · 1 line
viresh
Quoted 8 lines · Viresh Kumar
Quoted 2 lines · Sibi Sankar
opp_npneeds to be subjected
to NULL check as well.No, it isn't. It should already be valid and is set by the OPP core. Actually we don't need to do
of_node_get(opp_table->np)and just use np, I did that to not have a special case while putting the resource.
I should have phrased it differently.opp_np needs to be checked to deal
with cases where devices don't have
"operating-points-v2" associated with
it.
drivers/opp/of.c +4 -4
@@ -344,14 +344,14 @@ static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) opp_np =_opp_of_get_opp_desc_node (np,0 );of_node_put (np); - -/* Lets not fail in case we are parsing opp-v1 bindings */ -if (!opp_np) -return 0 ; }else { opp_np =of_node_get (opp_table->np); } +/* Lets not fail in case we are parsing opp-v1 bindings */ +if (!opp_np) +return 0 ; +
sdhci_msm 7c4000.sdhci: OPP table emptysdhci_msm 7c4000.sdhci: _allocate_opp_table: Error finding interconnect paths: -22
I see the following errors without
the check.
Quoted 4 lines
Quoted 2 lines
Tested-by Sibi Sankar <[email protected]>Reviewed-by Sibi Sankar <[email protected]>Thanks.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 42 lines · Sibi Sankar
Quoted 8 lines · Viresh Kumar
Quoted 2 lines · Sibi Sankar
opp_npneeds to be subjected
to NULL check as well.No, it isn't. It should already be valid and is set by the OPP core. Actually we don't need to do
of_node_get(opp_table->np)and just use np, I did that to not have a special case while putting the resource.I should have phrased it differently.
opp_npneeds to be checked to deal with cases where devices don't have "operating-points-v2" associated with it.drivers/opp/of.c +4
-4@@ -344,14 +344,14 @@ static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) opp_np =_opp_of_get_opp_desc_node (np,0 );of_node_put (np); - -/* Lets not fail in case we are parsing opp-v1 bindings */ -if (!opp_np) -return 0 ; }else { opp_np =of_node_get (opp_table->np); } +/* Lets not fail in case we are parsing opp-v1 bindings */ +if (!opp_np) +return 0 ; +
sdhci_msm7c4000.sdhci: OPP table emptysdhci_msm7c4000.sdhci:_allocate_opp_table: Error finding interconnect
paths: -22
Quoted 2 lines
I see the following errors without the check.
My reply unfortunately only considered the case where this routine was called from within the opp table. Are you testing it for the case where you are adding OPPs dynamically from the code ?
Signature · 1 line
viresh
Quoted 45 lines · Viresh Kumar
Quoted 44 lines · Sibi Sankar
Quoted 8 lines · Viresh Kumar
Quoted 2 lines · Sibi Sankar
opp_npneeds to be subjected
to NULL check as well.No, it isn't. It should already be valid and is set by the OPP core. Actually we don't need to do
of_node_get(opp_table->np)and just use np, I did that to not have a special case while putting the resource.I should have phrased it differently.
opp_npneeds to be checked to deal with cases where devices don't have "operating-points-v2" associated with it.drivers/opp/of.c +0
-2@@ -344,14 +344,14 @@ static int _bandwidth_supported(struct device *dev, struct opp_table *opp_table) opp_np =_opp_of_get_opp_desc_node (np,0 );of_node_put (np); - -/* Lets not fail in case we are parsing opp-v1 bindings */
drivers/opp/of.c +4
-2-if (!opp_np) -return 0 ; }else { opp_np =of_node_get (opp_table->np); } +/* Lets not fail in case we are parsing opp-v1 bindings */ +if (!opp_np) +return 0 ; +
sdhci_msm7c4000.sdhci: OPP table emptysdhci_msm7c4000.sdhci:_allocate_opp_table: Error finding interconnect
paths: -22
Quoted 6 lines
Quoted 2 lines
I see the following errors without the check.
My reply unfortunately only considered the case where this routine was called from within the opp table. Are you testing it for the case where you are adding OPPs dynamically from the code ?
Yeah dev_pm_opp_add/dev_pm_opp_set_clkname
or pretty much any api doing adev_pm_opp_get_opp_table without
a opp_table node associated with
it will run into this issue.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 5 lines · Sibi Sankar
Yeah dev_pm_opp_add/dev_pm_opp_set_clkname
or pretty much any api doing adev_pm_opp_get_opp_tablewithout
aopp_tablenode associated with
it will run into this issue.
Not sure if what you wrote now is correct, the problem shouldn't happen from within dev_pm_opp_set_clkname() but only when we try to do bw thing.
Anyway, I have pushed the change already.
Signature · 1 line
viresh
Quoted 7 lines · Viresh Kumar
Quoted 5 lines · Sibi Sankar
Yeah dev_pm_opp_add/dev_pm_opp_set_clkname
or pretty much any api doing adev_pm_opp_get_opp_tablewithout
aopp_tablenode associated with
it will run into this issue.
Quoted 5 lines
Not sure if what you wrote now is correct, the problem shouldn't happen from within
dev_pm_opp_set_clkname()but only when we try to do bw thing.Anyway, I have pushed the change already.
cool, thanks!
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.