diff -Nru thermald-2.4.9/debian/changelog thermald-2.4.9/debian/changelog --- thermald-2.4.9/debian/changelog 2023-08-10 15:36:06.000000000 +0800 +++ thermald-2.4.9/debian/changelog 2024-02-20 14:03:49.000000000 +0800 @@ -1,3 +1,10 @@ +thermald (2.4.9-1ubuntu0.5) jammy; urgency=medium + + * Fix CPU thermal sensors enumeration (LP: #2054391) + - d/p/0016-Fixed-enumeration-of-cpu-thermal-sensors.patch + + -- Kai-Heng Feng Tue, 20 Feb 2024 14:03:49 +0800 + thermald (2.4.9-1ubuntu0.4) jammy; urgency=medium * Add support for Meteor Lake (LP: #2028217) diff -Nru thermald-2.4.9/debian/patches/0016-Fixed-enumeration-of-cpu-thermal-sensors.patch thermald-2.4.9/debian/patches/0016-Fixed-enumeration-of-cpu-thermal-sensors.patch --- thermald-2.4.9/debian/patches/0016-Fixed-enumeration-of-cpu-thermal-sensors.patch 1970-01-01 08:00:00.000000000 +0800 +++ thermald-2.4.9/debian/patches/0016-Fixed-enumeration-of-cpu-thermal-sensors.patch 2024-02-20 14:03:49.000000000 +0800 @@ -0,0 +1,96 @@ +From: SSchloetzer +Date: Thu, 30 Jun 2022 16:46:48 +0200 +Subject: Fixed enumeration of cpu thermal sensors + +The current code can can just enumerate 4 hwmon sensors, which +is not enough for any modern systems with more than 4 logica +CPUs. + +Instead of using a mask traverse full directory and look for +each directory for coretemp and add. + +Ref: +https://github.com/intel/thermal_daemon/issues/356 +Origin: upstream, https://github.com/intel/thermal_daemon/commit/df8ac025d22e51c237c8ebe2aa25bf672ec04edb +Bug: https://github.com/intel/thermal_daemon/issues/356 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/2054391 +--- + src/thd_engine_default.cpp | 41 ++++++++++++++++++++++++----------------- + 1 file changed, 24 insertions(+), 17 deletions(-) + +diff --git a/src/thd_engine_default.cpp b/src/thd_engine_default.cpp +index ce0e76b..153fab2 100644 +--- a/src/thd_engine_default.cpp ++++ b/src/thd_engine_default.cpp +@@ -22,6 +22,7 @@ + * + */ + ++#include + #include + #include + #include +@@ -94,7 +95,6 @@ int cthd_engine_default::read_thermal_sensors() { + int index; + DIR *dir; + struct dirent *entry; +- int sensor_mask = 0x0f; + cthd_sensor *sensor; + const std::string base_path[] = { "/sys/devices/platform/", + "/sys/class/hwmon/" }; +@@ -147,22 +147,30 @@ int cthd_engine_default::read_thermal_sensors() { + if (name != "coretemp") + continue; + +- int cnt = 0; +- unsigned int mask = 0x1; +- do { +- if (sensor_mask & mask) { +- std::stringstream temp_input_str; +- std::string path = base_path[i] + entry->d_name +- + "/"; +- csys_fs dts_sysfs(path.c_str()); +- temp_input_str << "temp" << cnt << "_input"; +- if (dts_sysfs.exists(temp_input_str.str())) { ++ std::string temp_dir_path = base_path[i] + entry->d_name ++ + "/"; ++ DIR *temp_dir = nullptr; ++ struct dirent *temp_dir_entry = nullptr; ++ int len_temp_dir_entry = 0; ++ int len_input = strlen("_input"); ++ ++ if ((temp_dir = opendir(temp_dir_path.c_str())) != NULL) { ++ while ((temp_dir_entry = readdir(temp_dir)) != NULL) { ++ len_temp_dir_entry = strlen(temp_dir_entry->d_name); ++ if ((len_temp_dir_entry >= len_input ++ && !strcmp( ++ temp_dir_entry->d_name ++ + len_temp_dir_entry ++ - len_input, "_input")) ++ && (!strncmp(temp_dir_entry->d_name, "temp", ++ strlen("temp")))) { ++ + cthd_sensor *sensor = new cthd_sensor(index, +- base_path[i] + entry->d_name + "/" +- + temp_input_str.str(), "hwmon", +- SENSOR_TYPE_RAW); ++ temp_dir_path + temp_dir_entry->d_name, ++ "hwmon", SENSOR_TYPE_RAW); + if (sensor->sensor_update() != THD_SUCCESS) { + delete sensor; ++ closedir(temp_dir); + closedir(dir); + return THD_ERROR; + } +@@ -170,9 +178,8 @@ int cthd_engine_default::read_thermal_sensors() { + ++index; + } + } +- mask = (mask << 1); +- cnt++; +- } while (mask != 0); ++ closedir(temp_dir); ++ } + } + } + closedir(dir); diff -Nru thermald-2.4.9/debian/patches/series thermald-2.4.9/debian/patches/series --- thermald-2.4.9/debian/patches/series 2023-08-10 15:36:06.000000000 +0800 +++ thermald-2.4.9/debian/patches/series 2024-02-20 14:03:49.000000000 +0800 @@ -13,3 +13,4 @@ 0013-Add-AlderLake-N.patch 0014-Process-ITMT-v2.patch 0015-Add-support-for-Mateor-Lake.patch +0016-Fixed-enumeration-of-cpu-thermal-sensors.patch