Commit 8486a32d authored by Hector.Yuan's avatar Hector.Yuan Committed by Viresh Kumar

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: default avatarHector.Yuan <hector.yuan@mediatek.com>
[ Viresh: create separate routine parse_perf_domain() and always set the
	  cpumask. ]
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent a8bbe0c9
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pm_opp.h> #include <linux/pm_opp.h>
#include <linux/pm_qos.h> #include <linux/pm_qos.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -1003,6 +1005,55 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy ...@@ -1003,6 +1005,55 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy
return count; return count;
} }
static inline int parse_perf_domain(int cpu, const char *list_name,
const char *cell_name)
{
struct device_node *cpu_np;
struct of_phandle_args args;
int ret;
cpu_np = of_cpu_device_node_get(cpu);
if (!cpu_np)
return -ENODEV;
ret = of_parse_phandle_with_args(cpu_np, list_name, cell_name, 0,
&args);
if (ret < 0)
return ret;
of_node_put(cpu_np);
return args.args[0];
}
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
const char *cell_name, struct cpumask *cpumask)
{
int target_idx;
int cpu, ret;
ret = parse_perf_domain(pcpu, list_name, cell_name);
if (ret < 0)
return ret;
target_idx = ret;
cpumask_set_cpu(pcpu, cpumask);
for_each_possible_cpu(cpu) {
if (cpu == pcpu)
continue;
ret = parse_perf_domain(pcpu, list_name, cell_name);
if (ret < 0)
continue;
if (target_idx == ret)
cpumask_set_cpu(cpu, cpumask);
}
return target_idx;
}
#else #else
static inline int cpufreq_boost_trigger_state(int state) static inline int cpufreq_boost_trigger_state(int state)
{ {
...@@ -1022,6 +1073,12 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy) ...@@ -1022,6 +1073,12 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
{ {
return false; return false;
} }
static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
const char *cell_name, struct cpumask *cpumask)
{
return -EOPNOTSUPP;
}
#endif #endif
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
...@@ -1043,7 +1100,6 @@ void arch_set_freq_scale(const struct cpumask *cpus, ...@@ -1043,7 +1100,6 @@ void arch_set_freq_scale(const struct cpumask *cpus,
{ {
} }
#endif #endif
/* the following are really really optional */ /* the following are really really optional */
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
......
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