Skip to content

Commit 8486a32

Browse files
Hector.Yuanvireshk
authored andcommitted
cpufreq: Add of_perf_domain_get_sharing_cpumask
Add of_perf_domain_get_sharing_cpumask function to group cpu to specific performance domain. Signed-off-by: Hector.Yuan <[email protected]> [ Viresh: create separate routine parse_perf_domain() and always set the cpumask. ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent a8bbe0c commit 8486a32

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

include/linux/cpufreq.h

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/completion.h>
1515
#include <linux/kobject.h>
1616
#include <linux/notifier.h>
17+
#include <linux/of.h>
18+
#include <linux/of_device.h>
1719
#include <linux/pm_opp.h>
1820
#include <linux/pm_qos.h>
1921
#include <linux/spinlock.h>
@@ -1003,6 +1005,55 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy
10031005

10041006
return count;
10051007
}
1008+
1009+
static inline int parse_perf_domain(int cpu, const char *list_name,
1010+
const char *cell_name)
1011+
{
1012+
struct device_node *cpu_np;
1013+
struct of_phandle_args args;
1014+
int ret;
1015+
1016+
cpu_np = of_cpu_device_node_get(cpu);
1017+
if (!cpu_np)
1018+
return -ENODEV;
1019+
1020+
ret = of_parse_phandle_with_args(cpu_np, list_name, cell_name, 0,
1021+
&args);
1022+
if (ret < 0)
1023+
return ret;
1024+
1025+
of_node_put(cpu_np);
1026+
1027+
return args.args[0];
1028+
}
1029+
1030+
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
1031+
const char *cell_name, struct cpumask *cpumask)
1032+
{
1033+
int target_idx;
1034+
int cpu, ret;
1035+
1036+
ret = parse_perf_domain(pcpu, list_name, cell_name);
1037+
if (ret < 0)
1038+
return ret;
1039+
1040+
target_idx = ret;
1041+
cpumask_set_cpu(pcpu, cpumask);
1042+
1043+
for_each_possible_cpu(cpu) {
1044+
if (cpu == pcpu)
1045+
continue;
1046+
1047+
ret = parse_perf_domain(pcpu, list_name, cell_name);
1048+
if (ret < 0)
1049+
continue;
1050+
1051+
if (target_idx == ret)
1052+
cpumask_set_cpu(cpu, cpumask);
1053+
}
1054+
1055+
return target_idx;
1056+
}
10061057
#else
10071058
static inline int cpufreq_boost_trigger_state(int state)
10081059
{
@@ -1022,6 +1073,12 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
10221073
{
10231074
return false;
10241075
}
1076+
1077+
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
1078+
const char *cell_name, struct cpumask *cpumask)
1079+
{
1080+
return -EOPNOTSUPP;
1081+
}
10251082
#endif
10261083

10271084
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
@@ -1043,7 +1100,6 @@ void arch_set_freq_scale(const struct cpumask *cpus,
10431100
{
10441101
}
10451102
#endif
1046-
10471103
/* the following are really really optional */
10481104
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
10491105
extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;

0 commit comments

Comments
 (0)