diff mbox series

[v15,2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask

Message ID 1630658364-6192-3-git-send-email-hector.yuan@mediatek.com (mailing list archive)
State New, archived
Delegated to: viresh kumar
Headers show
Series [v15,1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW | expand

Commit Message

Hector Yuan Sept. 3, 2021, 8:39 a.m. UTC
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(-)

Comments

kernel test robot Sept. 4, 2021, 10:32 p.m. UTC | #1
Hi Hector,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on soc/for-next]
[also build test WARNING on robh/for-next v5.14]
[cannot apply to pm/linux-next next-20210903]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: i386-randconfig-r002-20210903 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1104e3258b5064e7110cc297e2cec60ac9acfc0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/47a2ae7200a52148136871a5a9c85eadd4c6c620
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
        git checkout 47a2ae7200a52148136871a5a9c85eadd4c6c620
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
                                                                            ^
   include/linux/node.h:177:32: warning: unused parameter 'unreg' [-Wunused-parameter]
                                                   node_registration_func_t unreg)
                                                                            ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   In file included from include/linux/cpufreq.h:17:
   In file included from include/linux/of_device.h:5:
   In file included from include/linux/cpu.h:20:
   include/linux/cpuhotplug.h:417:55: warning: unused parameter 'state' [-Wunused-parameter]
   static inline void cpuhp_online_idle(enum cpuhp_state state) { }
                                                         ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   In file included from include/linux/cpufreq.h:17:
   In file included from include/linux/of_device.h:5:
   include/linux/cpu.h:111:40: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline int add_cpu(unsigned int cpu) { return 0;}
                                          ^
   include/linux/cpu.h:142:43: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline int remove_cpu(unsigned int cpu) { return -EPERM; }
                                             ^
   include/linux/cpu.h:143:59: warning: unused parameter 'primary_cpu' [-Wunused-parameter]
   static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
                                                             ^
   include/linux/cpu.h:226:41: warning: unused parameter 'force' [-Wunused-parameter]
   static inline void cpu_smt_disable(bool force) { }
                                           ^
   include/linux/cpu.h:230:60: warning: unused parameter 'ctrlval' [-Wunused-parameter]
   static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; }
                                                              ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   In file included from include/linux/cpufreq.h:17:
   In file included from include/linux/of_device.h:6:
   include/linux/platform_device.h:353:71: warning: unused parameter 'pdev' [-Wunused-parameter]
   static inline int is_sh_early_platform_device(struct platform_device *pdev)
                                                                         ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   include/linux/cpufreq.h:190:71: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
                                                                         ^
   include/linux/cpufreq.h:194:67: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
                                                                     ^
   include/linux/cpufreq.h:198:59: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_cpu_put(struct cpufreq_policy *policy) { }
                                                             ^
   include/linux/cpufreq.h:232:53: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_get(unsigned int cpu)
                                                       ^
   include/linux/cpufreq.h:236:59: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_quick_get(unsigned int cpu)
                                                             ^
   include/linux/cpufreq.h:240:63: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_quick_get_max(unsigned int cpu)
                                                                 ^
   include/linux/cpufreq.h:244:65: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_get_hw_max_freq(unsigned int cpu)
                                                                   ^
   include/linux/cpufreq.h:261:70: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_stats_create_table(struct cpufreq_policy *policy) { }
                                                                        ^
   include/linux/cpufreq.h:262:68: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_stats_free_table(struct cpufreq_policy *policy) { }
                                                                      ^
   include/linux/cpufreq.h:263:75: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
                                                                             ^
   include/linux/cpufreq.h:264:23: warning: unused parameter 'new_freq' [-Wunused-parameter]
                                                      unsigned int new_freq) { }
                                                                   ^
   include/linux/cpufreq.h:500:68: warning: unused parameter 'nb' [-Wunused-parameter]
   static inline int cpufreq_register_notifier(struct notifier_block *nb,
                                                                      ^
   include/linux/cpufreq.h:501:20: warning: unused parameter 'list' [-Wunused-parameter]
                                                   unsigned int list)
                                                                ^
   include/linux/cpufreq.h:505:70: warning: unused parameter 'nb' [-Wunused-parameter]
   static inline int cpufreq_unregister_notifier(struct notifier_block *nb,
                                                                        ^
   include/linux/cpufreq.h:506:20: warning: unused parameter 'list' [-Wunused-parameter]
                                                   unsigned int list)
                                                                ^
   include/linux/cpufreq.h:676:64: warning: unused parameter 'dev' [-Wunused-parameter]
   static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
                                                                  ^
   include/linux/cpufreq.h:678:9: warning: unused parameter 'table' [-Wunused-parameter]
                                                   **table)
                                                     ^
   include/linux/cpufreq.h:683:65: warning: unused parameter 'dev' [-Wunused-parameter]
   static inline void dev_pm_opp_free_cpufreq_table(struct device *dev,
                                                                   ^
   include/linux/cpufreq.h:685:10: warning: unused parameter 'table' [-Wunused-parameter]
                                                    **table)
                                                      ^
   include/linux/cpufreq.h:1038:51: warning: unused parameter 'state' [-Wunused-parameter]
   static inline int cpufreq_boost_trigger_state(int state)
                                                     ^
   include/linux/cpufreq.h:1052:65: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
                                                                   ^
>> include/linux/cpufreq.h:1057:58: warning: unused parameter 'pcpu' [-Wunused-parameter]
   static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
                                                            ^
>> include/linux/cpufreq.h:1057:76: warning: unused parameter 'list_name' [-Wunused-parameter]
   static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
                                                                              ^
>> include/linux/cpufreq.h:1058:24: warning: unused parameter 'cell_name' [-Wunused-parameter]
                                                        const char *cell_name, struct cpumask *cpumask)
                                                                    ^
>> include/linux/cpufreq.h:1058:51: warning: unused parameter 'cpumask' [-Wunused-parameter]
                                                        const char *cell_name, struct cpumask *cpumask)
                                                                                               ^
   include/linux/cpufreq.h:1068:73: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void sched_cpufreq_governor_change(struct cpufreq_policy *policy,
                                                                           ^
   include/linux/cpufreq.h:1069:29: warning: unused parameter 'old_gov' [-Wunused-parameter]
                           struct cpufreq_governor *old_gov) { }
                                                    ^
   include/linux/cpufreq.h:1077:48: warning: unused parameter 'cpus' [-Wunused-parameter]
   void arch_set_freq_scale(const struct cpumask *cpus,
                                                  ^
   include/linux/cpufreq.h:1078:19: warning: unused parameter 'cur_freq' [-Wunused-parameter]
                            unsigned long cur_freq,
                                          ^
   include/linux/cpufreq.h:1079:19: warning: unused parameter 'max_freq' [-Wunused-parameter]
                            unsigned long max_freq)
                                          ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:5:
   include/linux/context_tracking_state.h:51:53: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline bool context_tracking_enabled_cpu(int cpu) { return false; }
                                                       ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   include/linux/vtime.h:28:57: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_user_enter(struct task_struct *tsk) { }
                                                           ^
   include/linux/vtime.h:29:56: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_user_exit(struct task_struct *tsk) { }
                                                          ^
   include/linux/vtime.h:30:58: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_guest_enter(struct task_struct *tsk) { }
                                                            ^
   include/linux/vtime.h:31:57: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_guest_exit(struct task_struct *tsk) { }
                                                           ^
   include/linux/vtime.h:32:56: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
                                                          ^
   include/linux/vtime.h:32:65: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
                                                                   ^
   include/linux/vtime.h:41:58: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { }
                                                            ^
   include/linux/vtime.h:41:76: warning: unused parameter 'offset' [-Wunused-parameter]
   static inline void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { }
                                                                              ^
   include/linux/vtime.h:42:62: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_account_softirq(struct task_struct *tsk) { }
                                                                ^
   include/linux/vtime.h:43:62: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_account_hardirq(struct task_struct *tsk) { }
                                                                ^
   include/linux/vtime.h:44:52: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_flush(struct task_struct *tsk) { }
                                                      ^
   include/linux/vtime.h:117:58: warning: unused parameter 'prev' [-Wunused-parameter]
   static inline void vtime_task_switch(struct task_struct *prev) { }
                                                            ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   In file included from include/linux/interrupt.h:20:
   In file included from arch/x86/include/asm/sections.h:7:
   include/asm-generic/sections.h:70:53: warning: unused parameter 'addr' [-Wunused-parameter]
   static inline int arch_is_kernel_text(unsigned long addr)
                                                       ^
   include/asm-generic/sections.h:77:53: warning: unused parameter 'addr' [-Wunused-parameter]
   static inline int arch_is_kernel_data(unsigned long addr)
                                                       ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   include/linux/interrupt.h:346:49: warning: unused parameter 'irq' [-Wunused-parameter]
   static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
                                                   ^
   include/linux/interrupt.h:346:76: warning: unused parameter 'm' [-Wunused-parameter]
   static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
                                                                              ^
   include/linux/interrupt.h:351:51: warning: unused parameter 'irq' [-Wunused-parameter]
   static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
                                                     ^
   include/linux/interrupt.h:351:78: warning: unused parameter 'cpumask' [-Wunused-parameter]
   static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
                                                                                ^
   include/linux/interrupt.h:356:53: warning: unused parameter 'irq' [-Wunused-parameter]
   static inline int irq_can_set_affinity(unsigned int irq)
                                                       ^
   include/linux/interrupt.h:361:52: warning: unused parameter 'irq' [-Wunused-parameter]


vim +/pcpu +1057 include/linux/cpufreq.h

  1000	
  1001	static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
  1002							     const char *cell_name, struct cpumask *cpumask)
  1003	{
  1004		struct device_node *cpu_np;
  1005		struct of_phandle_args args;
  1006		int target_idx;
  1007		int cpu, ret;
  1008	
  1009		cpu_np = of_cpu_device_node_get(pcpu);
  1010		of_parse_phandle_with_args(cpu_np, list_name,
  1011					   cell_name, 0, &args);
  1012		of_node_put(cpu_np);
  1013		target_idx = args.args[0];
  1014	
  1015		for_each_possible_cpu(cpu) {
  1016			if (cpu == pcpu)
  1017				continue;
  1018	
  1019			cpu_np = of_cpu_device_node_get(cpu);
  1020			if (!cpu_np)
  1021				continue;
  1022	
  1023			ret = of_parse_phandle_with_args(cpu_np, list_name,
  1024							 cell_name, 0,
  1025							 &args);
  1026	
  1027			of_node_put(cpu_np);
  1028			if (ret < 0)
  1029				continue;
  1030	
  1031			if (target_idx == args.args[0])
  1032				cpumask_set_cpu(cpu, cpumask);
  1033		}
  1034	
  1035		return target_idx;
  1036	}
  1037	#else
> 1038	static inline int cpufreq_boost_trigger_state(int state)
  1039	{
  1040		return 0;
  1041	}
  1042	static inline int cpufreq_boost_enabled(void)
  1043	{
  1044		return 0;
  1045	}
  1046	
  1047	static inline int cpufreq_enable_boost_support(void)
  1048	{
  1049		return -EINVAL;
  1050	}
  1051	
> 1052	static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
  1053	{
  1054		return false;
  1055	}
  1056	
> 1057	static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
> 1058							     const char *cell_name, struct cpumask *cpumask)
  1059	{
  1060		return -EOPNOTSUPP;
  1061	}
  1062	#endif
  1063	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Viresh Kumar Sept. 6, 2021, 9:43 a.m. UTC | #2
On 03-09-21, 16:39, Hector Yuan wrote:
> 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(-)

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
Hector Yuan Sept. 6, 2021, 1:11 p.m. UTC | #3
On Mon, 2021-09-06 at 15:13 +0530, Viresh Kumar wrote:
> On 03-09-21, 16:39, Hector Yuan wrote:
> > 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(-)
> 
> To speed things up, I have applied this with following changes.
> Please
> test my branch and see if something breaks:
> 
> 
https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git/log/?h=cpufreq*arm*linux-next__;Ly8!!CTRNKA9wMg0ARbw!1FkaXVRm8cyf4CDTMMNDmFZ3X8eLd3gf1jK92brq9m-OryGK_peVZW963ettt0DF588$
>  
> 
Hi, Viresh:

I've tested the code in your branch and its okay. Thanks for the review
and your guideness. Thanks.
diff mbox series

Patch

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;