Re: [PATCH V2 2/2] cpufreq: dt: Refactor initialization to handle probe deferral properly

From: Viresh Kumar
Date: Tue Sep 01 2020 - 05:45:18 EST


On 01-09-20, 10:57, Marek Szyprowski wrote:
> This patch landed in linux-next about a week ago. It introduces a
> following warning on Samsung Exnyos3250 SoC:
>
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 1000000000, volt: 1150000, enabled: 1. New: freq: 1000000000, volt:
> 1150000, enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 900000000, volt: 1112500, enabled: 1. New: freq: 900000000, volt:
> 1112500, enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 800000000, volt: 1075000, enabled: 1. New: freq: 800000000, volt:
> 1075000, enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 700000000, volt: 1037500, enabled: 1. New: freq: 700000000, volt:
> 1037500, enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 600000000, volt: 1000000, enabled: 1. New: freq: 600000000, volt:
> 1000000, enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 500000000, volt: 962500, enabled: 1. New: freq: 500000000, volt: 962500,
> enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 400000000, volt: 925000, enabled: 1. New: freq: 400000000, volt: 925000,
> enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 300000000, volt: 887500, enabled: 1. New: freq: 300000000, volt: 887500,
> enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 200000000, volt: 850000, enabled: 1. New: freq: 200000000, volt: 850000,
> enabled: 1
> cpu cpu1: _opp_is_duplicate: duplicate OPPs detected. Existing: freq:
> 100000000, volt: 850000, enabled: 1. New: freq: 100000000, volt: 850000,
> enabled: 1
>
> I've checked a bit and this is related to the fact that Exynos3250 SoC
> use OPP-v1 table. Is this intentional? It is not a problem to convert it
> to OPP-v2 and mark OPP table as shared, but this is a kind of a regression.

It took me 20 minutes for me to see "where has my patch gone" :(

I wrote a small patch for that to work without any issues, but not
sure how I missed or abandoned it. Anyway, here is the diff again and
I will send it out again once you confirm it fixes the issue. Can you
please also test your driver as a module with multiple insertion/removals ?

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 5dac8bffd68c..e72753be7dc7 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -905,6 +905,16 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
const __be32 *val;
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);
if (!prop)
return -ENODEV;
@@ -921,10 +931,6 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
return -EINVAL;
}

- mutex_lock(&opp_table->lock);
- opp_table->parsed_static_opps = 1;
- mutex_unlock(&opp_table->lock);
-
val = prop->value;
while (nr) {
unsigned long freq = be32_to_cpup(val++) * 1000;

--
viresh