Skip to content

Commit 7c41cdc

Browse files
committed
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 6e41766 ("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: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 84cb7ff commit 7c41cdc

4 files changed

Lines changed: 5 additions & 13 deletions

File tree

drivers/opp/core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp,
245245
return 0;
246246
}
247247

248-
return opp->required_opps[index]->pstate;
248+
return opp->required_opps[index]->level;
249249
}
250250
EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate);
251251

@@ -943,7 +943,7 @@ static int _set_opp_bw(const struct opp_table *opp_table,
943943
static int _set_performance_state(struct device *dev, struct device *pd_dev,
944944
struct dev_pm_opp *opp, int i)
945945
{
946-
unsigned int pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
946+
unsigned int pstate = likely(opp) ? opp->required_opps[i]->level: 0;
947947
int ret;
948948

949949
if (!pd_dev)
@@ -2728,8 +2728,8 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table,
27282728
mutex_lock(&src_table->lock);
27292729

27302730
list_for_each_entry(opp, &src_table->opp_list, node) {
2731-
if (opp->pstate == pstate) {
2732-
dest_pstate = opp->required_opps[i]->pstate;
2731+
if (opp->level == pstate) {
2732+
dest_pstate = opp->required_opps[i]->level;
27332733
goto unlock;
27342734
}
27352735
}

drivers/opp/debugfs.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
156156
debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
157157
&opp->clock_latency_ns);
158158

159-
if (opp_table->is_genpd)
160-
debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate);
161-
162159
opp->of_name = of_node_full_name(opp->np);
163160
debugfs_create_str("of_name", S_IRUGO, d, (char **)&opp->of_name);
164161

drivers/opp/of.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,6 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
945945
if (ret)
946946
goto free_required_opps;
947947

948-
if (opp_table->is_genpd)
949-
new_opp->pstate = pm_genpd_opp_to_performance_state(dev, new_opp);
950-
951948
ret = _opp_add(dev, new_opp, opp_table);
952949
if (ret) {
953950
/* Don't return error for duplicate OPPs */
@@ -1400,7 +1397,7 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
14001397

14011398
opp = _find_opp_of_np(opp_table, required_np);
14021399
if (opp) {
1403-
pstate = opp->pstate;
1400+
pstate = opp->level;
14041401
dev_pm_opp_put(opp);
14051402
}
14061403

drivers/opp/opp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ struct opp_config_data {
7878
* @turbo: true if turbo (boost) OPP
7979
* @suspend: true if suspend OPP
8080
* @removed: flag indicating that OPP's reference is dropped by OPP core.
81-
* @pstate: Device's power domain's performance state.
8281
* @rates: Frequencies in hertz
8382
* @level: Performance level
8483
* @supplies: Power supplies voltage/current values
@@ -101,7 +100,6 @@ struct dev_pm_opp {
101100
bool turbo;
102101
bool suspend;
103102
bool removed;
104-
unsigned int pstate;
105103
unsigned long *rates;
106104
unsigned int level;
107105

0 commit comments

Comments
 (0)