* thermal: mediatek: Add cpu power cooling model
@ 2015-09-04 9:01 Dawei Chien
2015-09-04 9:01 ` [PATCH 1/2] " Dawei Chien
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Dawei Chien @ 2015-09-04 9:01 UTC (permalink / raw)
To: linux-arm-kernel
Use Intelligent Power Allocation (IPA) technical to add
static/dynamic power model for binding CPU thermal zone.
The power allocator governor allocates power budget to control
CPU temperature.
Dawei.Chien (2):
thermal: mediatek: Add cpu power cooling model.
arm64: dts: mt8173: Add thermal zone node for mt8173.
arch/arm64/boot/dts/mediatek/mt8173.dtsi | 44 ++++++++++++++
drivers/cpufreq/mt8173-cpufreq.c | 97 ++++++++++++++++++++++++++----
2 files changed, 130 insertions(+), 11 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/2] thermal: mediatek: Add cpu power cooling model 2015-09-04 9:01 thermal: mediatek: Add cpu power cooling model Dawei Chien @ 2015-09-04 9:01 ` Dawei Chien 2015-09-04 9:01 ` [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Dawei Chien @ 2015-09-04 9:01 UTC (permalink / raw) To: linux-arm-kernel Use Intelligent Power Allocation (IPA) technical to add static/dynamic power model for binding CPU thermal zone. The power allocator governor allocates power budget to control CPU temperature. Signed-off-by: Dawei Chien <dawei.chien@mediatek.com> --- This patch is base on https://patchwork.kernel.org/patch/7034601/ --- drivers/cpufreq/mt8173-cpufreq.c | 97 +++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c index 49caed2..9233ec5 100644 --- a/drivers/cpufreq/mt8173-cpufreq.c +++ b/drivers/cpufreq/mt8173-cpufreq.c @@ -28,7 +28,8 @@ #define MAX_VOLT_SHIFT (200000) #define MAX_VOLT_LIMIT (1150000) #define VOLT_TOL (10000) - +#define CAPACITANCE_CA53 (263) +#define CAPACITANCE_CA57 (530) /* * The struct mtk_cpu_dvfs_info holds necessary information for doing CPU DVFS * on each CPU power/clock domain of Mediatek SoCs. Each CPU cluster in @@ -51,6 +52,72 @@ struct mtk_cpu_dvfs_info { bool need_voltage_tracking; }; +struct mtk_cpu_static_power { + unsigned long voltage; + unsigned int power; +}; + +/* measured by WA program. */ +static const struct mtk_cpu_static_power mtk_ca53_static_power[] = { + {859000, 43}, + {908000, 52}, + {983000, 86}, + {1009000, 123}, + {1028000, 138}, + {1083000, 172}, + {1109000, 180}, + {1125000, 192}, +}; + +/* measured by WA program. */ +static const struct mtk_cpu_static_power mtk_ca57_static_power[] = { + {828000, 72}, + {867000, 90}, + {927000, 156}, + {968000, 181}, + {1007000, 298}, + {1049000, 435}, + {1089000, 533}, + {1125000, 533}, +}; + +unsigned int mtk_cpufreq_lookup_power(const struct mtk_cpu_static_power *table, + unsigned int count, unsigned long voltage) +{ + int i; + + for (i = 0; i < count; i++) { + if (voltage <= table[i].voltage) + return table[i].power; + } + + return table[count - 1].power; +} + +int mtk_cpufreq_get_static(cpumask_t *cpumask, int interval, + unsigned long voltage, u32 *power) +{ + int nr_cpus = cpumask_weight(cpumask); + + *power = 0; + + if (nr_cpus) { + + if (cpumask_test_cpu(0, cpumask)) + *power += mtk_cpufreq_lookup_power( + mtk_ca53_static_power, + ARRAY_SIZE(mtk_ca53_static_power), + voltage); + + if (cpumask_test_cpu(2, cpumask)) + *power += mtk_cpufreq_lookup_power( + mtk_ca57_static_power, + ARRAY_SIZE(mtk_ca57_static_power), + voltage); + } + return 0; +} + static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info, int new_vproc) { @@ -272,15 +339,21 @@ static void mtk_cpufreq_ready(struct cpufreq_policy *policy) return; if (of_find_property(np, "#cooling-cells", NULL)) { - info->cdev = of_cpufreq_cooling_register(np, - policy->related_cpus); - - if (IS_ERR(info->cdev)) { - dev_err(info->cpu_dev, - "running cpufreq without cooling device: %ld\n", - PTR_ERR(info->cdev)); - - info->cdev = NULL; + u32 capacitance = cpumask_test_cpu(0, policy->related_cpus) ? + CAPACITANCE_CA53 : CAPACITANCE_CA57; + + if (!info->cdev) { + info->cdev = of_cpufreq_power_cooling_register(np, + policy->related_cpus, + capacitance, + mtk_cpufreq_get_static); + + if (IS_ERR(info->cdev)) { + dev_err(info->cpu_dev, + "running cpufreq without cooling device: %ld\n", + PTR_ERR(info->cdev)); + info->cdev = NULL; + } } } @@ -460,7 +533,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy) { struct mtk_cpu_dvfs_info *info = policy->driver_data; - cpufreq_cooling_unregister(info->cdev); + if (info->cdev) + cpufreq_cooling_unregister(info->cdev); + dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table); mtk_cpu_dvfs_info_release(info); kfree(info); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173. 2015-09-04 9:01 thermal: mediatek: Add cpu power cooling model Dawei Chien 2015-09-04 9:01 ` [PATCH 1/2] " Dawei Chien @ 2015-09-04 9:01 ` Dawei Chien 2015-09-07 4:00 ` Daniel Kurtz 2015-09-04 10:00 ` thermal: mediatek: Add cpu power cooling model dawei chien 2015-09-07 6:09 ` Viresh Kumar 3 siblings, 1 reply; 9+ messages in thread From: Dawei Chien @ 2015-09-04 9:01 UTC (permalink / raw) To: linux-arm-kernel Add thermal zone node to mt8173.dtsi. Signed-off-by: Dawei Chien <dawei.chien@mediatek.com> --- This patch is base on following patches https://patchwork.kernel.org/patch/6969581/ https://patchwork.kernel.org/patch/6969571/ https://patchwork.kernel.org/patch/6969381/ --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 208051a..6493bfd 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -17,6 +17,7 @@ #include <dt-bindings/power/mt8173-power.h> #include <dt-bindings/reset-controller/mt8173-resets.h> #include "mt8173-pinfunc.h" +#include <dt-bindings/thermal/thermal.h> / { compatible = "mediatek,mt8173"; @@ -116,6 +117,49 @@ clock-output-names = "clk32k"; }; + thermal-zones { + cpu_thermal: cpu_thermal { + polling-delay-passive = <1000>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + + thermal-sensors = <&thermal MT8173_THERMAL_ZONE_CA57>; + sustainable-power = <1500>; + + trips { + threshold: trip-point at 0 { + temperature = <68000>; + hysteresis = <2000>; + type = "passive"; + }; + + target: trip-point at 1 { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + + cpu_crit: cpu_crit at 0 { + temperature = <115000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + + cooling-maps { + map at 0 { + trip = <&target>; + cooling-device = <&cpu0 0 0>; + contribution = <1024>; + }; + map at 1 { + trip = <&target>; + cooling-device = <&cpu2 0 0>; + contribution = <2048>; + }; + }; + }; + }; + timer { compatible = "arm,armv8-timer"; interrupt-parent = <&gic>; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173. 2015-09-04 9:01 ` [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien @ 2015-09-07 4:00 ` Daniel Kurtz 2015-09-07 4:05 ` Daniel Kurtz 0 siblings, 1 reply; 9+ messages in thread From: Daniel Kurtz @ 2015-09-07 4:00 UTC (permalink / raw) To: linux-arm-kernel Hi Dawei, On Fri, Sep 4, 2015 at 5:01 PM, Dawei Chien <dawei.chien@mediatek.com> wrote: > Add thermal zone node to mt8173.dtsi. > > Signed-off-by: Dawei Chien <dawei.chien@mediatek.com> > --- > This patch is base on following patches > https://patchwork.kernel.org/patch/6969581/ > https://patchwork.kernel.org/patch/6969571/ > https://patchwork.kernel.org/patch/6969381/ > --- > arch/arm64/boot/dts/mediatek/mt8173.dtsi | 44 ++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi > index 208051a..6493bfd 100644 > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi > @@ -17,6 +17,7 @@ > #include <dt-bindings/power/mt8173-power.h> > #include <dt-bindings/reset-controller/mt8173-resets.h> > #include "mt8173-pinfunc.h" > +#include <dt-bindings/thermal/thermal.h> This include is not necessary, however... > > / { > compatible = "mediatek,mt8173"; > @@ -116,6 +117,49 @@ > clock-output-names = "clk32k"; > }; > > + thermal-zones { > + cpu_thermal: cpu_thermal { > + polling-delay-passive = <1000>; /* milliseconds */ > + polling-delay = <1000>; /* milliseconds */ > + > + thermal-sensors = <&thermal MT8173_THERMAL_ZONE_CA57>; this fails to compile, because MT8173_THERMAL_ZONE_CA57 is defined in: include/dt-bindings/thermal/mt8173.h -Dan > + sustainable-power = <1500>; > + > + trips { > + threshold: trip-point at 0 { > + temperature = <68000>; > + hysteresis = <2000>; > + type = "passive"; > + }; > + > + target: trip-point at 1 { > + temperature = <85000>; > + hysteresis = <2000>; > + type = "passive"; > + }; > + > + cpu_crit: cpu_crit at 0 { > + temperature = <115000>; > + hysteresis = <2000>; > + type = "critical"; > + }; > + }; > + > + cooling-maps { > + map at 0 { > + trip = <&target>; > + cooling-device = <&cpu0 0 0>; > + contribution = <1024>; > + }; > + map at 1 { > + trip = <&target>; > + cooling-device = <&cpu2 0 0>; > + contribution = <2048>; > + }; > + }; > + }; > + }; > + > timer { > compatible = "arm,armv8-timer"; > interrupt-parent = <&gic>; > -- > 1.7.9.5 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173. 2015-09-07 4:00 ` Daniel Kurtz @ 2015-09-07 4:05 ` Daniel Kurtz 2015-09-08 15:50 ` dawei chien 0 siblings, 1 reply; 9+ messages in thread From: Daniel Kurtz @ 2015-09-07 4:05 UTC (permalink / raw) To: linux-arm-kernel On Mon, Sep 7, 2015 at 12:00 PM, Daniel Kurtz <djkurtz@chromium.org> wrote: > Hi Dawei, > > On Fri, Sep 4, 2015 at 5:01 PM, Dawei Chien <dawei.chien@mediatek.com> wrote: >> Add thermal zone node to mt8173.dtsi. >> >> Signed-off-by: Dawei Chien <dawei.chien@mediatek.com> >> --- >> This patch is base on following patches >> https://patchwork.kernel.org/patch/6969581/ >> https://patchwork.kernel.org/patch/6969571/ >> https://patchwork.kernel.org/patch/6969381/ >> --- >> arch/arm64/boot/dts/mediatek/mt8173.dtsi | 44 ++++++++++++++++++++++++++++++ >> 1 file changed, 44 insertions(+) >> >> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi >> index 208051a..6493bfd 100644 >> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi >> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi >> @@ -17,6 +17,7 @@ >> #include <dt-bindings/power/mt8173-power.h> >> #include <dt-bindings/reset-controller/mt8173-resets.h> >> #include "mt8173-pinfunc.h" >> +#include <dt-bindings/thermal/thermal.h> Also, as a nit, (#include <dt-bindings/thermal/mt8173.h>) should be above '#include "mt8173-pinfunc.h"' -djk ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173. 2015-09-07 4:05 ` Daniel Kurtz @ 2015-09-08 15:50 ` dawei chien 0 siblings, 0 replies; 9+ messages in thread From: dawei chien @ 2015-09-08 15:50 UTC (permalink / raw) To: linux-arm-kernel Hi Daniel, On Mon, 2015-09-07 at 12:05 +0800, Daniel Kurtz wrote: > On Mon, Sep 7, 2015 at 12:00 PM, Daniel Kurtz <djkurtz@chromium.org> wrote: > > Hi Dawei, > > > > On Fri, Sep 4, 2015 at 5:01 PM, Dawei Chien <dawei.chien@mediatek.com> wrote: > >> Add thermal zone node to mt8173.dtsi. > >> > >> Signed-off-by: Dawei Chien <dawei.chien@mediatek.com> > >> --- > >> This patch is base on following patches > >> https://patchwork.kernel.org/patch/6969581/ > >> https://patchwork.kernel.org/patch/6969571/ > >> https://patchwork.kernel.org/patch/6969381/ > >> --- > >> arch/arm64/boot/dts/mediatek/mt8173.dtsi | 44 ++++++++++++++++++++++++++++++ > >> 1 file changed, 44 insertions(+) > >> > >> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi > >> index 208051a..6493bfd 100644 > >> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi > >> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi > >> @@ -17,6 +17,7 @@ > >> #include <dt-bindings/power/mt8173-power.h> > >> #include <dt-bindings/reset-controller/mt8173-resets.h> > >> #include "mt8173-pinfunc.h" > >> +#include <dt-bindings/thermal/thermal.h> > > Also, as a nit, (#include <dt-bindings/thermal/mt8173.h>) should be > above '#include "mt8173-pinfunc.h"' Thank you, I will resend this patch with mt8171.h and sort header file. > -djk ^ permalink raw reply [flat|nested] 9+ messages in thread
* thermal: mediatek: Add cpu power cooling model 2015-09-04 9:01 thermal: mediatek: Add cpu power cooling model Dawei Chien 2015-09-04 9:01 ` [PATCH 1/2] " Dawei Chien 2015-09-04 9:01 ` [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien @ 2015-09-04 10:00 ` dawei chien 2015-09-07 6:09 ` Viresh Kumar 3 siblings, 0 replies; 9+ messages in thread From: dawei chien @ 2015-09-04 10:00 UTC (permalink / raw) To: linux-arm-kernel Sorry, forgot to add Rafael and Viresh as reviewer. On Fri, 2015-09-04 at 17:01 +0800, Dawei Chien wrote: > Use Intelligent Power Allocation (IPA) technical to add > static/dynamic power model for binding CPU thermal zone. > The power allocator governor allocates power budget to control > CPU temperature. > > Dawei.Chien (2): > thermal: mediatek: Add cpu power cooling model. > arm64: dts: mt8173: Add thermal zone node for mt8173. > > arch/arm64/boot/dts/mediatek/mt8173.dtsi | 44 ++++++++++++++ > drivers/cpufreq/mt8173-cpufreq.c | 97 ++++++++++++++++++++++++++---- > 2 files changed, 130 insertions(+), 11 deletions(-) > > -- > 1.7.9.5 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* thermal: mediatek: Add cpu power cooling model 2015-09-04 9:01 thermal: mediatek: Add cpu power cooling model Dawei Chien ` (2 preceding siblings ...) 2015-09-04 10:00 ` thermal: mediatek: Add cpu power cooling model dawei chien @ 2015-09-07 6:09 ` Viresh Kumar 2015-09-08 15:46 ` dawei chien 3 siblings, 1 reply; 9+ messages in thread From: Viresh Kumar @ 2015-09-07 6:09 UTC (permalink / raw) To: linux-arm-kernel On 04-09-15, 17:01, Dawei Chien wrote: > Use Intelligent Power Allocation (IPA) technical to add > static/dynamic power model for binding CPU thermal zone. > The power allocator governor allocates power budget to control > CPU temperature. Sorry but this isn't enough really.. I don't have time to go through the code and understand the purpose of the series. Please explain here in detail: - Why this is needed. - What/How you are doing it. (Don't resend, just reply to this email :) ) -- viresh ^ permalink raw reply [flat|nested] 9+ messages in thread
* thermal: mediatek: Add cpu power cooling model 2015-09-07 6:09 ` Viresh Kumar @ 2015-09-08 15:46 ` dawei chien 0 siblings, 0 replies; 9+ messages in thread From: dawei chien @ 2015-09-08 15:46 UTC (permalink / raw) To: linux-arm-kernel Hi Viresh, On Mon, 2015-09-07 at 11:39 +0530, Viresh Kumar wrote: > On 04-09-15, 17:01, Dawei Chien wrote: > > Use Intelligent Power Allocation (IPA) technical to add > > static/dynamic power model for binding CPU thermal zone. > > The power allocator governor allocates power budget to control > > CPU temperature. > > Sorry but this isn't enough really.. I don't have time to go through > the code and understand the purpose of the series. > > Please explain here in detail: > - Why this is needed. Power Allocator governor is able to keep SOC temperature within a defined temperature range to avoid SOC overheat and keep it's performance. mt8173-cpufreq.c need to register its' own power model with power allocator thermal governor, so that power allocator governor can allocates suitable power budget to control CPU temperature. > - What/How you are doing it. Measure and create dynamic/static power model, and register cooling device of_cpufreq_power_cooling_register for MT8173. > > (Don't resend, just reply to this email :) ) > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-09-08 15:50 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-04 9:01 thermal: mediatek: Add cpu power cooling model Dawei Chien 2015-09-04 9:01 ` [PATCH 1/2] " Dawei Chien 2015-09-04 9:01 ` [PATCH 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien 2015-09-07 4:00 ` Daniel Kurtz 2015-09-07 4:05 ` Daniel Kurtz 2015-09-08 15:50 ` dawei chien 2015-09-04 10:00 ` thermal: mediatek: Add cpu power cooling model dawei chien 2015-09-07 6:09 ` Viresh Kumar 2015-09-08 15:46 ` dawei chien
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).