From: Hector Yuan <hector.yuan@mediatek.com>
To: <linux-mediatek@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-pm@vger.kernel.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>,
Rob Herring <robh+dt@kernel.org>, <devicetree@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <wsd_upstream@mediatek.com>,
<hector.yuan@mediatek.com>
Subject: [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask
Date: Fri, 3 Sep 2021 16:39:23 +0800 [thread overview]
Message-ID: <1630658364-6192-3-git-send-email-hector.yuan@mediatek.com> (raw)
In-Reply-To: <1630658364-6192-1-git-send-email-hector.yuan@mediatek.com>
From: "Hector.Yuan" <hector.yuan@mediatek.com>
Add of_perf_domain_get_sharing_cpumask function to group cpu
to specific performance domain.
Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
---
include/linux/cpufreq.h | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 9fd7194..0246144 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -13,6 +13,8 @@
#include <linux/completion.h>
#include <linux/kobject.h>
#include <linux/notifier.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/pm_qos.h>
#include <linux/spinlock.h>
#include <linux/sysfs.h>
@@ -995,6 +997,43 @@ 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)
+{
+ struct device_node *cpu_np;
+ struct of_phandle_args args;
+ 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];
+
+ 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);
+ if (ret < 0)
+ continue;
+
+ if (target_idx == args.args[0])
+ cpumask_set_cpu(cpu, cpumask);
+ }
+
+ return target_idx;
+}
#else
static inline int cpufreq_boost_trigger_state(int state)
{
@@ -1014,6 +1053,12 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
{
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
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
@@ -1035,7 +1080,6 @@ void arch_set_freq_scale(const struct cpumask *cpus,
{
}
#endif
-
/* the following are really really optional */
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
--
1.7.9.5
next prev parent reply other threads:[~2021-09-03 8:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 8:39 [PATCH v15] cpufreq: mediatek-hw: Add support for Mediatek cpufreq HW driver Hector Yuan
2021-09-03 8:39 ` [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW Hector Yuan
2021-09-03 16:35 ` Rob Herring
2021-09-03 8:39 ` Hector Yuan [this message]
2021-09-04 22:32 ` [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask kernel test robot
2021-09-06 9:43 ` Viresh Kumar
2021-09-06 13:11 ` Hector Yuan
2021-09-03 8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
2021-09-03 15:54 ` kernel test robot
2021-09-03 16:34 ` kernel test robot
2021-09-06 9:44 ` Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1630658364-6192-3-git-send-email-hector.yuan@mediatek.com \
--to=hector.yuan@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=robh+dt@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=wsd_upstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®