Skip to contentSkip to conversation

arm64: allwinner: a64: Enable DVFS on A64

PATCH Applied Vasily Khoruzhick 2 participants 9 messages Jan 8, 2020 – Jan 9, 2020

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

v2 cover arm64: allwinner: a64: Enable DVFS on A64

This series introduces new DTSI with operating points for A64, adds cooling maps and thermal tripping points and enables DVFS on all the supported A64-based boards

v2: - drop two commits that were merged
- mention where tripping points and OPP were taken from
- add new line after each node in OPP table
- split adding CPU clock and OPP into separate commits
- put operating points into their own dtsi

Vasily Khoruzhick (4):
arm64: dts: allwinner: a64: add CPU clock to CPU0-3 nodes
arm64: dts: allwinner: a64: add cooling maps and thermal tripping
points
arm64: dts: allwinner: a64: add dtsi with CPU operating points
arm64: dts: allwinner: a64: enable DVFS

 .../allwinner/sun50i-a64-amarula-relic.dts    | 17 +++++
 .../dts/allwinner/sun50i-a64-bananapi-m64.dts | 17 +++++
 .../dts/allwinner/sun50i-a64-cpu-opp.dtsi     | 75 +++++++++++++++++++
 .../dts/allwinner/sun50i-a64-nanopi-a64.dts   | 17 +++++
 .../dts/allwinner/sun50i-a64-olinuxino.dts    | 17 +++++
 .../dts/allwinner/sun50i-a64-orangepi-win.dts | 17 +++++
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  | 17 +++++
 .../dts/allwinner/sun50i-a64-pinebook.dts     | 17 +++++
 .../boot/dts/allwinner/sun50i-a64-sopine.dtsi | 17 +++++
 .../boot/dts/allwinner/sun50i-a64-teres-i.dts | 17 +++++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 52 +++++++++++++
 11 files changed, 280 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi
Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/4 arm64: dts: allwinner: a64: add CPU clock to CPU0-3 nodes

Add CPU clock to the CPU nodes since it is a prerequisite for enabling DVFS.

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +8 -0
index 5e3f16c3b706..77b33087866d 100644
@@ -90,6 +90,8 @@ cpu0: cpu@0 {
 			reg = <0>;
 			enable-method = "psci";
 			next-level-cache = <&L2>;
+			clocks = <&ccu CLK_CPUX>;
+			clock-names = "cpu";
 		};
 
 		cpu1: cpu@1 {
@@ -98,6 +100,8 @@ cpu1: cpu@1 {
 			reg = <1>;
 			enable-method = "psci";
 			next-level-cache = <&L2>;
+			clocks = <&ccu CLK_CPUX>;
+			clock-names = "cpu";
 		};
 
 		cpu2: cpu@2 {
@@ -106,6 +110,8 @@ cpu2: cpu@2 {
 			reg = <2>;
 			enable-method = "psci";
 			next-level-cache = <&L2>;
+			clocks = <&ccu CLK_CPUX>;
+			clock-names = "cpu";
 		};
 
 		cpu3: cpu@3 {
@@ -114,6 +120,8 @@ cpu3: cpu@3 {
 			reg = <3>;
 			enable-method = "psci";
 			next-level-cache = <&L2>;
+			clocks = <&ccu CLK_CPUX>;
+			clock-names = "cpu";
 		};
 
 		L2: l2-cache {
Signature · 1 line
2.24.1
#2 lore raw

PATCH v2 2/4 arm64: dts: allwinner: a64: add cooling maps and thermal tripping points

In reply to Vasily Khoruzhick

Add cooling maps and thermal tripping points to prevent CPU overheating when running at the highest frequency. Tripping points are taken from A33 dts since A64 user manual doesn't mention when we should start throttling.

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +44 -0
index 77b33087866d..54a741f3cd8c 100644
@@ -92,6 +92,7 @@ cpu0: cpu@0 {
 			next-level-cache = <&L2>;
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
+			#cooling-cells = <2>;
 		};
 
 		cpu1: cpu@1 {
@@ -102,6 +103,7 @@ cpu1: cpu@1 {
 			next-level-cache = <&L2>;
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
+			#cooling-cells = <2>;
 		};
 
 		cpu2: cpu@2 {
@@ -112,6 +114,7 @@ cpu2: cpu@2 {
 			next-level-cache = <&L2>;
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
+			#cooling-cells = <2>;
 		};
 
 		cpu3: cpu@3 {
@@ -122,6 +125,7 @@ cpu3: cpu@3 {
 			next-level-cache = <&L2>;
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
+			#cooling-cells = <2>;
 		};
 
 		L2: l2-cache {
@@ -226,6 +230,46 @@ cpu_thermal: cpu0-thermal {
 			polling-delay-passive = <0>;
 			polling-delay = <0>;
 			thermal-sensors = <&ths 0>;
+
+			cooling-maps {
+				map0 {
+					trip = <&cpu_alert0>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+				map1 {
+					trip = <&cpu_alert1>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+			};
+
+			trips {
+				cpu_alert0: cpu_alert0 {
+					/* milliCelsius */
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
+				cpu_alert1: cpu_alert1 {
+					/* milliCelsius */
+					temperature = <90000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
+				cpu_crit: cpu_crit {
+					/* milliCelsius */
+					temperature = <110000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
 		};
 
 		gpu0_thermal: gpu0-thermal {
Signature · 1 line
2.24.1
#3 lore raw

PATCH v2 3/4 arm64: dts: allwinner: a64: add dtsi with CPU operating points

In reply to Vasily Khoruzhick

Add operating points for A64. These are taken from FEX file from BSP for A64.

---
 .../dts/allwinner/sun50i-a64-cpu-opp.dtsi     | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi
arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi new file +75 -0
new file mode 100644
index 000000000000..578c37490d90
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Vasily khoruzhick <[email protected]>
+ */
+
+/ {
+	cpu0_opp_table: opp_table0 {
+		compatible = "operating-points-v2";
+		opp-shared;
+
+		opp-648000000 {
+			opp-hz = /bits/ 64 <648000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-816000000 {
+			opp-hz = /bits/ 64 <816000000>;
+			opp-microvolt = <1100000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-912000000 {
+			opp-hz = /bits/ 64 <912000000>;
+			opp-microvolt = <1120000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-960000000 {
+			opp-hz = /bits/ 64 <960000000>;
+			opp-microvolt = <1160000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-1008000000 {
+			opp-hz = /bits/ 64 <1008000000>;
+			opp-microvolt = <1200000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-1056000000 {
+			opp-hz = /bits/ 64 <1056000000>;
+			opp-microvolt = <1240000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-1104000000 {
+			opp-hz = /bits/ 64 <1104000000>;
+			opp-microvolt = <1260000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp-1152000000 {
+			opp-hz = /bits/ 64 <1152000000>;
+			opp-microvolt = <1300000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+	};
+};
+
+&cpu0 {
+	operating-points-v2 = <&cpu0_opp_table>;
+};
+
+&cpu1 {
+	operating-points-v2 = <&cpu0_opp_table>;
+};
+
+&cpu2 {
+	operating-points-v2 = <&cpu0_opp_table>;
+};
+
+&cpu3 {
+	operating-points-v2 = <&cpu0_opp_table>;
+};
Signature · 1 line
2.24.1
#4 lore raw

PATCH v2 4/4 arm64: dts: allwinner: a64: enable DVFS

In reply to Vasily Khoruzhick

Add CPU regulator and operating points for all the A64-based boards that are currently supported to enable DVFS.

---
 .../dts/allwinner/sun50i-a64-amarula-relic.dts  | 17 +++++++++++++++++
 .../dts/allwinner/sun50i-a64-bananapi-m64.dts   | 17 +++++++++++++++++
 .../dts/allwinner/sun50i-a64-nanopi-a64.dts     | 17 +++++++++++++++++
 .../boot/dts/allwinner/sun50i-a64-olinuxino.dts | 17 +++++++++++++++++
 .../dts/allwinner/sun50i-a64-orangepi-win.dts   | 17 +++++++++++++++++
 .../boot/dts/allwinner/sun50i-a64-pine64.dts    | 17 +++++++++++++++++
 .../boot/dts/allwinner/sun50i-a64-pinebook.dts  | 17 +++++++++++++++++
 .../boot/dts/allwinner/sun50i-a64-sopine.dtsi   | 17 +++++++++++++++++
 .../boot/dts/allwinner/sun50i-a64-teres-i.dts   | 17 +++++++++++++++++
 9 files changed, 153 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-amarula-relic.dts +17 -0
index 5634245d11db..6ee7291293ec 100644
@@ -7,6 +7,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -65,6 +66,22 @@ wifi_pwrseq: wifi-pwrseq {
 	};
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &csi {
 	status = "okay";
 
arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts +17 -0
index 208373efee49..9b80e06f40d6 100644
@@ -43,6 +43,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -108,6 +109,22 @@ &codec_analog {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &dai {
 	status = "okay";
 };
arch/arm64/boot/dts/allwinner/sun50i-a64-nanopi-a64.dts +17 -0
index 9b9d9157128c..6b81b91da504 100644
@@ -43,6 +43,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -87,6 +88,22 @@ wifi_pwrseq: wifi_pwrseq {
 	};
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &de {
 	status = "okay";
 };
arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts +17 -0
index 01a9a52edae4..fb45c32558c5 100644
@@ -43,6 +43,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -87,6 +88,22 @@ wifi_pwrseq: wifi_pwrseq {
 	};
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &de {
 	status = "okay";
 };
arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts +17 -0
index f54a415f2e3b..a510cf40a9fe 100644
@@ -44,6 +44,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -123,6 +124,22 @@ &codec_analog {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &dai {
 	status = "okay";
 };
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +17 -0
index 409523cb0950..7cb01886aa32 100644
@@ -43,6 +43,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -84,6 +85,22 @@ &codec_analog {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &dai {
 	status = "okay";
 };
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +17 -0
index 78c82a665c84..74a8569c677f 100644
@@ -8,6 +8,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
@@ -98,6 +99,22 @@ &codec_analog {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &dai {
 	status = "okay";
 };
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi +17 -0
index 9d20e13f0c02..e64f330ca420 100644
@@ -44,6 +44,7 @@
  */
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 
@@ -51,6 +52,22 @@ &codec_analog {
 	cpvdd-supply = <&reg_eldo1>;
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins>;
arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts +17 -0
index 970415106dcf..0356608ce467 100644
@@ -8,6 +8,7 @@
 /dts-v1/;
 
 #include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
@@ -104,6 +105,22 @@ &de {
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu2 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
+&cpu3 {
+	cpu-supply = <&reg_dcdc2>;
+};
+
 &ehci1 {
 	status = "okay";
 };
Signature · 1 line
2.24.1
#5 lore raw
In reply to Vasily Khoruzhick

Hi,

Quoted 3 lines · Vasily Khoruzhick

This series introduces new DTSI with operating points for A64, adds cooling maps and thermal tripping points and enables DVFS on all the supported A64-based boards

Thanks for that new series.

I'm not sure I've seen the answer, but how did you test that the OPPs were stable?

So far, the only method that proved to be reliable was to run
https://github.com/ssvb/cpuburn-arm/blob/master/cpufreq-ljt-stress-test

Could you paste the result (one board should be enough) ?

Thanks
Maxime

#6 lore raw
Quoted 4 lines · Maxime Ripard

Hi,

On Tue, Jan 07, 2020 at 08:20:14PM -0800, Vasily Khoruzhick wrote:

Quoted 8 lines
Quoted 3 lines

This series introduces new DTSI with operating points for A64, adds cooling maps and thermal tripping points and enables DVFS on all the supported A64-based boards

Thanks for that new series.

I'm not sure I've seen the answer, but how did you test that the OPPs were stable?

I've been using them for close to 2 years and haven't seen any issues so far.

Quoted 4 lines

So far, the only method that proved to be reliable was to run
https://github.com/ssvb/cpuburn-arm/blob/master/cpufreq-ljt-stress-test

Could you paste the result (one board should be enough) ?

Here is a run on Pine64-LTS:
https://gist.github.com/anarsoul/23c361b42bcdf4f2e23624f74c4c94bc

Regards,
Vasily

Quoted 2 lines

Thanks
Maxime

#7 lore raw
Quoted 9 lines · Vasily Khoruzhick
Quoted 8 lines · Maxime Ripard

Hi,

Quoted 3 lines · Vasily Khoruzhick

This series introduces new DTSI with operating points for A64, adds cooling maps and thermal tripping points and enables DVFS on all the supported A64-based boards

Quoted 7 lines
Quoted 4 lines

Thanks for that new series.

I'm not sure I've seen the answer, but how did you test that the OPPs were stable?

I've been using them for close to 2 years and haven't seen any issues so far.

I'm sure you did, but those issues can be easily masked depending on your config (and the default governor you have) and the workload.

Quoted 7 lines
Quoted 4 lines

So far, the only method that proved to be reliable was to run
https://github.com/ssvb/cpuburn-arm/blob/master/cpufreq-ljt-stress-test

Could you paste the result (one board should be enough) ?

Here is a run on Pine64-LTS:
https://gist.github.com/anarsoul/23c361b42bcdf4f2e23624f74c4c94bc

Awesome, thanks!
Maxime

#8 lore raw
In reply to Vasily Khoruzhick
Quoted 9 lines · Vasily Khoruzhick

This series introduces new DTSI with operating points for A64, adds cooling maps and thermal tripping points and enables DVFS on all the supported A64-based boards

v2: - drop two commits that were merged
- mention where tripping points and OPP were taken from
- add new line after each node in OPP table
- split adding CPU clock and OPP into separate commits
- put operating points into their own dtsi

Applied, thanks!
Maxime