[ROCM-1036] Dynamic fan support detection in set -h (#2721)
Show "N/A" for ASICs without fan support `amd-smi set -h` fan help text will be dynamic instead of "0-255 or 0-100%" Signed-off-by: Sumanth Gavini <sumanth.gavini@amd.com>
This commit is contained in:
committed by
GitHub
orang tua
e9b143323a
melakukan
e9c72b06b0
@@ -973,6 +973,35 @@ class AMDSMIHelpers():
|
||||
return value
|
||||
|
||||
|
||||
def get_fan_support(self):
|
||||
"""Check if fan control is supported on the first device.
|
||||
|
||||
Returns:
|
||||
str: "0-255 or 0-100%%" if fan control is supported, "N/A" otherwise
|
||||
"""
|
||||
device_handles = amdsmi_interface.amdsmi_get_processor_handles()
|
||||
for dev in device_handles:
|
||||
try:
|
||||
# Try to get both fan speed and max fan speed
|
||||
# If both succeed, fan control is supported
|
||||
_ = amdsmi_interface.amdsmi_get_gpu_fan_speed(dev, 0)
|
||||
_ = amdsmi_interface.amdsmi_get_gpu_fan_speed_max(dev, 0)
|
||||
# Fan control is supported on this device
|
||||
return "0-255 or 0-100%%"
|
||||
except amdsmi_interface.AmdSmiLibraryException as e:
|
||||
logging.debug(f"AMDSMIHelpers.get_fan_support - Unable to get fan info for device {dev}: {str(e)}")
|
||||
if e.err_code == amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NOT_SUPPORTED:
|
||||
logging.debug(f"AMDSMIHelpers.get_fan_support - Device {dev} does not support fan control")
|
||||
return "N/A"
|
||||
return "N/A"
|
||||
except Exception as e:
|
||||
logging.debug(f"AMDSMIHelpers.get_fan_support - Unexpected error occurred --> Unable to get fan info for device {dev}: {str(e)}")
|
||||
return "N/A"
|
||||
# Only check the first device (socket device, never partition)
|
||||
break
|
||||
return "N/A"
|
||||
|
||||
|
||||
def get_soc_pstates(self):
|
||||
device_handles = amdsmi_interface.amdsmi_get_processor_handles()
|
||||
soc_pstate_profile_list = []
|
||||
|
||||
@@ -1354,7 +1354,8 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
# Help text for Arguments only on BM platforms
|
||||
if self.helpers.is_amdgpu_initialized():
|
||||
if self.helpers.is_baremetal():
|
||||
set_fan_help = "Set GPU fan speed (0-255 or 0-100%%)"
|
||||
fan_support = self.helpers.get_fan_support()
|
||||
set_fan_help = f"Set GPU fan speed ({fan_support})"
|
||||
perf_level_help_choices_str = ", ".join(self.helpers.get_perf_levels()[0][0:-1])
|
||||
set_perf_level_help = f"Set one of the following performance levels:\n\t{perf_level_help_choices_str}"
|
||||
power_profile_choices_str = ", ".join(self.helpers.get_power_profiles()[0:-1])
|
||||
|
||||
Reference in New Issue
Block a user