Skip to content

Commit

Permalink
hw-mgmt: thermal: TC fix crash for unsuppotred platform
Browse files Browse the repository at this point in the history
In case hw-mgmgt running on unknown platform - TC should
treat it as "Unsupported platform".

Bug 4032775

Signed-off-by: Oleksandr Shamray <[email protected]>
  • Loading branch information
sholeksandr committed Aug 14, 2024
1 parent a3ab216 commit a89a7e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion usr/usr/bin/hw-management.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@ do_start()
if [ -v "thermal_control_config" ] && [ -f $thermal_control_config ]; then
cp $thermal_control_config $config_path/tc_config.json
else
cp $thermal_control_configs_path/tc_config_default.json $config_path/tc_config.json
cp $thermal_control_configs_path/tc_config_not_supported.json $config_path/tc_config.json
fi
log_info "Init completed."
}
Expand Down
17 changes: 12 additions & 5 deletions usr/usr/bin/hw_management_thermal_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ def str2bool(val):
"""
if isinstance(val, bool):
return val
if val.lower() in ("yes", "true", "t", "y", "1"):
elif isinstance(val, int):
return bool(val)
elif val.lower() in ("yes", "true", "t", "y", "1"):
return True
elif val.lower() in ("no", "false", "f", "n", "0"):
return False
Expand Down Expand Up @@ -2472,8 +2474,8 @@ def __init__(self, cmd_arg, tc_logger):
self.exit_flag = False

self.load_configuration()
if not self.sys_config.get("platform_support", 1):
self.log.notice("Platform Board:{}, SKU:{} is not supported.".format(self.board_type, self.sku), 1)
if not str2bool(self.sys_config.get("platform_support", 1)):
self.log.notice("Platform Board:'{}', SKU:'{}' is not supported.".format(self.board_type, self.sku), 1)
self.log.notice("Set TC to idle.")
while True:
self.exit.wait(60)
Expand Down Expand Up @@ -2983,9 +2985,14 @@ def load_configuration(self):
if "name" in sys_config.keys():
self.log.info("System data: {}".format(sys_config["name"]))
except Exception:
self.log.error("System config file {} broken. Applying default config.".format(config_file_name), 1)
self.log.error("System config file {} broken.".format(config_file_name), 1)
sys_config["platform_support"] = 0
else:
self.log.warn("System config file {} missing. Applying default config.".format(config_file_name), 1)
self.log.warn("System config file {} missing. Platform: '{}'/'{}'/'{}' is not supported.".format(config_file_name,
self.board_type,
self.sku,
self.system_ver), 1)
sys_config["platform_support"] = 0

# 1. Init dmin table
if CONST.SYS_CONF_DMIN not in sys_config:
Expand Down

0 comments on commit a89a7e3

Please sign in to comment.