From dd6ddcacb2b0b4ceca183ff2ace47cd6c361e34c Mon Sep 17 00:00:00 2001 From: Oleksandr Shamray Date: Wed, 2 Aug 2023 17:55:10 +0300 Subject: [PATCH] hw-mgmt: thermal: Fix ASIC tz mode In case ASIC starts after TC it can set thermal zone mode to 'step_wise'. This fix set thermal zone policy to 'user_space' after ASIC start. Signed-off-by: Oleksandr Shamray --- usr/usr/bin/hw_management_thermal_control.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/usr/usr/bin/hw_management_thermal_control.py b/usr/usr/bin/hw_management_thermal_control.py index f9faa24c1..32ac2672a 100755 --- a/usr/usr/bin/hw_management_thermal_control.py +++ b/usr/usr/bin/hw_management_thermal_control.py @@ -1250,7 +1250,6 @@ def sensor_configure(self): """ @summary: this function calling on sensor start after initialization or suspend off """ - # Disable kernel control for this thermal zone self.refresh_attr() if "asic" in self.base_file_name: tz_name = "mlxsw" @@ -1258,9 +1257,15 @@ def sensor_configure(self): tz_name = "mlxsw-{}".format(self.base_file_name) tz_policy_filename = "thermal/{}/thermal_zone_policy".format(tz_name) tz_mode_filename = "thermal/{}/thermal_zone_mode".format(tz_name) + + self.log.info("Configure module {} policy".format(tz_name)) + # Disable kernel control for this thermal zone try: - self.write_file(tz_policy_filename, "user_space") - self.write_file(tz_mode_filename, "disabled") + policy = self.read_file(tz_policy_filename) + # do not set policy if tz already configured + if "user_space" not in policy: + self.write_file(tz_policy_filename, "user_space") + self.write_file(tz_mode_filename, "disabled") except BaseException: pass @@ -1330,6 +1335,9 @@ def handle_input(self, thermal_table, flow_dir, amb_tmp): else: try: temperature = int(self.read_file(temp_read_file)) + if temp_read_file in self.check_reading_file_err(): + # senor returned back. Reconfigure module. + self.sensor_configure() self.handle_reading_file_err(temp_read_file, reset=True) temperature /= CONST.TEMP_SENSOR_SCALE self.log.debug("{} value:{}".format(self.name, temperature))