Thermal reading wrong

minimx-g ~ # grep saradc /boot/s905_autoscript.cmd
setenv boot_start "saradc open 1; booti ${kernel_loadaddr} ${initrd_loadaddr} ${dtb_mem_addr}"

minimx-g ~ # strings /boot/s905_autoscript | grep saradc
setenv boot_start "saradc open 1; booti ${kernel_loadaddr} ${initrd_loadaddr} ${dtb_mem_addr}"

minimx-g ~ # cd src/Amlogic_s905-kernel

minimx-g Amlogic_s905-kernel # git diff | cat
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index a0f6aca1c..8793aba93 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -439,9 +439,9 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
 			tz->enter_hot = 0;
 		else
 			tz->enter_hot++;
-//		dev_info(&tz->device,
-//			 "temp:%d, hyst:%ld, trip_temp:%ld, hot:%d\n",
-//			 tz->temperature, hyst, trip_temp, tz->enter_hot);
+		dev_info(&tz->device,
+			 "temp:%d, hyst:%ld, trip_temp:%ld, hot:%d\n",
+			 tz->temperature, hyst, trip_temp, tz->enter_hot);
 		if (tz->ops->notify)
 			tz->ops->notify(tz, trip, trip_type);
 	}
@@ -497,6 +497,12 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp)
 	mutex_lock(&tz->lock);
 
 	ret = tz->ops->get_temp(tz, temp);
+	if ((ret == -EINVAL) || (tz->temperature == -1000)) {
+		dev_info(&tz->device,
+			"get_temp: ret:%d temp:%d last:%d\n",
+			ret, tz->temperature, tz->last_temperature);
+		tz->temperature = tz->last_temperature;
+	}
 #ifdef CONFIG_THERMAL_EMULATION
 	if (!tz->emul_temperature)
 		goto skip_emul;

minimx-g Amlogic_s905-kernel # dmesg | grep get_temp
[   17.144572] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[   19.144753] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[   27.144207] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:39000
[   37.144682] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:39000
[   51.144190] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:38000
[   95.143872] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[  205.142194] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[  376.139658] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[  377.139309] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000

so the -1000 is effectively reported every now and then without error while previous temperature cold.

What do you mean here? does this approach works for you?

I mean: if I would -not- set temperature to be last_temperature in case of bogus temperature (not an error) then the trip thermal code would shutdown a CPU core for no good reason. Note that I have avoided the trip by pretending previous (cold) temperature.
As you see below, bogus measurement happens when otherwise temperature low…
Previously every -1000 temperature would shutdown a CPU core.

I guess I should say: the ‘saradc open 1’ did not help, but then gxbb_p200_2G.dts has no saradc section:

$ grep saradc gxbb_p200_2G.dts
$  


[ 1133.128562] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1248.126350] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1249.126289] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1274.125904] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1275.125948] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1280.125914] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1284.125857] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1315.126269] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1317.125451] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1338.125034] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:39000
[ 1427.124027] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1482.122956] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1508.122471] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1520.122295] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1523.122259] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1528.122177] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1532.122119] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1539.122024] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1549.121831] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1561.121769] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1569.121938] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 1618.120915] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1625.120748] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 1642.120439] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1731.119630] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1738.119185] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1739.119184] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1746.119087] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1748.119001] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1749.118935] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1750.119011] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1763.118691] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:39000
[ 1773.118947] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1781.118511] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1800.118517] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1808.118049] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1810.118767] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:39000
[ 1825.117923] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1837.117535] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:39000
[ 1841.117475] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1858.117602] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1859.117410] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1891.116943] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1902.116618] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 1906.116692] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 1916.116406] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1925.116241] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1929.116201] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:42000
[ 1930.116194] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:42000
[ 1937.116080] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1942.116019] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1944.115990] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1947.115938] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1953.115838] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1954.115833] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1956.115813] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1957.115785] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1962.115711] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1975.115521] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1977.115485] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1979.115467] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1984.115385] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 1991.115276] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 1998.115183] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2008.115026] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2012.114968] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2013.114929] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2018.114881] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2026.114765] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:60000
[ 2037.114593] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2038.114586] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2042.114522] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2050.114405] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2055.114327] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2057.114296] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2065.114180] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2078.113987] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2081.113938] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2082.113927] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2085.113857] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2090.113811] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2094.113754] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2096.113712] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2099.113667] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2110.113496] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2112.113437] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2113.113442] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2122.113320] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2126.113216] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2135.113096] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2145.113076] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2450.108812] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 2461.108434] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 2463.108255] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:56000
[ 2465.108600] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2467.108216] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2473.108172] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2482.108001] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2501.107784] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2510.107576] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2512.107688] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2514.107656] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2519.107447] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2520.107452] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2521.107602] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2523.107522] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2533.107236] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2544.107053] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2550.107129] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2557.106870] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2567.106739] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2568.106763] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2569.106869] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2581.106517] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2597.106285] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2598.106341] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2603.106342] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2606.106187] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2608.106295] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:42000
[ 2616.106113] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2739.104504] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:57000
[ 2777.104413] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2779.103594] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2782.103539] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 2786.103487] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:40000
[ 2788.103446] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2790.103376] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2793.103365] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2800.103273] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:41000
[ 2818.103032] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:48000
[ 2828.102868] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:59000
[ 2833.102828] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2834.102814] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2844.102653] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2845.102606] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2850.102498] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2854.102491] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2861.102388] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2866.102219] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2871.102230] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:42000
[ 2886.101974] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2888.101995] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:43000
[ 2896.101877] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:46000
[ 2908.101738] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:62000
[ 2921.101536] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:49000
[ 2930.101387] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:46000
[ 2934.101236] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:62000
[ 2938.101178] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2939.101171] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2941.101237] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2943.101122] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:61000
[ 2952.101007] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2954.100977] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 2961.100916] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2988.100491] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 2991.100399] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:46000
[ 3000.100336] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 3010.100148] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 3026.099935] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 3027.099958] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:45000
[ 3033.099857] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 3039.099713] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 3048.099609] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 3056.099507] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:60000
[ 3058.099456] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 3071.099184] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:44000
[ 3093.098957] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:50000

It works fine here for VIM/S905X, no idea for S905 :wink:

1 Like

Thanks, and no worries, Gouwa, it was worth trying.
update:
I tried to boot using minimx-g.dtb (built from my firmware android decompiled dtb.img). That did not seem to boot (perhaps I did not wait long enough), so I booted using LE gxbb_p200_2G.dtb as usual. Now the -1000 temperature is no longer logged. Note that minimx-g.dts, unlike gxbb_p200_2G.dts has a saradc section. I agree it does not make much sense (at least not to me). So perhaps the occasional -1000 temperature is not consistent across reboots.
update:
After 2 days uptime some occasional -1000 temperature results are seen:
[34911.775121] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:50000
[34922.775289] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:50000
[34973.774510] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:51000
[35244.770478] thermal thermal_zone0: get_temp: ret:0 temp:-1000 last:35000

This may be completely unrelated but I noticed what appears to be a power management bug via SunnyTV’s S912 builds after Sep 24. Their tv box has a metal case and with thermal pads added after the newer firmware the temperature went up about 10C (iirc). Swapping out u-boot/dtb seemed to indicate it was a problem with it. I’m not sure if it was a reporting difference or an actual increase in temperature.

The primary difference I could find in the dtb was related to the following additions:

These entries under each cpu:

cpu-idle-states = <0x16 0x17>;

And this entry:

       idle-states {
               entry-method = "arm,psci";

               cpu-sleep-0 {
                       compatible = "arm, idle-state";
                       arm,psci-suspend-param = <0x10000>;
                       local-timer-stop;
                       entry-latency-us = <0x1388>;
                       exit-latency-us = <0x1f40>;
                       min-residency-us = <0x4e20>;
               };

               cluster-sleep-0 {
                       compatible = "arm, idle-state";
                       arm,psci-suspend-param = <0x1010000>;
                       local-timer-stop;
                       entry-latency-us = <0x1388>;
                       exit-latency-us = <0x1f40>;
                       min-residency-us = <0x61a8>;
               };
       };

This would appear to be adding support for idle mode which should lower temperatures but it seemed to have the opposite effect, heh.