Dynamic power model from device tree
Subsystems (2)
v5 cover Dynamic power model from device tree
Hi,
This patchset adds support to build a single-coefficient dynamic power model for a CPU. The model is used by the CPU cooling device to provide an estimate of power consumption and also translate allocated power to performance cap.
Changes from previous posting -
v4 -> v5
Updated tags across the patchesarm_big_little: Do not register cooling devices when in IKS
v3 -> v4:arm_big_little: Migrated to using static arraysarm_big_little: Updated Kconfig to support building thermal as module
Patch 1 extends the CPU nodes binding to provide an optional dynamic power coefficient which can be used to create a dynamic power model for the CPUs. This model is used to constrain device power consumption (using power_allocator governor) when the system is thermally constrained.
Patches 2-3 extends the cpufreq-dt and arm_big_little driver to register cpu cooling devices with the dynamic coefficient when provided.
The patches were previously posted at [0][1][2][3]. Mediatek platform 8173 builds on these bindings to build a power model.
Thanks,
Punit
[0] http://thread.gmane.org/gmane.linux.kernel/2002152
[1] http://thread.gmane.org/gmane.linux.kernel/2011466
[2] http://marc.info/?l=linux-kernel&m=144709020014884&w=2
[3] http://marc.info/?l=linux-pm&m=144770224915315&w=2
Punit Agrawal (3):
devicetree: bindings: Add optional dynamic-power-coefficient property
cpufreq-dt: Supply power coefficient when registering cooling devices
cpufreq: arm_big_little: Add support to register a cpufreq cooling
device
Documentation/devicetree/bindings/arm/cpus.txt | 17 +++++++++++ drivers/cpufreq/Kconfig.arm | 2 ++ drivers/cpufreq/arm_big_little.c | 41 ++++++++++++++++++++++++++ drivers/cpufreq/cpufreq-dt.c | 9 ++++-- 4 files changed, 67 insertions(+), 2 deletions(-)
Signature · 6 lines
2.6.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 1/3 devicetree: bindings: Add optional dynamic-power-coefficient property
The dynamic power consumption of a device is proportional to the square of voltage (V) and the clock frequency (f). It can be expressed as
Pdyn = dynamic-power-coefficient * V^2 * f.
The coefficient represents the running time dynamic power consumption in units of mw/MHz/uVolt^2 and can be used in the above formula to calculate the dynamic power in mW.
--- Documentation/devicetree/bindings/arm/cpus.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/arm/cpus.txt +17 -0
@@ -242,6 +242,23 @@ nodes to be present and contain the properties described below. Definition: Specifies the syscon node controlling the cpu core power domains. + - dynamic-power-coefficient + Usage: optional + Value type: <prop-encoded-array> + Definition: A u32 value that represents the running time dynamic + power coefficient in units of mW/MHz/uVolt^2. The + coefficient can either be calculated from power + measurements or derived by analysis. + + The dynamic power consumption of the CPU is + proportional to the square of the Voltage (V) and + the clock frequency (f). The coefficient is used to + calculate the dynamic power as below - + + Pdyn = dynamic-power-coefficient * V^2 * f + + where voltage is in uV, frequency is in MHz. + Example 1 (dual-cluster big.LITTLE system 32-bit): cpus {
Signature · 1 line
2.6.2
PATCH v5 2/3 cpufreq-dt: Supply power coefficient when registering cooling devices
In reply to Punit AgrawalSupport registering cooling devices with dynamic power coefficient where provided by the device tree. This allows OF registered cooling devices driver to be used with the power_allocator thermal governor.
--- drivers/cpufreq/cpufreq-dt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq-dt.c +7 -2
@@ -407,8 +407,13 @@ static void cpufreq_ready(struct cpufreq_policy *policy)* thermal DT code takes care of matching them. */ if (of_find_property (np,"#cooling-cells" ,NULL )) { - priv->cdev =of_cpufreq_cooling_register (np, - policy->related_cpus); +u32 power_coefficient =0 ; + +of_property_read_u32 (np,"dynamic-power-coefficient" , + &power_coefficient); + + priv->cdev =of_cpufreq_power_cooling_register (np, + policy->related_cpus, power_coefficient,NULL );if (IS_ERR (priv->cdev)) { dev_err(priv->cpu_dev, "running cpufreq without cooling device: %ld\n",
Signature · 1 line
2.6.2
PATCH v5 3/3 cpufreq: arm_big_little: Add support to register a cpufreq cooling device
In reply to Punit AgrawalRegister passive cooling devices when initialising cpufreq on big.LITTLE systems. If the device tree provides a dynamic power coefficient for the CPUs then the bound cooling device will support the extensions that allow it to be used with all the existing thermal governors including the power allocator governor.
A cooling device will be created per individual frequency domain and can be bound to thermal zones via the thermal DT bindings.
--- drivers/cpufreq/Kconfig.arm | 2 ++ drivers/cpufreq/arm_big_little.c | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
drivers/cpufreq/Kconfig.arm +2 -0
@@ -6,6 +6,8 @@ config ARM_BIG_LITTLE_CPUFREQ tristate "Generic ARM big LITTLE CPUfreq driver" depends on (ARM_CPU_TOPOLOGY || ARM64) && HAVE_CLK + # if CPU_THERMAL is on and THERMAL=m, ARM_BIT_LITTLE_CPUFREQ cannot be =y + depends on !CPU_THERMAL || THERMAL select PM_OPP help This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.
drivers/cpufreq/arm_big_little.c +41 -0
71 lines not on this page · raw message
Signature · 1 line
2.6.2
Re: [PATCH v5 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device
Quoted 104 lines · Punit Agrawal
Register passive cooling devices when initialising cpufreq on big.LITTLE systems. If the device tree provides a dynamic power coefficient for the CPUs then the bound cooling device will support the extensions that allow it to be used with all the existing thermal governors including the power allocator governor.
A cooling device will be created per individual frequency domain and can be bound to thermal zones via the thermal DT bindings.
Signed-off-by Punit Agrawal <[email protected]>Cc Viresh Kumar <[email protected]>Cc Sudeep Holla <[email protected]>Cc Eduardo Valentin <[email protected]>--- drivers/cpufreq/Kconfig.arm | 2 ++ drivers/cpufreq/arm_big_little.c | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)drivers/cpufreq/Kconfig.arm +2
-0@@ -6,6 +6,8 @@ config ARM_BIG_LITTLE_CPUFREQ tristate "Generic ARM big LITTLE CPUfreq driver" depends on (ARM_CPU_TOPOLOGY || ARM64) && HAVE_CLK + # if CPU_THERMAL is on and THERMAL=m, ARM_BIT_LITTLE_CPUFREQ cannot be =y + depends on !CPU_THERMAL || THERMAL select PM_OPP help This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.drivers/cpufreq/arm_big_little.c +40
-0@@ -23,6 +23,7 @@#include <linux/cpu.h> #include <linux/cpufreq.h> #include <linux/cpumask.h> +#include <linux/cpu_cooling.h> #include <linux/export.h> #include <linux/module.h> #include <linux/mutex.h> @@ -55,6 +56,7 @@ static bool bL_switching_enabled;#define ACTUAL_FREQ (cluster, freq) ((cluster == A7_CLUSTER) ? freq << 1 : freq)#define VIRT_FREQ (cluster, freq) ((cluster == A7_CLUSTER) ? freq >> 1 : freq) +static struct thermal_cooling_device *cdev[MAX_CLUSTERS ];static struct cpufreq_arm_bL_ops *arm_bL_ops;static struct clk *clk[MAX_CLUSTERS ];static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS +1 ];@@ -493,6 +495,12 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)static int bL_cpufreq_exit (struct cpufreq_policy *policy) {struct device *cpu_dev; +int cur_cluster =cpu_to_cluster (policy->cpu); + +if (cur_cluster <MAX_CLUSTERS ) { +cpufreq_cooling_unregister (cdev[cur_cluster]); + cdev[cur_cluster] =NULL ; + } cpu_dev =get_cpu_device (policy->cpu);if (!cpu_dev) {@@ -507,6 +515,38 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)return 0 ; } +static void bL_cpufreq_ready (struct cpufreq_policy *policy) +{ +struct device *cpu_dev =get_cpu_device (policy->cpu); +int cur_cluster =cpu_to_cluster (policy->cpu); +struct device_node *np; + +/* Do not register a cpu_cooling device if we are in IKS mode */ +if (cur_cluster >=MAX_CLUSTERS ) +return ; + + np =of_node_get (cpu_dev->of_node); +if (WARN_ON (!np)) +return ; + +if (of_find_property (np,"#cooling-cells" ,NULL )) { +u32 power_coefficient =0 ; + +of_property_read_u32 (np,"dynamic-power-coefficient" , + &power_coefficient); + + cdev[cur_cluster] =of_cpufreq_power_cooling_register (np, + policy->related_cpus, power_coefficient,NULL ); +if (IS_ERR (cdev[cur_cluster])) { +dev_err (cpu_dev, +"running cpufreq without cooling device: %ld\n" , +PTR_ERR (cdev[cur_cluster])); + cdev[cur_cluster] =NULL ; + } + } +of_node_put (np); +} +static struct cpufreq_driver bL_cpufreq_driver = { .name ="arm-big-little" , .flags = CPUFREQ_STICKY |
drivers/cpufreq/arm_big_little.c static struct cpufreq_driver bL_cpufreq_driver = { · line 562
Quoted 6 lines
drivers/cpufreq/arm_big_little.c +1
-0@@ -517,6 +557,7 @@ static struct cpufreq_driver bL_cpufreq_driver = { .get = bL_cpufreq_get_rate, .init = bL_cpufreq_init, .exit = bL_cpufreq_exit, + .ready = bL_cpufreq_ready, .attr = cpufreq_generic_attr, };
Signature · 1 line
viresh
Re: [PATCH v5 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device
Quoted 105 lines · Viresh Kumar
Quoted 104 lines · Punit Agrawal
Register passive cooling devices when initialising cpufreq on big.LITTLE systems. If the device tree provides a dynamic power coefficient for the CPUs then the bound cooling device will support the extensions that allow it to be used with all the existing thermal governors including the power allocator governor.
A cooling device will be created per individual frequency domain and can be bound to thermal zones via the thermal DT bindings.
Signed-off-by Punit Agrawal <[email protected]>Cc Viresh Kumar <[email protected]>Cc Sudeep Holla <[email protected]>Cc Eduardo Valentin <[email protected]>--- drivers/cpufreq/Kconfig.arm | 2 ++ drivers/cpufreq/arm_big_little.c | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)drivers/cpufreq/Kconfig.arm +2
-0@@ -6,6 +6,8 @@ config ARM_BIG_LITTLE_CPUFREQ tristate "Generic ARM big LITTLE CPUfreq driver" depends on (ARM_CPU_TOPOLOGY || ARM64) && HAVE_CLK + # if CPU_THERMAL is on and THERMAL=m, ARM_BIT_LITTLE_CPUFREQ cannot be =y + depends on !CPU_THERMAL || THERMAL select PM_OPP help This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.drivers/cpufreq/arm_big_little.c +40
-0@@ -23,6 +23,7 @@#include <linux/cpu.h> #include <linux/cpufreq.h> #include <linux/cpumask.h> +#include <linux/cpu_cooling.h> #include <linux/export.h> #include <linux/module.h> #include <linux/mutex.h> @@ -55,6 +56,7 @@ static bool bL_switching_enabled;#define ACTUAL_FREQ (cluster, freq) ((cluster == A7_CLUSTER) ? freq << 1 : freq)#define VIRT_FREQ (cluster, freq) ((cluster == A7_CLUSTER) ? freq >> 1 : freq) +static struct thermal_cooling_device *cdev[MAX_CLUSTERS ];static struct cpufreq_arm_bL_ops *arm_bL_ops;static struct clk *clk[MAX_CLUSTERS ];static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS +1 ];@@ -493,6 +495,12 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)static int bL_cpufreq_exit (struct cpufreq_policy *policy) {struct device *cpu_dev; +int cur_cluster =cpu_to_cluster (policy->cpu); + +if (cur_cluster <MAX_CLUSTERS ) { +cpufreq_cooling_unregister (cdev[cur_cluster]); + cdev[cur_cluster] =NULL ; + } cpu_dev =get_cpu_device (policy->cpu);if (!cpu_dev) {@@ -507,6 +515,38 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)return 0 ; } +static void bL_cpufreq_ready (struct cpufreq_policy *policy) +{ +struct device *cpu_dev =get_cpu_device (policy->cpu); +int cur_cluster =cpu_to_cluster (policy->cpu); +struct device_node *np; + +/* Do not register a cpu_cooling device if we are in IKS mode */ +if (cur_cluster >=MAX_CLUSTERS ) +return ; + + np =of_node_get (cpu_dev->of_node); +if (WARN_ON (!np)) +return ; + +if (of_find_property (np,"#cooling-cells" ,NULL )) { +u32 power_coefficient =0 ; + +of_property_read_u32 (np,"dynamic-power-coefficient" , + &power_coefficient); + + cdev[cur_cluster] =of_cpufreq_power_cooling_register (np, + policy->related_cpus, power_coefficient,NULL ); +if (IS_ERR (cdev[cur_cluster])) { +dev_err (cpu_dev, +"running cpufreq without cooling device: %ld\n" , +PTR_ERR (cdev[cur_cluster])); + cdev[cur_cluster] =NULL ; + } + } +of_node_put (np); +} +static struct cpufreq_driver bL_cpufreq_driver = { .name ="arm-big-little" , .flags = CPUFREQ_STICKY |@@ -517,6 +557,7 @@ static struct cpufreq_driver bL_cpufreq_driver = {
Quoted 8 lines
drivers/cpufreq/arm_big_little.c static struct cpufreq_driver bL_cpufreq_driver = { · line 562
Quoted 6 lines
drivers/cpufreq/arm_big_little.c +1
-0.get = bL_cpufreq_get_rate, .init = bL_cpufreq_init, .exit = bL_cpufreq_exit, + .ready = bL_cpufreq_ready, .attr = cpufreq_generic_attr, };Acked-by Viresh Kumar <[email protected]>
Thanks for the Ack.
Will you or Rafael be picking up the series or do they need to go via arm-soc?
Viresh Kumar
maintainerRe: [PATCH v5 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device
Quoted 4 lines · Punit Agrawal
Thanks for the Ack.
Will you or Rafael be picking up the series or do they need to go via arm-soc?
Rafael will pick this up, it should go via PM tree.
Signature · 1 line
viresh
Re: [PATCH v5 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device
Quoted 7 lines · Viresh Kumar
Quoted 4 lines · Punit Agrawal
Thanks for the Ack.
Will you or Rafael be picking up the series or do they need to go via arm-soc?
Rafael will pick this up, it should go via PM tree.
Applied now, thanks!
Rafael