cpufreq: dt: Try freeing static OPPs only if we have added them
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 3 Oct 2018 10:05:21 +0000 (15:35 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:08:24 +0000 (11:08 -0800)
commit6d8553dcd9d1e91bebe1e65ad8cbba8ec81d9832
treea06645878b2c59a0fac75ebd3c2d07410aa2e8c8
parent7b7706258e003a6966b9abc3f325e444ad43ea58
cpufreq: dt: Try freeing static OPPs only if we have added them

[ Upstream commit 51c99dd2c06b234575661fa1e0a1dea6c3ef566f ]

We can not call dev_pm_opp_of_cpumask_remove_table() freely anymore
since the latest OPP core updates as that uses reference counting to
free resources. There are cases where no static OPPs are added (using
DT) for a platform and trying to remove the OPP table may end up
decrementing refcount which is already zero and hence generating
warnings.

Lets track if we were able to add static OPPs or not and then only
remove the table based on that. Some reshuffling of code is also done to
do that.

Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
Tested-by: Niklas Cassel <niklas.cassel@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/cpufreq/cpufreq-dt.c