Commit 7c41cdcd authored by Viresh Kumar's avatar Viresh Kumar

OPP: Simplify the over-designed pstate <-> level dance

While adding support for "performance states" in the OPP and genpd core,
it was decided to set the `pstate` field via genpd's
pm_genpd_opp_to_performance_state() helper, to allow platforms to set
`pstate` even if they don't have a corresponding `level` field in the DT
OPP tables (More details are present in commit 6e41766a ("PM /
Domain: Implement of_genpd_opp_to_performance_state()")).

Revisiting that five years later clearly suggests that it was
over-designed as all current users are eventually using the `level`
value only.

The previous commit already added necessary checks to make sure pstate
is only used for genpd tables. Lets now simplify this a little, and use
`level` directly and remove `pstate` field altogether.
Suggested-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 84cb7ff3
...@@ -245,7 +245,7 @@ unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, ...@@ -245,7 +245,7 @@ unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp,
return 0; return 0;
} }
return opp->required_opps[index]->pstate; return opp->required_opps[index]->level;
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate); EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate);
...@@ -943,7 +943,7 @@ static int _set_opp_bw(const struct opp_table *opp_table, ...@@ -943,7 +943,7 @@ static int _set_opp_bw(const struct opp_table *opp_table,
static int _set_performance_state(struct device *dev, struct device *pd_dev, static int _set_performance_state(struct device *dev, struct device *pd_dev,
struct dev_pm_opp *opp, int i) struct dev_pm_opp *opp, int i)
{ {
unsigned int pstate = likely(opp) ? opp->required_opps[i]->pstate : 0; unsigned int pstate = likely(opp) ? opp->required_opps[i]->level: 0;
int ret; int ret;
if (!pd_dev) if (!pd_dev)
...@@ -2728,8 +2728,8 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, ...@@ -2728,8 +2728,8 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table,
mutex_lock(&src_table->lock); mutex_lock(&src_table->lock);
list_for_each_entry(opp, &src_table->opp_list, node) { list_for_each_entry(opp, &src_table->opp_list, node) {
if (opp->pstate == pstate) { if (opp->level == pstate) {
dest_pstate = opp->required_opps[i]->pstate; dest_pstate = opp->required_opps[i]->level;
goto unlock; goto unlock;
} }
} }
......
...@@ -156,9 +156,6 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table) ...@@ -156,9 +156,6 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
debugfs_create_ulong("clock_latency_ns", S_IRUGO, d, debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
&opp->clock_latency_ns); &opp->clock_latency_ns);
if (opp_table->is_genpd)
debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate);
opp->of_name = of_node_full_name(opp->np); opp->of_name = of_node_full_name(opp->np);
debugfs_create_str("of_name", S_IRUGO, d, (char **)&opp->of_name); debugfs_create_str("of_name", S_IRUGO, d, (char **)&opp->of_name);
......
...@@ -945,9 +945,6 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, ...@@ -945,9 +945,6 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
if (ret) if (ret)
goto free_required_opps; goto free_required_opps;
if (opp_table->is_genpd)
new_opp->pstate = pm_genpd_opp_to_performance_state(dev, new_opp);
ret = _opp_add(dev, new_opp, opp_table); ret = _opp_add(dev, new_opp, opp_table);
if (ret) { if (ret) {
/* Don't return error for duplicate OPPs */ /* Don't return error for duplicate OPPs */
...@@ -1400,7 +1397,7 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) ...@@ -1400,7 +1397,7 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
opp = _find_opp_of_np(opp_table, required_np); opp = _find_opp_of_np(opp_table, required_np);
if (opp) { if (opp) {
pstate = opp->pstate; pstate = opp->level;
dev_pm_opp_put(opp); dev_pm_opp_put(opp);
} }
......
...@@ -78,7 +78,6 @@ struct opp_config_data { ...@@ -78,7 +78,6 @@ struct opp_config_data {
* @turbo: true if turbo (boost) OPP * @turbo: true if turbo (boost) OPP
* @suspend: true if suspend OPP * @suspend: true if suspend OPP
* @removed: flag indicating that OPP's reference is dropped by OPP core. * @removed: flag indicating that OPP's reference is dropped by OPP core.
* @pstate: Device's power domain's performance state.
* @rates: Frequencies in hertz * @rates: Frequencies in hertz
* @level: Performance level * @level: Performance level
* @supplies: Power supplies voltage/current values * @supplies: Power supplies voltage/current values
...@@ -101,7 +100,6 @@ struct dev_pm_opp { ...@@ -101,7 +100,6 @@ struct dev_pm_opp {
bool turbo; bool turbo;
bool suspend; bool suspend;
bool removed; bool removed;
unsigned int pstate;
unsigned long *rates; unsigned long *rates;
unsigned int level; unsigned int level;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment