From 93d50e2df130fd5a7d0d2e9036b15368be38fe5a Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Wed, 17 Feb 2016 12:28:35 +0100 Subject: [PATCH 1/3] 1st try to solve wrong thermal read-outs --- .../sun8i-default/0005-h3-thermal.patch | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 patch/kernel/sun8i-default/0005-h3-thermal.patch diff --git a/patch/kernel/sun8i-default/0005-h3-thermal.patch b/patch/kernel/sun8i-default/0005-h3-thermal.patch new file mode 100644 index 000000000..9dfeb6a59 --- /dev/null +++ b/patch/kernel/sun8i-default/0005-h3-thermal.patch @@ -0,0 +1,109 @@ +diff --git a/drivers/thermal/cpu_budget_cooling.c b/drivers/thermal/cpu_budget_cooling.c +index fb316b6..ce1f9bb 100755 +--- a/drivers/thermal/cpu_budget_cooling.c ++++ b/drivers/thermal/cpu_budget_cooling.c +@@ -30,8 +30,6 @@ + #include + #include + #include +-#include "thermal_core.h" +- + #define CREATE_TRACE_POINTS + #include + #define BOOT_CPU 0 +@@ -249,8 +247,6 @@ static int cpu_budget_apply_cooling(struct cpu_budget_cooling_device *cpu_budget + unsigned long cooling_state) + { + unsigned long flags; +- struct thermal_instance *instance; +- int temperature = 0; + + /* Check if the old cooling action is same as new cooling action */ + if (cpu_budget_device->cpu_budget_state == cooling_state) +@@ -275,11 +271,7 @@ static int cpu_budget_apply_cooling(struct cpu_budget_cooling_device *cpu_budget + cpu_budget_device->cluster1_freq_limit, + cpu_budget_device->cluster1_num_limit, + cpu_budget_device->gpu_throttle); +- list_for_each_entry(instance, &(cpu_budget_device->cool_dev->thermal_instances), cdev_node) { +- if(instance->tz->temperature > temperature) +- temperature = instance->tz->temperature; +- } +- pr_info("CPU Budget: Temperature: %u Limit state:%lu item[%d,%d,%d,%d %d]\n",temperature,cooling_state, ++ pr_debug("CPU Budget: Limit state:%lu item[%d,%d,%d,%d %d]\n",cooling_state, + cpu_budget_device->cluster0_freq_limit, + cpu_budget_device->cluster0_num_limit , + cpu_budget_device->cluster1_freq_limit , +@@ -381,7 +373,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, + { + cpufreq_verify_within_limits(policy, min_freq, max_freq); + policy->user_policy.max = policy->max; +- pr_info("CPU Budget:update CPU %d cpufreq max to %lu min to %lu\n",policy->cpu,max_freq, min_freq); ++ pr_debug("CPU Budget:update CPU %d cpufreq max to %lu min to %lu\n",policy->cpu,max_freq, min_freq); + } + } + return 0; +diff --git a/drivers/thermal/sunxi-cpu-budget-cooling.c b/drivers/thermal/sunxi-cpu-budget-cooling.c +index 71ebc41..3a1b42b 100755 +--- a/drivers/thermal/sunxi-cpu-budget-cooling.c ++++ b/drivers/thermal/sunxi-cpu-budget-cooling.c +@@ -69,14 +69,16 @@ static struct cpu_budget_table m_default_budgets_table[]= + {1,816000,4,816000,1}, + }; + #endif ++/* LOBO */ + #ifdef CONFIG_ARCH_SUN8IW7 + static struct cpu_budget_table m_default_budgets_table[]= + { ++ {1,1296000 ,4,INVALID_FREQ,0}, + {1,1200000 ,4,INVALID_FREQ,0}, + {1,1008000 ,4,INVALID_FREQ,0}, +- {1,1008000 ,2,INVALID_FREQ,0}, +- {1,1008000 ,1,INVALID_FREQ,0}, +- {1,504000 ,1,INVALID_FREQ,0}, ++ {1,816000 ,4,INVALID_FREQ,0}, ++ {1,648000 ,4,INVALID_FREQ,0}, ++ {1,480000 ,1,INVALID_FREQ,0}, + }; + #endif + #ifdef CONFIG_ARCH_SUN9IW1 +@@ -480,7 +482,7 @@ static int sunxi_cpu_budget_syscfg_init(void) + &m_syscfg_budgets_table[i].cluster1_freq, + &m_syscfg_budgets_table[i].cluster1_cpunr, + &m_syscfg_budgets_table[i].gpu_throttle); +-#elif defined(CONFIG_ARCH_SUN8IW5) || defined(CONFIG_ARCH_SUN8IW6) || defined(CONFIG_ARCH_SUN8IW7) ++#elif defined(CONFIG_ARCH_SUN8IW5) || defined(CONFIG_ARCH_SUN8IW6) + num=sscanf(val.str, "%u %u %u %u %u", + &m_syscfg_budgets_table[i].cluster0_freq, + &m_syscfg_budgets_table[i].cluster0_cpunr, +diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c +old mode 100755 +new mode 100644 +index d897818..0e1fa39 +--- a/drivers/thermal/thermal_sys.c ++++ b/drivers/thermal/thermal_sys.c +@@ -359,9 +359,8 @@ static void handle_critical_trips(struct thermal_zone_device *tz, + tz->ops->notify(tz, trip, trip_type); + + if (trip_type == THERMAL_TRIP_CRITICAL) { +- /* Our system report temperature in centigrade, by qin 2014 .11.25 */ + pr_emerg("Critical temperature reached(%d C),shutting down\n", +- tz->temperature ); ++ tz->temperature / 1000); + orderly_poweroff(true); + } + } +diff --git a/drivers/arisc/binary/Makefile b/drivers/arisc/binary/Makefile +index 08b81fd..ab3d5d2 100755 +--- a/drivers/arisc/binary/Makefile ++++ b/drivers/arisc/binary/Makefile +@@ -29,8 +29,8 @@ ifdef CONFIG_ARCH_SUN9IW1P1 + PLATFORM=arisc_sun9iw1p1 + endif + +-$(obj)/$(PLATFORM).bin : $(src)/$(PLATFORM).code +- cp $< $(obj)/$(PLATFORM).tar.bz2; \ ++$(obj)/$(PLATFORM).bin : $(obj)/$(PLATFORM).code ++ cp $(obj)/$(PLATFORM).code $(obj)/$(PLATFORM).tar.bz2; \ + tar -xjvf $(obj)/$(PLATFORM).tar.bz2 -C $(obj)/; \ + cp $(obj)/arisc_package/$(PLATFORM).bin $(obj)/$(PLATFORM).bin; \ + cp $(obj)/arisc_package/$(PLATFORM).tar.bz2.aes $(obj)/arisc; \ From 04baf80b74f2b57b07ecc770e16d142bf2ba5747 Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Thu, 18 Feb 2016 08:10:30 +0100 Subject: [PATCH 2/3] Try to fix potential overvolting and overheating for Orange Pi One/Lite --- config/orangepione.fex | 9 +- configuration.sh | 4 +- .../sun8i-default/0005-h3-thermal.patch | 109 ------------------ 3 files changed, 6 insertions(+), 116 deletions(-) delete mode 100644 patch/kernel/sun8i-default/0005-h3-thermal.patch diff --git a/config/orangepione.fex b/config/orangepione.fex index 418191131..0ac7341f3 100644 --- a/config/orangepione.fex +++ b/config/orangepione.fex @@ -734,16 +734,15 @@ ir_tx = port:PH07<2> [dvfs_table] pmuic_type = 1 pmu_gpio0 = port:PL06<1><1><2><1> -pmu_level0 = 11300 -pmu_level1 = 1100 -;extremity_freq = 1296000000 +pmu_level0 = 1270 +pmu_level1 = 1270 max_freq = 1200000000 min_freq = 648000000 LV_count = 2 LV1_freq = 1200000000 -LV1_volt = 1300 +LV1_volt = 1270 LV2_freq = 648000000 -LV2_volt = 1100 +LV2_volt = 1270 [gpu_dvfs_table] G_LV_count = 3 diff --git a/configuration.sh b/configuration.sh index 01049902d..5b277e032 100644 --- a/configuration.sh +++ b/configuration.sh @@ -254,7 +254,7 @@ MODULES="gpio_sunxi w1-sunxi w1-gpio w1-therm" MODULES_NEXT="" CPUMIN="648000" - CPUMAX="1200000" + CPUMAX="1104000" GOVERNOR="interactive" ;; @@ -266,7 +266,7 @@ MODULES="8189es gpio_sunxi w1-sunxi w1-gpio w1-therm" MODULES_NEXT="" CPUMIN="648000" - CPUMAX="1200000" + CPUMAX="1104000" GOVERNOR="interactive" ;; diff --git a/patch/kernel/sun8i-default/0005-h3-thermal.patch b/patch/kernel/sun8i-default/0005-h3-thermal.patch deleted file mode 100644 index 9dfeb6a59..000000000 --- a/patch/kernel/sun8i-default/0005-h3-thermal.patch +++ /dev/null @@ -1,109 +0,0 @@ -diff --git a/drivers/thermal/cpu_budget_cooling.c b/drivers/thermal/cpu_budget_cooling.c -index fb316b6..ce1f9bb 100755 ---- a/drivers/thermal/cpu_budget_cooling.c -+++ b/drivers/thermal/cpu_budget_cooling.c -@@ -30,8 +30,6 @@ - #include - #include - #include --#include "thermal_core.h" -- - #define CREATE_TRACE_POINTS - #include - #define BOOT_CPU 0 -@@ -249,8 +247,6 @@ static int cpu_budget_apply_cooling(struct cpu_budget_cooling_device *cpu_budget - unsigned long cooling_state) - { - unsigned long flags; -- struct thermal_instance *instance; -- int temperature = 0; - - /* Check if the old cooling action is same as new cooling action */ - if (cpu_budget_device->cpu_budget_state == cooling_state) -@@ -275,11 +271,7 @@ static int cpu_budget_apply_cooling(struct cpu_budget_cooling_device *cpu_budget - cpu_budget_device->cluster1_freq_limit, - cpu_budget_device->cluster1_num_limit, - cpu_budget_device->gpu_throttle); -- list_for_each_entry(instance, &(cpu_budget_device->cool_dev->thermal_instances), cdev_node) { -- if(instance->tz->temperature > temperature) -- temperature = instance->tz->temperature; -- } -- pr_info("CPU Budget: Temperature: %u Limit state:%lu item[%d,%d,%d,%d %d]\n",temperature,cooling_state, -+ pr_debug("CPU Budget: Limit state:%lu item[%d,%d,%d,%d %d]\n",cooling_state, - cpu_budget_device->cluster0_freq_limit, - cpu_budget_device->cluster0_num_limit , - cpu_budget_device->cluster1_freq_limit , -@@ -381,7 +373,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, - { - cpufreq_verify_within_limits(policy, min_freq, max_freq); - policy->user_policy.max = policy->max; -- pr_info("CPU Budget:update CPU %d cpufreq max to %lu min to %lu\n",policy->cpu,max_freq, min_freq); -+ pr_debug("CPU Budget:update CPU %d cpufreq max to %lu min to %lu\n",policy->cpu,max_freq, min_freq); - } - } - return 0; -diff --git a/drivers/thermal/sunxi-cpu-budget-cooling.c b/drivers/thermal/sunxi-cpu-budget-cooling.c -index 71ebc41..3a1b42b 100755 ---- a/drivers/thermal/sunxi-cpu-budget-cooling.c -+++ b/drivers/thermal/sunxi-cpu-budget-cooling.c -@@ -69,14 +69,16 @@ static struct cpu_budget_table m_default_budgets_table[]= - {1,816000,4,816000,1}, - }; - #endif -+/* LOBO */ - #ifdef CONFIG_ARCH_SUN8IW7 - static struct cpu_budget_table m_default_budgets_table[]= - { -+ {1,1296000 ,4,INVALID_FREQ,0}, - {1,1200000 ,4,INVALID_FREQ,0}, - {1,1008000 ,4,INVALID_FREQ,0}, -- {1,1008000 ,2,INVALID_FREQ,0}, -- {1,1008000 ,1,INVALID_FREQ,0}, -- {1,504000 ,1,INVALID_FREQ,0}, -+ {1,816000 ,4,INVALID_FREQ,0}, -+ {1,648000 ,4,INVALID_FREQ,0}, -+ {1,480000 ,1,INVALID_FREQ,0}, - }; - #endif - #ifdef CONFIG_ARCH_SUN9IW1 -@@ -480,7 +482,7 @@ static int sunxi_cpu_budget_syscfg_init(void) - &m_syscfg_budgets_table[i].cluster1_freq, - &m_syscfg_budgets_table[i].cluster1_cpunr, - &m_syscfg_budgets_table[i].gpu_throttle); --#elif defined(CONFIG_ARCH_SUN8IW5) || defined(CONFIG_ARCH_SUN8IW6) || defined(CONFIG_ARCH_SUN8IW7) -+#elif defined(CONFIG_ARCH_SUN8IW5) || defined(CONFIG_ARCH_SUN8IW6) - num=sscanf(val.str, "%u %u %u %u %u", - &m_syscfg_budgets_table[i].cluster0_freq, - &m_syscfg_budgets_table[i].cluster0_cpunr, -diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c -old mode 100755 -new mode 100644 -index d897818..0e1fa39 ---- a/drivers/thermal/thermal_sys.c -+++ b/drivers/thermal/thermal_sys.c -@@ -359,9 +359,8 @@ static void handle_critical_trips(struct thermal_zone_device *tz, - tz->ops->notify(tz, trip, trip_type); - - if (trip_type == THERMAL_TRIP_CRITICAL) { -- /* Our system report temperature in centigrade, by qin 2014 .11.25 */ - pr_emerg("Critical temperature reached(%d C),shutting down\n", -- tz->temperature ); -+ tz->temperature / 1000); - orderly_poweroff(true); - } - } -diff --git a/drivers/arisc/binary/Makefile b/drivers/arisc/binary/Makefile -index 08b81fd..ab3d5d2 100755 ---- a/drivers/arisc/binary/Makefile -+++ b/drivers/arisc/binary/Makefile -@@ -29,8 +29,8 @@ ifdef CONFIG_ARCH_SUN9IW1P1 - PLATFORM=arisc_sun9iw1p1 - endif - --$(obj)/$(PLATFORM).bin : $(src)/$(PLATFORM).code -- cp $< $(obj)/$(PLATFORM).tar.bz2; \ -+$(obj)/$(PLATFORM).bin : $(obj)/$(PLATFORM).code -+ cp $(obj)/$(PLATFORM).code $(obj)/$(PLATFORM).tar.bz2; \ - tar -xjvf $(obj)/$(PLATFORM).tar.bz2 -C $(obj)/; \ - cp $(obj)/arisc_package/$(PLATFORM).bin $(obj)/$(PLATFORM).bin; \ - cp $(obj)/arisc_package/$(PLATFORM).tar.bz2.aes $(obj)/arisc; \ From 40d71f7a9c42c9e6fb68330a16d3fb9f03af520c Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Thu, 18 Feb 2016 08:15:52 +0100 Subject: [PATCH 3/3] Reactivate loboris patch for properly shutting down when massively overheating --- .../sun8i-default/0005-h3-thermal.patch | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 patch/kernel/sun8i-default/0005-h3-thermal.patch diff --git a/patch/kernel/sun8i-default/0005-h3-thermal.patch b/patch/kernel/sun8i-default/0005-h3-thermal.patch new file mode 100644 index 000000000..9dfeb6a59 --- /dev/null +++ b/patch/kernel/sun8i-default/0005-h3-thermal.patch @@ -0,0 +1,109 @@ +diff --git a/drivers/thermal/cpu_budget_cooling.c b/drivers/thermal/cpu_budget_cooling.c +index fb316b6..ce1f9bb 100755 +--- a/drivers/thermal/cpu_budget_cooling.c ++++ b/drivers/thermal/cpu_budget_cooling.c +@@ -30,8 +30,6 @@ + #include + #include + #include +-#include "thermal_core.h" +- + #define CREATE_TRACE_POINTS + #include + #define BOOT_CPU 0 +@@ -249,8 +247,6 @@ static int cpu_budget_apply_cooling(struct cpu_budget_cooling_device *cpu_budget + unsigned long cooling_state) + { + unsigned long flags; +- struct thermal_instance *instance; +- int temperature = 0; + + /* Check if the old cooling action is same as new cooling action */ + if (cpu_budget_device->cpu_budget_state == cooling_state) +@@ -275,11 +271,7 @@ static int cpu_budget_apply_cooling(struct cpu_budget_cooling_device *cpu_budget + cpu_budget_device->cluster1_freq_limit, + cpu_budget_device->cluster1_num_limit, + cpu_budget_device->gpu_throttle); +- list_for_each_entry(instance, &(cpu_budget_device->cool_dev->thermal_instances), cdev_node) { +- if(instance->tz->temperature > temperature) +- temperature = instance->tz->temperature; +- } +- pr_info("CPU Budget: Temperature: %u Limit state:%lu item[%d,%d,%d,%d %d]\n",temperature,cooling_state, ++ pr_debug("CPU Budget: Limit state:%lu item[%d,%d,%d,%d %d]\n",cooling_state, + cpu_budget_device->cluster0_freq_limit, + cpu_budget_device->cluster0_num_limit , + cpu_budget_device->cluster1_freq_limit , +@@ -381,7 +373,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, + { + cpufreq_verify_within_limits(policy, min_freq, max_freq); + policy->user_policy.max = policy->max; +- pr_info("CPU Budget:update CPU %d cpufreq max to %lu min to %lu\n",policy->cpu,max_freq, min_freq); ++ pr_debug("CPU Budget:update CPU %d cpufreq max to %lu min to %lu\n",policy->cpu,max_freq, min_freq); + } + } + return 0; +diff --git a/drivers/thermal/sunxi-cpu-budget-cooling.c b/drivers/thermal/sunxi-cpu-budget-cooling.c +index 71ebc41..3a1b42b 100755 +--- a/drivers/thermal/sunxi-cpu-budget-cooling.c ++++ b/drivers/thermal/sunxi-cpu-budget-cooling.c +@@ -69,14 +69,16 @@ static struct cpu_budget_table m_default_budgets_table[]= + {1,816000,4,816000,1}, + }; + #endif ++/* LOBO */ + #ifdef CONFIG_ARCH_SUN8IW7 + static struct cpu_budget_table m_default_budgets_table[]= + { ++ {1,1296000 ,4,INVALID_FREQ,0}, + {1,1200000 ,4,INVALID_FREQ,0}, + {1,1008000 ,4,INVALID_FREQ,0}, +- {1,1008000 ,2,INVALID_FREQ,0}, +- {1,1008000 ,1,INVALID_FREQ,0}, +- {1,504000 ,1,INVALID_FREQ,0}, ++ {1,816000 ,4,INVALID_FREQ,0}, ++ {1,648000 ,4,INVALID_FREQ,0}, ++ {1,480000 ,1,INVALID_FREQ,0}, + }; + #endif + #ifdef CONFIG_ARCH_SUN9IW1 +@@ -480,7 +482,7 @@ static int sunxi_cpu_budget_syscfg_init(void) + &m_syscfg_budgets_table[i].cluster1_freq, + &m_syscfg_budgets_table[i].cluster1_cpunr, + &m_syscfg_budgets_table[i].gpu_throttle); +-#elif defined(CONFIG_ARCH_SUN8IW5) || defined(CONFIG_ARCH_SUN8IW6) || defined(CONFIG_ARCH_SUN8IW7) ++#elif defined(CONFIG_ARCH_SUN8IW5) || defined(CONFIG_ARCH_SUN8IW6) + num=sscanf(val.str, "%u %u %u %u %u", + &m_syscfg_budgets_table[i].cluster0_freq, + &m_syscfg_budgets_table[i].cluster0_cpunr, +diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c +old mode 100755 +new mode 100644 +index d897818..0e1fa39 +--- a/drivers/thermal/thermal_sys.c ++++ b/drivers/thermal/thermal_sys.c +@@ -359,9 +359,8 @@ static void handle_critical_trips(struct thermal_zone_device *tz, + tz->ops->notify(tz, trip, trip_type); + + if (trip_type == THERMAL_TRIP_CRITICAL) { +- /* Our system report temperature in centigrade, by qin 2014 .11.25 */ + pr_emerg("Critical temperature reached(%d C),shutting down\n", +- tz->temperature ); ++ tz->temperature / 1000); + orderly_poweroff(true); + } + } +diff --git a/drivers/arisc/binary/Makefile b/drivers/arisc/binary/Makefile +index 08b81fd..ab3d5d2 100755 +--- a/drivers/arisc/binary/Makefile ++++ b/drivers/arisc/binary/Makefile +@@ -29,8 +29,8 @@ ifdef CONFIG_ARCH_SUN9IW1P1 + PLATFORM=arisc_sun9iw1p1 + endif + +-$(obj)/$(PLATFORM).bin : $(src)/$(PLATFORM).code +- cp $< $(obj)/$(PLATFORM).tar.bz2; \ ++$(obj)/$(PLATFORM).bin : $(obj)/$(PLATFORM).code ++ cp $(obj)/$(PLATFORM).code $(obj)/$(PLATFORM).tar.bz2; \ + tar -xjvf $(obj)/$(PLATFORM).tar.bz2 -C $(obj)/; \ + cp $(obj)/arisc_package/$(PLATFORM).bin $(obj)/$(PLATFORM).bin; \ + cp $(obj)/arisc_package/$(PLATFORM).tar.bz2.aes $(obj)/arisc; \