Skip to content

Commit

Permalink
Merge branch 'opp/fixes' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/vireshk/pm

Pull operating performance points (OPP) framework fixes for v5.4
from Viresh Kumar:

"This contains:

- Patch to revert addition of regulator enable/disable in OPP core
  (Marek).
- Remove incorrect lockdep assert (Viresh).
- Fix a kref counting issue (Viresh)."

* 'opp/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  opp: Reinitialize the list_kref before adding the static OPPs again
  opp: core: Revert "add regulators enable and disable"
  opp: of: drop incorrect lockdep_assert_held()
  • Loading branch information
Rafael J. Wysocki committed Oct 23, 2019
2 parents 7d194c2 + b19c235 commit 028db79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
16 changes: 3 additions & 13 deletions drivers/opp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1626,12 +1626,6 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev,
goto free_regulators;
}

ret = regulator_enable(reg);
if (ret < 0) {
regulator_put(reg);
goto free_regulators;
}

opp_table->regulators[i] = reg;
}

Expand All @@ -1645,10 +1639,8 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev,
return opp_table;

free_regulators:
while (i--) {
regulator_disable(opp_table->regulators[i]);
regulator_put(opp_table->regulators[i]);
}
while (i != 0)
regulator_put(opp_table->regulators[--i]);

kfree(opp_table->regulators);
opp_table->regulators = NULL;
Expand All @@ -1674,10 +1666,8 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
/* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list));

for (i = opp_table->regulator_count - 1; i >= 0; i--) {
regulator_disable(opp_table->regulators[i]);
for (i = opp_table->regulator_count - 1; i >= 0; i--)
regulator_put(opp_table->regulators[i]);
}

_free_set_opp_data(opp_table);

Expand Down
9 changes: 7 additions & 2 deletions drivers/opp/of.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table,
{
struct dev_pm_opp *opp;

lockdep_assert_held(&opp_table_lock);

mutex_lock(&opp_table->lock);

list_for_each_entry(opp, &opp_table->opp_list, node) {
Expand Down Expand Up @@ -665,6 +663,13 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
return 0;
}

/*
* Re-initialize list_kref every time we add static OPPs to the OPP
* table as the reference count may be 0 after the last tie static OPPs
* were removed.
*/
kref_init(&opp_table->list_kref);

/* We have opp-table node now, iterate over it and add OPPs */
for_each_available_child_of_node(opp_table->np, np) {
opp = _opp_add_static_v2(opp_table, dev, np);
Expand Down

0 comments on commit 028db79

Please sign in to comment.