Skip to content

Commit c8ed995

Browse files
Vincent Donnefortrafaeljw
authored andcommitted
PM: EM: Mark inefficient states
Some SoCs, such as the sd855 have OPPs within the same performance domain, whose cost is higher than others with a higher frequency. Even though those OPPs are interesting from a cooling perspective, it makes no sense to use them when the device can run at full capacity. Those OPPs handicap the performance domain, when choosing the most energy-efficient CPU and are wasting energy. They are inefficient. Hence, add support for such OPPs to the Energy Model. The table can now be read skipping inefficient performance states (and by extension, inefficient OPPs). Signed-off-by: Vincent Donnefort <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent aa1a432 commit c8ed995

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

include/linux/energy_model.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,25 @@
1717
* device). It can be a total power: static and dynamic.
1818
* @cost: The cost coefficient associated with this level, used during
1919
* energy calculation. Equal to: power * max_frequency / frequency
20+
* @flags: see "em_perf_state flags" description below.
2021
*/
2122
struct em_perf_state {
2223
unsigned long frequency;
2324
unsigned long power;
2425
unsigned long cost;
26+
unsigned long flags;
2527
};
2628

29+
/*
30+
* em_perf_state flags:
31+
*
32+
* EM_PERF_STATE_INEFFICIENT: The performance state is inefficient. There is
33+
* in this em_perf_domain, another performance state with a higher frequency
34+
* but a lower or equal power cost. Such inefficient states are ignored when
35+
* using em_pd_get_efficient_*() functions.
36+
*/
37+
#define EM_PERF_STATE_INEFFICIENT BIT(0)
38+
2739
/**
2840
* struct em_perf_domain - Performance domain
2941
* @table: List of performance states, in ascending order

kernel/power/energy_model.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Energy Model of devices
44
*
5-
* Copyright (c) 2018-2020, Arm ltd.
5+
* Copyright (c) 2018-2021, Arm ltd.
66
* Written by: Quentin Perret, Arm ltd.
77
* Improvements provided by: Lukasz Luba, Arm ltd.
88
*/
@@ -42,6 +42,7 @@ static void em_debug_create_ps(struct em_perf_state *ps, struct dentry *pd)
4242
debugfs_create_ulong("frequency", 0444, d, &ps->frequency);
4343
debugfs_create_ulong("power", 0444, d, &ps->power);
4444
debugfs_create_ulong("cost", 0444, d, &ps->cost);
45+
debugfs_create_ulong("inefficient", 0444, d, &ps->flags);
4546
}
4647

4748
static int em_debug_cpus_show(struct seq_file *s, void *unused)
@@ -162,6 +163,7 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
162163
table[i].cost = div64_u64(fmax * power_res,
163164
table[i].frequency);
164165
if (table[i].cost >= prev_cost) {
166+
table[i].flags = EM_PERF_STATE_INEFFICIENT;
165167
dev_dbg(dev, "EM: OPP:%lu is inefficient\n",
166168
table[i].frequency);
167169
} else {

0 commit comments

Comments
 (0)