Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq,arm,arm64: restructure definitions of arch_set_freq_scale()

Compared to other arch_* functions, arch_set_freq_scale() has an atypical
weak definition that can be replaced by a strong architecture specific
implementation.

The more typical support for architectural functions involves defining
an empty stub in a header file if the symbol is not already defined in
architecture code. Some examples involve:
- #define arch_scale_freq_capacity topology_get_freq_scale
- #define arch_scale_freq_invariant topology_scale_freq_invariant
- #define arch_scale_cpu_capacity topology_get_cpu_scale
- #define arch_update_cpu_topology topology_update_cpu_topology
- #define arch_scale_thermal_pressure topology_get_thermal_pressure
- #define arch_set_thermal_pressure topology_set_thermal_pressure

Bring arch_set_freq_scale() in line with these functions by renaming it to
topology_set_freq_scale() in the arch topology driver, and by defining the
arch_set_freq_scale symbol to point to the new function for arm and arm64.

While there are other users of the arch_topology driver, this patch defines
arch_set_freq_scale for arm and arm64 only, due to their existing
definitions of arch_scale_freq_capacity. This is the getter function of the
frequency invariance scale factor and without a getter function, the
setter function - arch_set_freq_scale() has not purpose.

Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com> (BL_SWITCHER and topology parts)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Ionela Voinescu and committed by
Rafael J. Wysocki
a20b7053 efad4240

+14 -12
+1
arch/arm/include/asm/topology.h
··· 8 8 #include <linux/arch_topology.h> 9 9 10 10 /* Replace task scheduler's default frequency-invariant accounting */ 11 + #define arch_set_freq_scale topology_set_freq_scale 11 12 #define arch_scale_freq_capacity topology_get_freq_scale 12 13 #define arch_scale_freq_invariant topology_scale_freq_invariant 13 14
+1
arch/arm64/include/asm/topology.h
··· 26 26 #endif /* CONFIG_ARM64_AMU_EXTN */ 27 27 28 28 /* Replace task scheduler's default frequency-invariant accounting */ 29 + #define arch_set_freq_scale topology_set_freq_scale 29 30 #define arch_scale_freq_capacity topology_get_freq_scale 30 31 #define arch_scale_freq_invariant topology_scale_freq_invariant 31 32
+2 -2
drivers/base/arch_topology.c
··· 33 33 } 34 34 DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; 35 35 36 - void arch_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq, 37 - unsigned long max_freq) 36 + void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq, 37 + unsigned long max_freq) 38 38 { 39 39 unsigned long scale; 40 40 int i;
-7
drivers/cpufreq/cpufreq.c
··· 160 160 } 161 161 EXPORT_SYMBOL_GPL(get_cpu_idle_time); 162 162 163 - __weak void arch_set_freq_scale(const struct cpumask *cpus, 164 - unsigned long cur_freq, 165 - unsigned long max_freq) 166 - { 167 - } 168 - EXPORT_SYMBOL_GPL(arch_set_freq_scale); 169 - 170 163 /* 171 164 * This is a generic cpufreq init() routine which can be used by cpufreq 172 165 * drivers of SMP systems. It will do following:
+2
include/linux/arch_topology.h
··· 30 30 return per_cpu(freq_scale, cpu); 31 31 } 32 32 33 + void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq, 34 + unsigned long max_freq); 33 35 bool topology_scale_freq_invariant(void); 34 36 35 37 bool arch_freq_counters_available(const struct cpumask *cpus);
+8 -3
include/linux/cpufreq.h
··· 1011 1011 extern void arch_freq_prepare_all(void); 1012 1012 extern unsigned int arch_freq_get_on_cpu(int cpu); 1013 1013 1014 - extern void arch_set_freq_scale(const struct cpumask *cpus, 1015 - unsigned long cur_freq, 1016 - unsigned long max_freq); 1014 + #ifndef arch_set_freq_scale 1015 + static __always_inline 1016 + void arch_set_freq_scale(const struct cpumask *cpus, 1017 + unsigned long cur_freq, 1018 + unsigned long max_freq) 1019 + { 1020 + } 1021 + #endif 1017 1022 1018 1023 /* the following are really really optional */ 1019 1024 extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;