[PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask

Viresh Kumar viresh.kumar at linaro.org
Mon Sep 6 02:43:09 PDT 2021


On 03-09-21, 16:39, Hector Yuan wrote:
> From: "Hector.Yuan" <hector.yuan at mediatek.com>
> 
> Add of_perf_domain_get_sharing_cpumask function to group cpu
> to specific performance domain.
> 
> Signed-off-by: Hector.Yuan <hector.yuan at mediatek.com>
> ---
>  include/linux/cpufreq.h |   46 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 45 insertions(+), 1 deletion(-)

To speed things up, I have applied this with following changes. Please
test my branch and see if something breaks:

https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git/log/?h=cpufreq/arm/linux-next

-- 
viresh

-------------------------8<-------------------------
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 9eb1fa17a8a4..acd3ee5b8b0a 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -1006,37 +1006,49 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy
        return count;
 }

-static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
-                                                    const char *cell_name, struct cpumask *cpumask)
+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;

-       cpu_np = of_cpu_device_node_get(pcpu);
-       of_parse_phandle_with_args(cpu_np, list_name,
-                                  cell_name, 0, &args);
-       of_node_put(cpu_np);
-       target_idx = args.args[0];
+       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;

-               cpu_np = of_cpu_device_node_get(cpu);
-               if (!cpu_np)
-                       continue;
-
-               ret = of_parse_phandle_with_args(cpu_np, list_name,
-                                                cell_name, 0,
-                                                &args);
-
-               of_node_put(cpu_np);
+               ret = parse_perf_domain(pcpu, list_name, cell_name);
                if (ret < 0)
                        continue;

-               if (target_idx == args.args[0])
+               if (target_idx == ret)
                        cpumask_set_cpu(cpu, cpumask);
        }




More information about the linux-arm-kernel mailing list