Skip to content

Commit 442d24a

Browse files
Vincent Donnefortrafaeljw
authored andcommitted
cpufreq: Add an interface to mark inefficient frequencies
Some SoCs such as the sd855 have OPPs within the same policy whose cost is higher than others with a higher frequency. Those OPPs are inefficients and it might be interesting for a governor to not use them. cpufreq_table_set_inefficient() allows the caller to identify a specified frequency as being inefficient. Inefficient frequencies are only supported on sorted tables. Signed-off-by: Vincent Donnefort <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1517176 commit 442d24a

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

include/linux/cpufreq.h

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,11 @@ struct governor_attr {
660660
*********************************************************************/
661661

662662
/* Special Values of .frequency field */
663-
#define CPUFREQ_ENTRY_INVALID ~0u
664-
#define CPUFREQ_TABLE_END ~1u
663+
#define CPUFREQ_ENTRY_INVALID ~0u
664+
#define CPUFREQ_TABLE_END ~1u
665665
/* Special Values of .flags field */
666-
#define CPUFREQ_BOOST_FREQ (1 << 0)
666+
#define CPUFREQ_BOOST_FREQ (1 << 0)
667+
#define CPUFREQ_INEFFICIENT_FREQ (1 << 1)
667668

668669
struct cpufreq_frequency_table {
669670
unsigned int flags;
@@ -1003,6 +1004,36 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy
10031004
return count;
10041005
}
10051006

1007+
/**
1008+
* cpufreq_table_set_inefficient() - Mark a frequency as inefficient
1009+
* @policy: the &struct cpufreq_policy containing the inefficient frequency
1010+
* @frequency: the inefficient frequency
1011+
*
1012+
* The &struct cpufreq_policy must use a sorted frequency table
1013+
*
1014+
* Return: %0 on success or a negative errno code
1015+
*/
1016+
1017+
static inline int
1018+
cpufreq_table_set_inefficient(struct cpufreq_policy *policy,
1019+
unsigned int frequency)
1020+
{
1021+
struct cpufreq_frequency_table *pos;
1022+
1023+
/* Not supported */
1024+
if (policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED)
1025+
return -EINVAL;
1026+
1027+
cpufreq_for_each_valid_entry(pos, policy->freq_table) {
1028+
if (pos->frequency == frequency) {
1029+
pos->flags |= CPUFREQ_INEFFICIENT_FREQ;
1030+
return 0;
1031+
}
1032+
}
1033+
1034+
return -EINVAL;
1035+
}
1036+
10061037
static inline int parse_perf_domain(int cpu, const char *list_name,
10071038
const char *cell_name)
10081039
{
@@ -1071,6 +1102,13 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
10711102
return false;
10721103
}
10731104

1105+
static inline int
1106+
cpufreq_table_set_inefficient(struct cpufreq_policy *policy,
1107+
unsigned int frequency)
1108+
{
1109+
return -EINVAL;
1110+
}
1111+
10741112
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
10751113
const char *cell_name, struct cpumask *cpumask)
10761114
{

0 commit comments

Comments
 (0)