Skip to content

Commit 9251414

Browse files
committed
OPP: Don't set OPP recursively for a parent genpd
Like other frameworks (clk, regulator, etc.) genpd core too takes care of propagation to performance state to parent genpds. The OPP core shouldn't attempt the same, or it may result in undefined behavior. Add checks at various places to take care of the same. Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent e37440e commit 9251414

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

drivers/opp/core.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,12 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
23922392
return -EINVAL;
23932393
}
23942394

2395+
/* Genpd core takes care of propagation to parent genpd */
2396+
if (opp_table->is_genpd) {
2397+
dev_err(dev, "%s: Operation not supported for genpds\n", __func__);
2398+
return -EOPNOTSUPP;
2399+
}
2400+
23952401
/* Checking only the first one is enough ? */
23962402
if (opp_table->required_devs[0])
23972403
return 0;
@@ -2453,8 +2459,16 @@ static int _opp_set_required_devs(struct opp_table *opp_table,
24532459
if (opp_table->required_devs[0])
24542460
return 0;
24552461

2456-
for (i = 0; i < opp_table->required_opp_count; i++)
2462+
for (i = 0; i < opp_table->required_opp_count; i++) {
2463+
/* Genpd core takes care of propagation to parent genpd */
2464+
if (required_devs[i] && opp_table->is_genpd &&
2465+
opp_table->required_opp_tables[i]->is_genpd) {
2466+
dev_err(dev, "%s: Operation not supported for genpds\n", __func__);
2467+
return -EOPNOTSUPP;
2468+
}
2469+
24572470
opp_table->required_devs[i] = required_devs[i];
2471+
}
24582472

24592473
return 0;
24602474
}

drivers/opp/of.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,11 @@ static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_tab
339339
*/
340340
if (required_table->is_genpd && opp_table->required_opp_count == 1 &&
341341
!opp_table->required_devs[0]) {
342-
if (!WARN_ON(opp->level != OPP_LEVEL_UNSET))
343-
opp->level = opp->required_opps[0]->level;
342+
/* Genpd core takes care of propagation to parent genpd */
343+
if (!opp_table->is_genpd) {
344+
if (!WARN_ON(opp->level != OPP_LEVEL_UNSET))
345+
opp->level = opp->required_opps[0]->level;
346+
}
344347
}
345348

346349
return 0;

0 commit comments

Comments
 (0)