Skip to content

Commit ed7ac17

Browse files
committed
hw-mgmt: thermal: Fix module present status update and lcrit validation
On cable removal, TC should not check the module temperature value. However, since the status update interval is 60 seconds, if the cable is removed during this interval, TC reports a sensor read error. Fix: add module status update on each temperature reading. Bug: 4657183 Signed-off-by: Oleksandr Shamray <[email protected]>
1 parent c71df98 commit ed7ac17

File tree

2 files changed

+64
-36
lines changed

2 files changed

+64
-36
lines changed

usr/usr/bin/hw_management_thermal_control.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,17 +1625,17 @@ def get_fault(self):
16251625
return status
16261626

16271627
# ----------------------------------------------------------------------
1628-
def get_temp_support_status(self):
1628+
def get_temp_support_status(self, value=0):
16291629
"""
16301630
@summary: Check if module supporting temp sensor (optic)
16311631
@return: True - in case if temp sensor is supported
16321632
False - if module is not optical
16331633
"""
1634-
status = True
1634+
status = False
16351635

1636-
if self.last_value == 0 and self.val_max == 0 and self.val_min == 0:
1637-
self.log.debug("Module not supporting temp reading val:{} max:{}".format(self.value, self.val_max))
1638-
status = False
1636+
if self.val_max != 0 or value:
1637+
self.log.debug("{} support temp reading".format(self.name))
1638+
status = True
16391639

16401640
return status
16411641

@@ -1654,21 +1654,35 @@ def handle_input(self, thermal_table, flow_dir, amb_tmp):
16541654
try:
16551655
value = self.read_file_int(temp_read_file, self.scale)
16561656
self.log.debug("{} value:{}".format(self.name, value))
1657-
self.fread_err.handle_err(temp_read_file, reset=True)
1658-
# handle case if cable was replsed by the other cable with the sensor
1659-
if value != 0 and self.val_min == 0 and self.val_max == 0:
1660-
self.log.info("{} refreshing min/max arttribures by the rule: val({}) min({}) max({})".format(self.name,
1661-
value,
1662-
self.val_min,
1663-
self.val_max))
1657+
# handle case if cable was replaced by the other cable
1658+
# cable removed - value == 0 max != 0
1659+
# cable connected - value != 0 max == 0
1660+
if (value != 0 and self.val_max == 0) or (value == 0 and self.val_max != 0):
1661+
self.log.info("{} refreshing min/max attributes by the rule: val({}) max({})".format(self.name,
1662+
value,
1663+
self.val_max))
16641664
self.refresh_attr()
1665-
self.update_value(value)
16661665

1667-
if self.get_temp_support_status():
1668-
if self.value > self.val_max:
1669-
self.log.warn("{} value({}) >= ({})".format(self.name, self.value, self.val_max))
1670-
elif self.value < self.val_min:
1671-
self.log.debug("{} value {}".format(self.name, self.value))
1666+
if self.get_temp_support_status(value):
1667+
if self.val_hcrit is not None and value >= self.val_hcrit:
1668+
self.log.warn("{} value({}) >= hcrit({})".format(self.name,
1669+
value,
1670+
self.val_hcrit))
1671+
self.fread_err.handle_err(temp_read_file)
1672+
elif self.val_lcrit is not None and value <= self.val_lcrit:
1673+
self.log.warn("{} value({}) <= lcrit({})".format(self.name,
1674+
value,
1675+
self.val_lcrit))
1676+
self.fread_err.handle_err(temp_read_file)
1677+
else:
1678+
self.fread_err.handle_err(temp_read_file, reset=True)
1679+
self.update_value(value)
1680+
if self.value > self.val_max:
1681+
self.log.warn("{} value({}) >= ({})".format(self.name, self.value, self.val_max))
1682+
elif self.value < self.val_min:
1683+
self.log.debug("{} value {}".format(self.name, self.value))
1684+
else:
1685+
self.fread_err.handle_err(temp_read_file, reset=True)
16721686
except (ValueError, TypeError, OSError, IOError):
16731687
self.log.warn("value reading from file: {}".format(self.base_file_name))
16741688
self.fread_err.handle_err(temp_read_file)

usr/usr/bin/hw_management_thermal_control_2_5.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,17 +1853,17 @@ def refresh_attr(self):
18531853
self.pwm_regulator.update_param(self.val_min, self.val_max, self.pwm_min, self.pwm_max)
18541854

18551855
# ----------------------------------------------------------------------
1856-
def get_temp_support_status(self):
1856+
def get_temp_support_status(self, value=0):
18571857
"""
18581858
@summary: Check if module supporting temp sensor (optic)
18591859
@return: True - in case if temp sensor is supported
18601860
False - if module is not optical
18611861
"""
1862-
status = True
1862+
status = False
18631863

1864-
if self.val_max == 0:
1865-
self.log.debug("{} does not support temp reading max:{}".format(self.name, self.val_max))
1866-
status = False
1864+
if self.val_max != 0 or value:
1865+
self.log.debug("{} support temp reading".format(self.name))
1866+
status = True
18671867

18681868
return status
18691869

@@ -1882,21 +1882,35 @@ def handle_input(self, thermal_table, flow_dir, amb_tmp):
18821882
try:
18831883
value = self.read_file_float(temp_read_file, self.scale)
18841884
self.log.debug("{} value:{}".format(self.name, value))
1885-
self.fread_err.handle_err(temp_read_file, reset=True)
1886-
# handle case if cable was replsed by the other cable with the sensor
1887-
if value != 0 and self.val_min == 0 and self.val_max == 0:
1888-
self.log.info("{} refreshing min/max arttribures by the rule: val({}) min({}) max({})".format(self.name,
1889-
value,
1890-
self.val_min,
1891-
self.val_max))
1885+
# handle case if cable was replaced by the other cable
1886+
# cable removed - value == 0 max != 0
1887+
# cable connected - value != 0 max == 0
1888+
if (value != 0 and self.val_max == 0) or (value == 0 and self.val_max != 0):
1889+
self.log.info("{} refreshing min/max attributes by the rule: val({}) max({})".format(self.name,
1890+
value,
1891+
self.val_max))
18921892
self.refresh_attr()
1893-
self.update_value(value)
18941893

1895-
if self.get_temp_support_status():
1896-
if self.value > self.val_max:
1897-
self.log.warn("{} value({}) >= ({})".format(self.name, self.value, self.val_max))
1898-
elif self.value < self.val_min:
1899-
self.log.debug("{} value {}".format(self.name, self.value))
1894+
if self.get_temp_support_status(value):
1895+
if self.val_hcrit is not None and value >= self.val_hcrit:
1896+
self.log.warn("{} value({}) >= hcrit({})".format(self.name,
1897+
value,
1898+
self.val_hcrit))
1899+
self.fread_err.handle_err(temp_read_file)
1900+
elif self.val_lcrit is not None and value <= self.val_lcrit:
1901+
self.log.warn("{} value({}) <= lcrit({})".format(self.name,
1902+
value,
1903+
self.val_lcrit))
1904+
self.fread_err.handle_err(temp_read_file)
1905+
else:
1906+
self.fread_err.handle_err(temp_read_file, reset=True)
1907+
self.update_value(value)
1908+
if self.value > self.val_max:
1909+
self.log.warn("{} value({}) >= ({})".format(self.name, self.value, self.val_max))
1910+
elif self.value < self.val_min:
1911+
self.log.debug("{} value {}".format(self.name, self.value))
1912+
else:
1913+
self.fread_err.handle_err(temp_read_file, reset=True)
19001914
except (ValueError, TypeError, OSError, IOError):
19011915
self.log.warn("value reading from file: {}".format(self.base_file_name))
19021916
self.fread_err.handle_err(temp_read_file)

0 commit comments

Comments
 (0)