lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210906094309.rcacbme27zpvdd4a@vireshk-i7>
Date:   Mon, 6 Sep 2021 15:13:09 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     Hector Yuan <hector.yuan@...iatek.com>
Cc:     linux-mediatek@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org, linux-pm@...r.kernel.org,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Rob Herring <robh+dt@...nel.org>, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, wsd_upstream@...iatek.com
Subject: Re: [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask

On 03-09-21, 16:39, Hector Yuan wrote:
> From: "Hector.Yuan" <hector.yuan@...iatek.com>
> 
> Add of_perf_domain_get_sharing_cpumask function to group cpu
> to specific performance domain.
> 
> Signed-off-by: Hector.Yuan <hector.yuan@...iatek.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);
        }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ