Skip to contentSkip to conversation

thermal: mediatek: Add cpu dynamic power cooling model.

PATCH RESEND In review Dawei Chien 6 participants 13 messages Mar 15, 2016 – Apr 21, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v6 cover thermal: mediatek: Add cpu dynamic power cooling model.

Use Intelligent Power Allocation (IPA) technical to add 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.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V5:
1. Remove thermal sensor ID from phandles

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c 2. Initializing variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models respectively

Change since V2:
1. Move dynamic/static power model in device tree

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

Dawei Chien (3):
thermal: mediatek: Add cpu dynamic power cooling model.
arm64: dts: mt8173: Add thermal zone node.
arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++++++++++++++++++++++++++++++
 drivers/cpufreq/mt8173-cpufreq.c         |   12 ++++++--
 2 files changed, 57 insertions(+), 2 deletions(-)
#1 lore raw

PATCH RESEND v6 1/3 thermal: mediatek: Add cpu dynamic power cooling model.

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251

---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/cpufreq/mt8173-cpufreq.c +9 -2
index 1efba34..d8ad406 100644
@@ -309,17 +309,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
 	return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
 	struct mtk_cpu_dvfs_info *info = policy->driver_data;
 	struct device_node *np = of_node_get(info->cpu_dev->of_node);
+	u32 capacitance = 0;
 
 	if (WARN_ON(!np))
 		return;
 
 	if (of_find_property(np, "#cooling-cells", NULL)) {
-		info->cdev = of_cpufreq_cooling_register(np,
-							 policy->related_cpus);
+		of_property_read_u32(np, DYNAMIC_POWER, &capacitance);
+
+		info->cdev = of_cpufreq_power_cooling_register(np,
+						policy->related_cpus,
+						capacitance,
+						NULL);
 
 		if (IS_ERR(info->cdev)) {
 			dev_err(info->cpu_dev,
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH RESEND v6 2/3 arm64: dts: mt8173: Add thermal zone node.

In reply to Dawei Chien

This adds thermal zone node to Mediatek MT8173 dtsi file.

---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +43 -0
index 47151e8..f9c44cc 100644
@@ -188,6 +188,49 @@
 		clock-output-names = "cpum_ck";
 	};
 
+	thermal-zones {
+		cpu_thermal: cpu_thermal {
+			polling-delay-passive = <1000>; /* milliseconds */
+			polling-delay = <1000>; /* milliseconds */
+
+			thermal-sensors = <&thermal>;
+			sustainable-power = <1500>; /* milliwatts */
+
+			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>;
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH RESEND v6 3/3 arm64: dts: mt8173: Add dynamic power node.

In reply to Dawei Chien

This device node is for calculating dynamic power in mW. Since mt8173 has two clusters, there are two dynamic power coefficient as well.

---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251

---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +4 -0
index f9c44cc..5cb6b4e 100644
@@ -71,6 +71,7 @@
 			#cooling-cells = <2>;
 			#cooling-min-level = <0>;
 			#cooling-max-level = <7>;
+			dynamic-power-coefficient = <263>;
 		};
 
 		cpu1: cpu at 1 {
@@ -95,6 +96,7 @@
 			#cooling-cells = <2>;
 			#cooling-min-level = <0>;
 			#cooling-max-level = <7>;
+			dynamic-power-coefficient = <263>;
 		};
 
 		cpu2: cpu at 100 {
@@ -119,6 +121,7 @@
 			#cooling-cells = <2>;
 			#cooling-min-level = <0>;
 			#cooling-max-level = <7>;
+			dynamic-power-coefficient = <530>;
 		};
 
 		cpu3: cpu at 101 {
@@ -143,6 +146,7 @@
 			#cooling-cells = <2>;
 			#cooling-min-level = <0>;
 			#cooling-max-level = <7>;
+			dynamic-power-coefficient = <530>;
 		};
 
 		idle-states {
Signature · 1 line
1.7.9.5
#3 lore raw
Quoted 10 lines · Viresh Kumar

Hi Rafael,

Quoted 5 lines · Dawei Chien

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

Can you please apply this patch from Dawei ?

I can, but I'm traveling this week, so that's rather going to happen next week.

Thanks,
Rafael

maintainer
#4 lore raw

Hi Rafael,

Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Viresh Kumar

Hi Rafael,

Quoted 3 lines · Dawei Chien

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Can you please apply this patch from Dawei ?

I can, but I'm traveling this week, so that's rather going to happen next week.

I don't see the patch in linux-next, did you forget to pick/push it?

Regards,
Matthias

#5 lore raw
Quoted 13 lines · Matthias Brugger

Hi Rafael,

Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Viresh Kumar

Hi Rafael,

Quoted 5 lines · Dawei Chien

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can you please apply this patch from Dawei ?

I can, but I'm traveling this week, so that's rather going to happen next week.

I don't see the patch in linux-next, did you forget to pick/push it?

No, I didn't. I just didn't have the time to get to them before.

Now, given that they are thermal patches, they really should go in via linux-soc-thermal.git.

Eduardo, any chance to take care of these?

Thanks,
Rafael

#6 lore raw
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · Matthias Brugger

Hi Rafael,

Quoted 14 lines · Rafael J. Wysocki
Quoted 10 lines · Viresh Kumar

Hi Rafael,

Quoted 5 lines · Dawei Chien

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

Can you please apply this patch from Dawei ?

I can, but I'm traveling this week, so that's rather going to happen next week.

Quoted 8 lines
Quoted 1 line

I don't see the patch in linux-next, did you forget to pick/push it?

No, I didn't. I just didn't have the time to get to them before.

Now, given that they are thermal patches, they really should go in via linux-soc-thermal.git.

Eduardo, any chance to take care of these?

Yes I can add this one, given that they have the proper acked-by. I was a bit hesitant to just get them because they are touching drivers/cpufreq.

Anyways, I am adding this to my branch to the next merge window.

Quoted 4 lines

Thanks,
Rafael

#7 lore raw
Quoted 27 lines · Eduardo Valentin
Quoted 26 lines · Rafael J. Wysocki
Quoted 13 lines · Matthias Brugger

Hi Rafael,

Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Viresh Kumar

Hi Rafael,

Quoted 5 lines · Dawei Chien

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can you please apply this patch from Dawei ?

I can, but I'm traveling this week, so that's rather going to happen next week.

I don't see the patch in linux-next, did you forget to pick/push it?

No, I didn't. I just didn't have the time to get to them before.

Now, given that they are thermal patches, they really should go in via linux-soc-thermal.git.

Quoted 7 lines
Quoted 1 line

Eduardo, any chance to take care of these?

Yes I can add this one, given that they have the proper acked-by. I was a bit hesitant to just get them because they are touching drivers/cpufreq.

Anyways, I am adding this to my branch to the next merge window.

Added the driver changes. The dt parts should go via your platform tree. And you can add my

on the dt changes.

Quoted 6 lines
Quoted 6 lines

Thanks,
Rafael

#11 lore raw

Re: [RESEND][PATCH 3/3] arm64: dts: mt8173: Add dynamic power node.

In reply to Dawei Chien
Quoted 8 lines · Dawei Chien (???)

This device node is for calculating dynamic power in mW. Since mt8173 has two clusters, there are two dynamic power coefficient as well.

---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251

Sorry for miss one dependence for this device node.
https://lkml.org/lkml/2015/7/9/206

Quoted 43 lines
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +4 -1
index f9c44cc..5cb6b4e 100644
@@ -71,6 +71,7 @@
                        #cooling-cells = <2>;
                        #cooling-min-level = <0>;
                        #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <263>;
                };
 
                cpu1: cpu at 1 {
@@ -95,6 +96,7 @@
                        #cooling-cells = <2>;
                        #cooling-min-level = <0>;
                        #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <263>;
                };
 
                cpu2: cpu at 100 {
@@ -119,6 +121,7 @@
                        #cooling-cells = <2>;
                        #cooling-min-level = <0>;
                        #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <530>;
                };
 
                cpu3: cpu at 101 {
@@ -143,6 +146,7 @@
                        #cooling-cells = <2>;
                        #cooling-min-level = <0>;
                        #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <530>;
                };
 
                idle-states {
--

1.7.9.5

maintainer
#12 lore raw

Re: [RESEND][PATCH 3/3] arm64: dts: mt8173: Add dynamic power node.

Quoted 5 lines · dawei chien
Quoted 4 lines · Dawei Chien (???)

This device node is for calculating dynamic power in mW. Since mt8173 has two clusters, there are two dynamic power coefficient as well.

Quoted 8 lines
Quoted 4 lines

---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251

Sorry for miss one dependence for this device node.
https://lkml.org/lkml/2015/7/9/206

This patch got somehow forgotten.
Thanks for the reminder.
Matthias

Quoted 45 lines
Quoted 43 lines
---
  arch/arm64/boot/dts/mediatek/mt8173.dtsi |    4 ++++
  1 file changed, 4 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173.dtsi +4 -1
index f9c44cc..5cb6b4e 100644
@@ -71,6 +71,7 @@
                         #cooling-cells = <2>;
                         #cooling-min-level = <0>;
                         #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <263>;
                 };
 
                 cpu1: cpu at 1 {
@@ -95,6 +96,7 @@
                         #cooling-cells = <2>;
                         #cooling-min-level = <0>;
                         #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <263>;
                 };
 
                 cpu2: cpu at 100 {
@@ -119,6 +121,7 @@
                         #cooling-cells = <2>;
                         #cooling-min-level = <0>;
                         #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <530>;
                 };
 
                 cpu3: cpu at 101 {
@@ -143,6 +146,7 @@
                         #cooling-cells = <2>;
                         #cooling-min-level = <0>;
                         #cooling-max-level = <7>;
+                       dynamic-power-coefficient = <530>;
                 };
 
                 idle-states {
--

1.7.9.5

#8 lore raw
In reply to Eduardo Valentin
Quoted 24 lines · Eduardo Valentin
Quoted 23 lines · Rafael J. Wysocki
Quoted 13 lines · Matthias Brugger

Hi Rafael,

Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Viresh Kumar

Hi Rafael,

Quoted 5 lines · Dawei Chien

MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering cooling devices with dynamic power coefficient.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can you please apply this patch from Dawei ?

I can, but I'm traveling this week, so that's rather going to happen next week.

I don't see the patch in linux-next, did you forget to pick/push it?

No, I didn't. I just didn't have the time to get to them before.

Quoted 8 lines
Quoted 4 lines

Now, given that they are thermal patches, they really should go in via linux-soc-thermal.git.

Eduardo, any chance to take care of these?

Yes I can add this one, given that they have the proper acked-by. I was a bit hesitant to just get them because they are touching drivers/cpufreq.

Generally, ACKs from Viresh are sufficient for ARM cpufreq drivers unless the maintainers of the platform in question disagree.

Quoted 1 line

Anyways, I am adding this to my branch to the next merge window.

Thanks!