From e9c72b06b07ec693e0cab45ee32b360257a58b21 Mon Sep 17 00:00:00 2001 From: Sumanth Gavini Date: Wed, 28 Jan 2026 22:44:25 -0600 Subject: [PATCH] [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 --- projects/amdsmi/amdsmi_cli/amdsmi_helpers.py | 29 ++++++++++++++++++++ projects/amdsmi/amdsmi_cli/amdsmi_parser.py | 3 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py b/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py index d2e4d25a3e..a58ed219be 100755 --- a/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py @@ -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 = [] diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py index 5b57e44cd5..f3f65f989d 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py @@ -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])