Commit 90d46d71 authored by Viresh Kumar's avatar Viresh Kumar

opp: Handle multiple calls for same OPP table in _of_add_opp_table_v1()

Until now for V1 OPP bindings we used to call
dev_pm_opp_of_cpumask_add_table() first and then
dev_pm_opp_set_sharing_cpus() in the cpufreq-dt driver.

A later patch will though update the cpufreq-dt driver to optimize the
code a bit and we will call dev_pm_opp_set_sharing_cpus() first followed
by dev_pm_opp_of_cpumask_add_table(), which doesn't work well today as
it tries to re parse the OPP entries. This should work nevertheless for
V1 bindings as the same works for V2 bindings.

Adapt the same approach from V2 bindings and fix this.
Reported-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent dd461cd9
...@@ -886,11 +886,25 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) ...@@ -886,11 +886,25 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
const __be32 *val; const __be32 *val;
int nr, ret = 0; int nr, ret = 0;
mutex_lock(&opp_table->lock);
if (opp_table->parsed_static_opps) {
opp_table->parsed_static_opps++;
mutex_unlock(&opp_table->lock);
return 0;
}
opp_table->parsed_static_opps = 1;
mutex_unlock(&opp_table->lock);
prop = of_find_property(dev->of_node, "operating-points", NULL); prop = of_find_property(dev->of_node, "operating-points", NULL);
if (!prop) if (!prop) {
return -ENODEV; ret = -ENODEV;
if (!prop->value) goto remove_static_opp;
return -ENODATA; }
if (!prop->value) {
ret = -ENODATA;
goto remove_static_opp;
}
/* /*
* Each OPP is a set of tuples consisting of frequency and * Each OPP is a set of tuples consisting of frequency and
...@@ -899,13 +913,10 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) ...@@ -899,13 +913,10 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
nr = prop->length / sizeof(u32); nr = prop->length / sizeof(u32);
if (nr % 2) { if (nr % 2) {
dev_err(dev, "%s: Invalid OPP table\n", __func__); dev_err(dev, "%s: Invalid OPP table\n", __func__);
return -EINVAL; ret = -EINVAL;
goto remove_static_opp;
} }
mutex_lock(&opp_table->lock);
opp_table->parsed_static_opps = 1;
mutex_unlock(&opp_table->lock);
val = prop->value; val = prop->value;
while (nr) { while (nr) {
unsigned long freq = be32_to_cpup(val++) * 1000; unsigned long freq = be32_to_cpup(val++) * 1000;
...@@ -915,12 +926,14 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) ...@@ -915,12 +926,14 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
if (ret) { if (ret) {
dev_err(dev, "%s: Failed to add OPP %ld (%d)\n", dev_err(dev, "%s: Failed to add OPP %ld (%d)\n",
__func__, freq, ret); __func__, freq, ret);
_opp_remove_all_static(opp_table); goto remove_static_opp;
return ret;
} }
nr -= 2; nr -= 2;
} }
remove_static_opp:
_opp_remove_all_static(opp_table);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment