diff options
author | Rafael J. Wysocki | 2020-09-01 19:44:20 +0200 |
---|---|---|
committer | Rafael J. Wysocki | 2020-09-01 19:44:20 +0200 |
commit | 763700f5e0fc8e66f4279848b150c5d12eb4d421 (patch) | |
tree | c508dabee27ccd6a88141dc70d09968dd9ac72bf /drivers/opp/core.c | |
parent | f75aef392f869018f78cfedf3c320a6b3fcfda6b (diff) | |
parent | 922ff0759a16299e24cacfc981ac07914d8f1826 (diff) |
Merge branch 'opp/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm
Pull operating performance points (OPP) framework fixes for 5.9-rc4 from
Viresh Kumar:
"This fixes reference counting for OPP tables. Few patches are getting
queued (for various subsystems) for 5.10 which depend on this to be
fixed first."
* 'opp/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
opp: Don't drop reference for an OPP table that was never parsed
Diffstat (limited to 'drivers/opp/core.c')
-rw-r--r-- | drivers/opp/core.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9668ea04cc80..3ca7543142bf 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1296,13 +1296,19 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq) } EXPORT_SYMBOL_GPL(dev_pm_opp_remove); -void _opp_remove_all_static(struct opp_table *opp_table) +bool _opp_remove_all_static(struct opp_table *opp_table) { struct dev_pm_opp *opp, *tmp; + bool ret = true; mutex_lock(&opp_table->lock); - if (!opp_table->parsed_static_opps || --opp_table->parsed_static_opps) + if (!opp_table->parsed_static_opps) { + ret = false; + goto unlock; + } + + if (--opp_table->parsed_static_opps) goto unlock; list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { @@ -1312,6 +1318,8 @@ void _opp_remove_all_static(struct opp_table *opp_table) unlock: mutex_unlock(&opp_table->lock); + + return ret; } /** @@ -2414,13 +2422,15 @@ void _dev_pm_opp_find_and_remove_table(struct device *dev) return; } - _opp_remove_all_static(opp_table); + /* + * Drop the extra reference only if the OPP table was successfully added + * with dev_pm_opp_of_add_table() earlier. + **/ + if (_opp_remove_all_static(opp_table)) + dev_pm_opp_put_opp_table(opp_table); /* Drop reference taken by _find_opp_table() */ dev_pm_opp_put_opp_table(opp_table); - - /* Drop reference taken while the OPP table was added */ - dev_pm_opp_put_opp_table(opp_table); } /** |