LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] thermal: mediatek: Add cpu power cooling model
@ 2015-10-07 12:22 Dawei Chien
  2015-10-07 12:22 ` [PATCH v2 1/2] " Dawei Chien
  2015-10-07 12:22 ` [PATCH v2 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien
  0 siblings, 2 replies; 7+ messages in thread
From: Dawei Chien @ 2015-10-07 12:22 UTC (permalink / raw
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Matthias Brugger, Daniel Kurtz,
	Sascha Hauer, Daniel Lezcano, Dawei Chien, devicetree,
	linux-arm-kernel, linux-kernel, linux-pm, linux-mediatek,
	srv_heupstream, Sascha Hauer

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.

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.

PATCH1 is base on
https://patchwork.kernel.org/patch/7034601/

PATCH2 is base on Sascha's thermal driver V9 https://patchwork.kernel.org/patch/7249821/
https://patchwork.kernel.org/patch/7249861/
https://patchwork.kernel.org/patch/7249891/

Change since V1:
include mt8171.h and sort header file for mt8173.dtsi

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] 7+ messages in thread

* [PATCH v2 1/2] thermal: mediatek: Add cpu power cooling model.
  2015-10-07 12:22 [PATCH v2 0/2] thermal: mediatek: Add cpu power cooling model Dawei Chien
@ 2015-10-07 12:22 ` Dawei Chien
  2015-10-07 15:57   ` Mark Rutland
  2015-10-07 12:22 ` [PATCH v2 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien
  1 sibling, 1 reply; 7+ messages in thread
From: Dawei Chien @ 2015-10-07 12:22 UTC (permalink / raw
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Matthias Brugger, Daniel Kurtz,
	Sascha Hauer, Daniel Lezcano, Dawei Chien, devicetree,
	linux-arm-kernel, linux-kernel, linux-pm, linux-mediatek,
	srv_heupstream, Sascha Hauer

From: "Dawei.Chien" <dawei.chien@mediatek.com>

This power model is base on Intelligent Power Allocation (IPA) technical,
requires that the operating-points of the CPUs are registered using the
kernel's opp library and the `cpufreq_frequency_table` is assigned to the
`struct device` of the cpu MT8173.

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] 7+ messages in thread

* [PATCH v2 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173.
  2015-10-07 12:22 [PATCH v2 0/2] thermal: mediatek: Add cpu power cooling model Dawei Chien
  2015-10-07 12:22 ` [PATCH v2 1/2] " Dawei Chien
@ 2015-10-07 12:22 ` Dawei Chien
  2015-10-07 17:56   ` kbuild test robot
  1 sibling, 1 reply; 7+ messages in thread
From: Dawei Chien @ 2015-10-07 12:22 UTC (permalink / raw
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Matthias Brugger, Daniel Kurtz,
	Sascha Hauer, Daniel Lezcano, Dawei Chien, devicetree,
	linux-arm-kernel, linux-kernel, linux-pm, linux-mediatek,
	srv_heupstream, Sascha Hauer

From: "Dawei.Chien" <dawei.chien@mediatek.com>

Add thermal zone node to mt8173.dtsi.

Signed-off-by: Dawei.Chien <dawei.chien@mediatek.com>
---
This patch is base on
https://patchwork.kernel.org/patch/7249821/
https://patchwork.kernel.org/patch/7249861/
https://patchwork.kernel.org/patch/7249891/
---
 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 3b18f37..01a7c46c 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -16,6 +16,7 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/power/mt8173-power.h>
 #include <dt-bindings/reset-controller/mt8173-resets.h>
+#include <dt-bindings/thermal/mt8173.h>
 #include "mt8173-pinfunc.h"
 
 / {
@@ -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@0 {
+					temperature = <68000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
+				target: trip-point@1 {
+					temperature = <85000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
+				cpu_crit: cpu_crit@0 {
+					temperature = <115000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+
+			cooling-maps {
+				map@0 {
+					trip = <&target>;
+					cooling-device = <&cpu0 0 0>;
+					contribution = <1024>;
+				};
+				map@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] 7+ messages in thread

* Re: [PATCH v2 1/2] thermal: mediatek: Add cpu power cooling model.
  2015-10-07 12:22 ` [PATCH v2 1/2] " Dawei Chien
@ 2015-10-07 15:57   ` Mark Rutland
  2015-10-12 17:26     ` Punit Agrawal
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Rutland @ 2015-10-07 15:57 UTC (permalink / raw
  To: Dawei Chien
  Cc: Viresh Kumar, Rafael J. Wysocki, Rob Herring, Pawel Moll,
	Ian Campbell, Kumar Gala, Matthias Brugger, Daniel Kurtz,
	Sascha Hauer, Daniel Lezcano, devicetree, linux-arm-kernel,
	linux-kernel, linux-pm, linux-mediatek, srv_heupstream,
	Sascha Hauer

On Wed, Oct 07, 2015 at 08:22:40PM +0800, Dawei Chien wrote:
> From: "Dawei.Chien" <dawei.chien@mediatek.com>
> 
> This power model is base on Intelligent Power Allocation (IPA) technical,
> requires that the operating-points of the CPUs are registered using the
> kernel's opp library and the `cpufreq_frequency_table` is assigned to the
> `struct device` of the cpu MT8173.
> 
> 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},
> +};

This should be described in the DT, rather than necessitating tonnes of
these tables in the kernel.

Mark.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173.
  2015-10-07 12:22 ` [PATCH v2 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien
@ 2015-10-07 17:56   ` kbuild test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kbuild test robot @ 2015-10-07 17:56 UTC (permalink / raw
  To: Dawei Chien
  Cc: kbuild-all, Viresh Kumar, Rafael J. Wysocki, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Matthias Brugger, Daniel Kurtz, Sascha Hauer, Daniel Lezcano,
	Dawei Chien, devicetree, linux-arm-kernel, linux-kernel, linux-pm,
	linux-mediatek, srv_heupstream, Sascha Hauer

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

Hi Dawei.Chien,

[auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: arm64-allmodconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All errors (new ones prefixed by >>):

   In file included from arch/arm64/boot/dts/mediatek/mt8173-evb.dts:16:0:
>> arch/arm64/boot/dts/mediatek/mt8173.dtsi:19:40: fatal error: dt-bindings/thermal/mt8173.h: No such file or directory
    #include <dt-bindings/thermal/mt8173.h>
                                           ^
   compilation terminated.

vim +19 arch/arm64/boot/dts/mediatek/mt8173.dtsi

    13	
    14	#include <dt-bindings/clock/mt8173-clk.h>
    15	#include <dt-bindings/interrupt-controller/irq.h>
    16	#include <dt-bindings/interrupt-controller/arm-gic.h>
    17	#include <dt-bindings/power/mt8173-power.h>
    18	#include <dt-bindings/reset-controller/mt8173-resets.h>
  > 19	#include <dt-bindings/thermal/mt8173.h>
    20	#include "mt8173-pinfunc.h"
    21	
    22	/ {

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 45525 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] thermal: mediatek: Add cpu power cooling model.
  2015-10-07 15:57   ` Mark Rutland
@ 2015-10-12 17:26     ` Punit Agrawal
  2015-10-15 11:31       ` dawei chien
  0 siblings, 1 reply; 7+ messages in thread
From: Punit Agrawal @ 2015-10-12 17:26 UTC (permalink / raw
  To: Mark Rutland
  Cc: Dawei Chien, Viresh Kumar, Rafael J. Wysocki, Rob Herring,
	Pawel Moll, Ian Campbell, Kumar Gala, Matthias Brugger,
	Daniel Kurtz, Sascha Hauer, Daniel Lezcano, devicetree,
	linux-arm-kernel, linux-kernel, linux-pm, linux-mediatek,
	srv_heupstream, Sascha Hauer

Mark Rutland <mark.rutland@arm.com> writes:

> On Wed, Oct 07, 2015 at 08:22:40PM +0800, Dawei Chien wrote:
>> From: "Dawei.Chien" <dawei.chien@mediatek.com>
>> 
>> This power model is base on Intelligent Power Allocation (IPA) technical,
>> requires that the operating-points of the CPUs are registered using the
>> kernel's opp library and the `cpufreq_frequency_table` is assigned to the
>> `struct device` of the cpu MT8173.
>> 
>> 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},
>> +};
>
> This should be described in the DT, rather than necessitating tonnes of
> these tables in the kernel.

The above table is a simplification that is tying the static power of a
device to a voltage (indirectly via frequency for ease of indexing
perhaps).

We should definitely look at describing the static power model in the
device tree - but it is not entirely clear what is the best model to
use as basis for the device tree bindings.

Static power consumption depends on a few different parameters (silicon
process, voltage, temperature, etc.). The relationship between them
maybe non-linear and not all of these maybe significant for a given
platform. e.g., for Juno, we are using a regression based on voltage and
temperature which was deemed close enough (very subjective tbh).

On the other hand, dynamic power consumption is somewhat simpler and I
have patches[0][1][2] enabling it's description in device tree. Your comments
there would be very much appreciated.

As for this patch, I hope it can be moved to using the device tree when
the bindings for static power are agreed upon. Although sub-optimal, I
can't see any other way forward for now.

[0] http://thread.gmane.org/gmane.linux.kernel/2011466/focus=130373
[1] http://thread.gmane.org/gmane.linux.kernel/2011466/focus=2011465
[2] http://article.gmane.org/gmane.linux.drivers.sensors/37859

>
> Mark.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] thermal: mediatek: Add cpu power cooling model.
  2015-10-12 17:26     ` Punit Agrawal
@ 2015-10-15 11:31       ` dawei chien
  0 siblings, 0 replies; 7+ messages in thread
From: dawei chien @ 2015-10-15 11:31 UTC (permalink / raw
  To: Punit Agrawal
  Cc: Mark Rutland, Viresh Kumar, Rafael J. Wysocki, Rob Herring,
	Pawel Moll, Ian Campbell, Kumar Gala, Matthias Brugger,
	Daniel Kurtz, Sascha Hauer, Daniel Lezcano, devicetree,
	linux-arm-kernel, linux-kernel, linux-pm, linux-mediatek,
	srv_heupstream, Sascha Hauer

On Mon, 2015-10-12 at 18:26 +0100, Punit Agrawal wrote:
> Mark Rutland <mark.rutland@arm.com> writes:
> 
> > On Wed, Oct 07, 2015 at 08:22:40PM +0800, Dawei Chien wrote:
> >> From: "Dawei.Chien" <dawei.chien@mediatek.com>
> >> 
> >> This power model is base on Intelligent Power Allocation (IPA) technical,
> >> requires that the operating-points of the CPUs are registered using the
> >> kernel's opp library and the `cpufreq_frequency_table` is assigned to the
> >> `struct device` of the cpu MT8173.
> >> 
> >> 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},
> >> +};
> >
> > This should be described in the DT, rather than necessitating tonnes of
> > these tables in the kernel.
> 
> The above table is a simplification that is tying the static power of a
> device to a voltage (indirectly via frequency for ease of indexing
> perhaps).
> 
> We should definitely look at describing the static power model in the
> device tree - but it is not entirely clear what is the best model to
> use as basis for the device tree bindings.
> 
> Static power consumption depends on a few different parameters (silicon
> process, voltage, temperature, etc.). The relationship between them
> maybe non-linear and not all of these maybe significant for a given
> platform. e.g., for Juno, we are using a regression based on voltage and
> temperature which was deemed close enough (very subjective tbh).
> 
> On the other hand, dynamic power consumption is somewhat simpler and I
> have patches[0][1][2] enabling it's description in device tree. Your comments
> there would be very much appreciated.
> 
> As for this patch, I hope it can be moved to using the device tree when
> the bindings for static power are agreed upon. Although sub-optimal, I
> can't see any other way forward for now.
> 
> [0] http://thread.gmane.org/gmane.linux.kernel/2011466/focus=130373
> [1] http://thread.gmane.org/gmane.linux.kernel/2011466/focus=2011465
> [2] http://article.gmane.org/gmane.linux.drivers.sensors/37859

Hi Mark/Punit,
Thank you for your nice comments. I will resend this patch with device tree for dynamic/static power model,
and refer to Punit's patches, thank you.

> >
> > Mark.
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-15 11:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-07 12:22 [PATCH v2 0/2] thermal: mediatek: Add cpu power cooling model Dawei Chien
2015-10-07 12:22 ` [PATCH v2 1/2] " Dawei Chien
2015-10-07 15:57   ` Mark Rutland
2015-10-12 17:26     ` Punit Agrawal
2015-10-15 11:31       ` dawei chien
2015-10-07 12:22 ` [PATCH v2 2/2] arm64: dts: mt8173: Add thermal zone node for mt8173 Dawei Chien
2015-10-07 17:56   ` kbuild test robot

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 read-only IMAP folder(s) and NNTP newsgroup(s).