Skip to content

Commit 4fa82a8

Browse files
hsinyi527vireshk
authored andcommitted
opp: Allow required-opps to be used for non genpd use cases
Don't limit required_opp_table to genpd only. One possible use case is cpufreq based devfreq governor, which can use required-opps property to derive devfreq from cpufreq. Though the OPP core still doesn't support non-genpd required-opps in _set_required_opps(). Suggested-by: Chanwoo Choi <[email protected]> Signed-off-by: Hsin-Yi Wang <[email protected]> [ Viresh: Update _set_required_opps() to check for genpd ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent ac9fd3c commit 4fa82a8

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

drivers/opp/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,16 @@ static int _set_required_opps(struct device *dev,
893893
if (!required_opp_tables)
894894
return 0;
895895

896+
/*
897+
* We only support genpd's OPPs in the "required-opps" for now, as we
898+
* don't know much about other use cases. Error out if the required OPP
899+
* doesn't belong to a genpd.
900+
*/
901+
if (unlikely(!required_opp_tables[0]->is_genpd)) {
902+
dev_err(dev, "required-opps don't belong to a genpd\n");
903+
return -ENOENT;
904+
}
905+
896906
/* required-opps not fully initialized yet */
897907
if (lazy_linking_pending(opp_table))
898908
return -EBUSY;

drivers/opp/of.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,8 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
197197
required_opp_tables[i] = _find_table_of_opp_np(required_np);
198198
of_node_put(required_np);
199199

200-
if (IS_ERR(required_opp_tables[i])) {
200+
if (IS_ERR(required_opp_tables[i]))
201201
lazy = true;
202-
continue;
203-
}
204-
205-
/*
206-
* We only support genpd's OPPs in the "required-opps" for now,
207-
* as we don't know how much about other cases. Error out if the
208-
* required OPP doesn't belong to a genpd.
209-
*/
210-
if (!required_opp_tables[i]->is_genpd) {
211-
dev_err(dev, "required-opp doesn't belong to genpd: %pOF\n",
212-
required_np);
213-
goto free_required_tables;
214-
}
215202
}
216203

217204
/* Let's do the linking later on */
@@ -379,13 +366,6 @@ static void lazy_link_required_opp_table(struct opp_table *new_table)
379366
struct dev_pm_opp *opp;
380367
int i, ret;
381368

382-
/*
383-
* We only support genpd's OPPs in the "required-opps" for now,
384-
* as we don't know much about other cases.
385-
*/
386-
if (!new_table->is_genpd)
387-
return;
388-
389369
mutex_lock(&opp_table_lock);
390370

391371
list_for_each_entry_safe(opp_table, temp, &lazy_opp_tables, lazy) {
@@ -873,7 +853,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
873853
return ERR_PTR(-ENOMEM);
874854

875855
ret = _read_opp_key(new_opp, opp_table, np, &rate_not_available);
876-
if (ret < 0 && !opp_table->is_genpd) {
856+
if (ret < 0) {
877857
dev_err(dev, "%s: opp key field not found\n", __func__);
878858
goto free_opp;
879859
}

0 commit comments

Comments
 (0)