2024-12-19 21:34:44 +00:00
|
|
|
From 86d1b4f34344dafecea8286b87c0f1fe24c2f406 Mon Sep 17 00:00:00 2001
|
2024-12-15 18:29:23 +00:00
|
|
|
From: yangwei1 <yangwei1@eswincomputing.com>
|
|
|
|
Date: Wed, 16 Oct 2024 16:46:21 +0800
|
|
|
|
Subject: [PATCH 191/219] feat:support IPA thermal control
|
|
|
|
|
|
|
|
Changelogs:
|
|
|
|
1. add IPA thermal control framework
|
|
|
|
2. workaround cpu DVFS problem when EM enabled
|
|
|
|
|
|
|
|
Signed-off-by: yangwei1 <yangwei1@eswincomputing.com>
|
|
|
|
---
|
|
|
|
.../boot/dts/eswin/eswin-win2030-arch.dtsi | 8 +++
|
|
|
|
.../dts/eswin/eswin-win2030-die0-soc.dtsi | 57 +++++++++++++++++++
|
|
|
|
.../dts/eswin/eswin-win2030-die1-soc.dtsi | 57 +++++++++++++++++++
|
|
|
|
arch/riscv/configs/eic7700_defconfig | 11 ++++
|
|
|
|
kernel/power/energy_model.c | 3 +-
|
|
|
|
5 files changed, 135 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/arch/riscv/boot/dts/eswin/eswin-win2030-arch.dtsi b/arch/riscv/boot/dts/eswin/eswin-win2030-arch.dtsi
|
|
|
|
index 3f2582159f83..bde485b4abfa 100644
|
|
|
|
--- a/arch/riscv/boot/dts/eswin/eswin-win2030-arch.dtsi
|
|
|
|
+++ b/arch/riscv/boot/dts/eswin/eswin-win2030-arch.dtsi
|
|
|
|
@@ -84,6 +84,8 @@ L17: cpu@0 {
|
|
|
|
tlb-split;
|
|
|
|
clocks = <&d0_clock WIN2030_CLK_CPU_EXT_SRC_CORE_CLK_0>;
|
|
|
|
operating-points-v2 = <&d0_cpu_opp_table>;
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <324>;
|
|
|
|
cpu-idle-states = <&CPU_RET>;
|
|
|
|
L14: interrupt-controller {
|
|
|
|
#interrupt-cells = <1>;
|
|
|
|
@@ -127,6 +129,8 @@ L22: cpu@1 {
|
|
|
|
tlb-split;
|
|
|
|
clocks = <&d0_clock WIN2030_CLK_CPU_EXT_SRC_CORE_CLK_1>;
|
|
|
|
operating-points-v2 = <&d0_cpu_opp_table>;
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <324>;
|
|
|
|
cpu-idle-states = <&CPU_RET>;
|
|
|
|
L19: interrupt-controller {
|
|
|
|
#interrupt-cells = <1>;
|
|
|
|
@@ -170,6 +174,8 @@ L27: cpu@2 {
|
|
|
|
tlb-split;
|
|
|
|
clocks = <&d0_clock WIN2030_CLK_CPU_EXT_SRC_CORE_CLK_2>;
|
|
|
|
operating-points-v2 = <&d0_cpu_opp_table>;
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <324>;
|
|
|
|
cpu-idle-states = <&CPU_RET>;
|
|
|
|
L24: interrupt-controller {
|
|
|
|
#interrupt-cells = <1>;
|
|
|
|
@@ -213,6 +219,8 @@ L32: cpu@3 {
|
|
|
|
tlb-split;
|
|
|
|
clocks = <&d0_clock WIN2030_CLK_CPU_EXT_SRC_CORE_CLK_3>;
|
|
|
|
operating-points-v2 = <&d0_cpu_opp_table>;
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <324>;
|
|
|
|
cpu-idle-states = <&CPU_RET>;
|
|
|
|
L29: interrupt-controller {
|
|
|
|
#interrupt-cells = <1>;
|
|
|
|
diff --git a/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi b/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi
|
|
|
|
index 50a9383989b4..14d5b4b0df6a 100644
|
|
|
|
--- a/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi
|
|
|
|
+++ b/arch/riscv/boot/dts/eswin/eswin-win2030-die0-soc.dtsi
|
|
|
|
@@ -31,6 +31,7 @@
|
|
|
|
#include <dt-bindings/i2c/i2c.h>
|
|
|
|
#include <dt-bindings/interconnect/eswin,win2030.h>
|
|
|
|
#include <dt-bindings/power/eswin,eic770x-pmu.h>
|
|
|
|
+#include <dt-bindings/thermal/thermal.h>
|
|
|
|
|
|
|
|
/ {
|
|
|
|
compatible = "sifive,hifive-unmatched-a00", "sifive,fu740-c000","sifive,fu740";
|
|
|
|
@@ -104,6 +105,55 @@ opp-1400000000 {
|
|
|
|
clock-latency-ns = <70000>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
+
|
|
|
|
+ thermal-zones {
|
|
|
|
+ thermal0 {
|
|
|
|
+ polling-delay-passive = <500>; /*ms*/
|
|
|
|
+ polling-delay = <5000>; /*ms*/
|
|
|
|
+ sustainable-power = <1200>; /*mW*/
|
|
|
|
+ thermal-sensors = <&pvt0>;
|
|
|
|
+
|
|
|
|
+ trips {
|
|
|
|
+ threshold: trip-point0 {
|
|
|
|
+ temperature = <60000>; /* DC*1000 */
|
|
|
|
+ hysteresis = <1000>; /* DC*1000 */
|
|
|
|
+ type = "passive";
|
|
|
|
+ };
|
|
|
|
+ target: trip-point1 {
|
|
|
|
+ temperature = <70000>;
|
|
|
|
+ hysteresis = <1000>;
|
|
|
|
+ type = "passive";
|
|
|
|
+ };
|
|
|
|
+ crit: trip-point2 {
|
|
|
|
+ temperature = <110000>;
|
|
|
|
+ hysteresis = <0>;
|
|
|
|
+ type = "critical";
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ cooling-maps {
|
|
|
|
+ map0 {
|
|
|
|
+ trip = <&target>;
|
|
|
|
+ contribution = <1024>;
|
|
|
|
+ cooling-device =
|
|
|
|
+ <&L17 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
|
|
|
+ <&L22 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
|
|
|
+ <&L27 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
|
|
|
+ <&L32 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
|
|
|
+ };
|
|
|
|
+ map1 {
|
|
|
|
+ trip = <&target>;
|
|
|
|
+ contribution = <1024>; /*TBD*/
|
|
|
|
+ cooling-device = <&d0_npu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
|
|
|
+ };
|
|
|
|
+ map2 {
|
|
|
|
+ trip = <&target>;
|
|
|
|
+ contribution = <1024>; /*TBD*/
|
|
|
|
+ cooling-device = <&gpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
};
|
|
|
|
|
|
|
|
&SOC {
|
|
|
|
@@ -510,6 +560,9 @@ d0_npu: eswin-npu@51c00000 {
|
|
|
|
|
|
|
|
numa-node-id = <0>;
|
|
|
|
dma-noncoherent;
|
|
|
|
+
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <0>; /*TBD*/
|
|
|
|
};
|
|
|
|
|
|
|
|
dev_llc_d0: llc@51c00000 {
|
|
|
|
@@ -720,6 +773,9 @@ gpu0: gpu@51400000 {
|
|
|
|
interrupt-parent = <&plic0>;
|
|
|
|
interrupts = <15>;
|
|
|
|
dma-noncoherent;
|
|
|
|
+
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <0>; /*TBD*/
|
|
|
|
};
|
|
|
|
|
|
|
|
d0_sata: sata@0x50420000{
|
|
|
|
@@ -1245,6 +1301,7 @@ pvt0: pvt@0x50b00000 {
|
|
|
|
reg = <0x0 0x50b00000 0x0 0x10000>;
|
|
|
|
interrupts = <349>;
|
|
|
|
interrupt-parent = <&plic0>;
|
|
|
|
+ #thermal-sensor-cells = <0>;
|
|
|
|
status = "disabled";
|
|
|
|
label = "pvt0";
|
|
|
|
};
|
|
|
|
diff --git a/arch/riscv/boot/dts/eswin/eswin-win2030-die1-soc.dtsi b/arch/riscv/boot/dts/eswin/eswin-win2030-die1-soc.dtsi
|
|
|
|
index 01a325bd598f..8351a81c605a 100644
|
|
|
|
--- a/arch/riscv/boot/dts/eswin/eswin-win2030-die1-soc.dtsi
|
|
|
|
+++ b/arch/riscv/boot/dts/eswin/eswin-win2030-die1-soc.dtsi
|
|
|
|
@@ -29,6 +29,7 @@
|
|
|
|
#include <dt-bindings/clock/win2030-clock.h>
|
|
|
|
#include <dt-bindings/i2c/i2c.h>
|
|
|
|
#include <dt-bindings/interconnect/eswin,win2030.h>
|
|
|
|
+#include <dt-bindings/thermal/thermal.h>
|
|
|
|
|
|
|
|
/ {
|
|
|
|
#if (CHIPLET_AND_DIE == 0x1)
|
|
|
|
@@ -108,6 +109,55 @@ opp-1400000000 {
|
|
|
|
clock-latency-ns = <70000>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
+
|
|
|
|
+ thermal-zones {
|
|
|
|
+ d1_thermal0 {
|
|
|
|
+ polling-delay-passive = <500>; /*ms*/
|
|
|
|
+ polling-delay = <5000>; /*ms*/
|
|
|
|
+ sustainable-power = <1200>; /*mW*/
|
|
|
|
+ thermal-sensors = <&d1_pvt0>;
|
|
|
|
+
|
|
|
|
+ trips {
|
|
|
|
+ d1_threshold: trip-point0 {
|
|
|
|
+ temperature = <60000>; /* DC*1000 */
|
|
|
|
+ hysteresis = <1000>; /* DC*1000 */
|
|
|
|
+ type = "passive";
|
|
|
|
+ };
|
|
|
|
+ d1_target: trip-point1 {
|
|
|
|
+ temperature = <70000>;
|
|
|
|
+ hysteresis = <1000>;
|
|
|
|
+ type = "passive";
|
|
|
|
+ };
|
|
|
|
+ d1_crit: trip-point2 {
|
|
|
|
+ temperature = <110000>;
|
|
|
|
+ hysteresis = <0>;
|
|
|
|
+ type = "critical";
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ cooling-maps {
|
|
|
|
+ map0 {
|
|
|
|
+ trip = <&d1_target>;
|
|
|
|
+ contribution = <1024>;
|
|
|
|
+ cooling-device =
|
|
|
|
+ <&cpu_4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
|
|
|
+ <&cpu_5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
|
|
|
+ <&cpu_6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
|
|
|
+ <&cpu_7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
|
|
|
+ };
|
|
|
|
+ map1 {
|
|
|
|
+ trip = <&d1_target>;
|
|
|
|
+ contribution = <1024>; /*TBD*/
|
|
|
|
+ cooling-device = <&d1_npu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
|
|
|
+ };
|
|
|
|
+ map2 {
|
|
|
|
+ trip = <&d1_target>;
|
|
|
|
+ contribution = <1024>; /*TBD*/
|
|
|
|
+ cooling-device = <&d1_gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
};
|
|
|
|
|
|
|
|
&SOC {
|
|
|
|
@@ -654,6 +704,7 @@ d1_pvt0: pvt@0x70b00000 {
|
|
|
|
reg = <0x0 0x70b00000 0x0 0x10000>;
|
|
|
|
interrupts = <349>;
|
|
|
|
interrupt-parent = <&plic1>;
|
|
|
|
+ #thermal-sensor-cells = <0>;
|
|
|
|
status = "disabled";
|
|
|
|
label = "d1_pvt0";
|
|
|
|
};
|
|
|
|
@@ -912,6 +963,9 @@ d1_npu: eswin-npu@71c00000 {
|
|
|
|
|
|
|
|
numa-node-id = <1>;
|
|
|
|
dma-noncoherent;
|
|
|
|
+
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <0>; /*TBD*/
|
|
|
|
};
|
|
|
|
|
|
|
|
dev_llc_d1: llc@71c00000 {
|
|
|
|
@@ -956,6 +1010,9 @@ d1_gpu: gpu@71400000 {
|
|
|
|
interrupt-parent = <&plic1>;
|
|
|
|
interrupts = <15>;
|
|
|
|
dma-noncoherent;
|
|
|
|
+
|
|
|
|
+ #cooling-cells = <2>;
|
|
|
|
+ dynamic-power-coefficient = <0>; /*TBD*/
|
|
|
|
};
|
|
|
|
|
|
|
|
d1_sata: sata@0x70420000 {
|
|
|
|
diff --git a/arch/riscv/configs/eic7700_defconfig b/arch/riscv/configs/eic7700_defconfig
|
|
|
|
index 71765f0bea49..dcb4a252da20 100644
|
|
|
|
--- a/arch/riscv/configs/eic7700_defconfig
|
|
|
|
+++ b/arch/riscv/configs/eic7700_defconfig
|
|
|
|
@@ -38,6 +38,7 @@ CONFIG_RISCV_SBI_V01=y
|
|
|
|
CONFIG_CMDLINE="earlycon=sbi console=ttyS0,115200n8 clk_ignore_unused cma_pernuma=0x2000000 disable_bypass=false firmware_class.path=/lib/firmware/eic7x/"
|
|
|
|
CONFIG_CMDLINE_EXTEND=y
|
|
|
|
# CONFIG_SUSPEND is not set
|
|
|
|
+CONFIG_ENERGY_MODEL=y
|
|
|
|
CONFIG_CPU_FREQ=y
|
|
|
|
CONFIG_CPU_FREQ_STAT=y
|
|
|
|
CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
|
|
|
|
@@ -462,6 +463,14 @@ CONFIG_SENSORS_ESWIN_FAN_CONTROL=y
|
|
|
|
CONFIG_SENSORS_ESWIN_PVT=y
|
|
|
|
CONFIG_SENSORS_INA2XX=y
|
|
|
|
CONFIG_SENSORS_PAC1934=y
|
|
|
|
+CONFIG_THERMAL=y
|
|
|
|
+CONFIG_THERMAL_STATISTICS=y
|
|
|
|
+CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR=y
|
|
|
|
+CONFIG_THERMAL_GOV_STEP_WISE=y
|
|
|
|
+CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y
|
|
|
|
+CONFIG_CPU_THERMAL=y
|
|
|
|
+CONFIG_DEVFREQ_THERMAL=y
|
|
|
|
+CONFIG_THERMAL_EMULATION=y
|
|
|
|
CONFIG_WATCHDOG=y
|
|
|
|
CONFIG_DW_WATCHDOG=y
|
|
|
|
CONFIG_REGULATOR=y
|
|
|
|
@@ -741,6 +750,8 @@ CONFIG_RPMSG_VIRTIO=y
|
|
|
|
CONFIG_ARCH_ESWIN_EIC770X_SOC_FAMILY=y
|
|
|
|
CONFIG_ESWIN_DSP=m
|
|
|
|
CONFIG_ESWIN_NPU=m
|
|
|
|
+CONFIG_PM_DEVFREQ=y
|
|
|
|
+CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
|
|
|
|
CONFIG_EXTCON=y
|
|
|
|
CONFIG_MEMORY=y
|
|
|
|
CONFIG_ESWIN_BUDDY=y
|
|
|
|
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
|
|
|
|
index 7b44f5b89fa1..cbc638479e46 100644
|
|
|
|
--- a/kernel/power/energy_model.c
|
|
|
|
+++ b/kernel/power/energy_model.c
|
|
|
|
@@ -173,7 +173,8 @@ static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
|
|
|
|
|
|
|
|
table[i].cost = cost;
|
|
|
|
|
|
|
|
- if (table[i].cost >= prev_cost) {
|
|
|
|
+ //workaround for IPA thermal: modify >= to >
|
|
|
|
+ if (table[i].cost > prev_cost) {
|
|
|
|
table[i].flags = EM_PERF_STATE_INEFFICIENT;
|
|
|
|
dev_dbg(dev, "EM: OPP:%lu is inefficient\n",
|
|
|
|
table[i].frequency);
|
|
|
|
--
|
|
|
|
2.47.0
|
|
|
|
|