diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 95dccc8593..3370ea348a 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -8,7 +8,11 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr ### Additions -- N/A +- **Removed `amd-smi metric --ecc` & `amd-smi metric --ecc-blocks` on Guest VMs**. +Guest VMs do not support getting current ECC counts from the Host cards. + +- **Added `amd-smi static --ras`on Guest VMs**. +Guest VMs can view enabled/disabled ras features that are on Host cards. ### Optimizations @@ -20,6 +24,10 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr - **Updated CLI error strings to handle empty and invalid GPU/CPU inputs**. +- **Fixed Guest VM showing passthrough options**. + +- **Fixed firmware formatting where leading 0s were missing**. + ### Known Issues - N/A diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 7463a2284f..db00f18226 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1722,7 +1722,7 @@ def amdsmi_get_gpu_pm_metrics_info( def amdsmi_get_gpu_reg_table_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, - reg_type: amdsmi_reg_type_t, + reg_type: amdsmi_wrapper.amdsmi_reg_type_t, ) -> Dict[str, Any]: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( @@ -2175,8 +2175,16 @@ def amdsmi_get_fw_info( raise AmdSmiParameterException( processor_handle, amdsmi_wrapper.amdsmi_processor_handle) fw_info = amdsmi_wrapper.amdsmi_fw_info_t() - _check_res(amdsmi_wrapper.amdsmi_get_fw_info( - processor_handle, ctypes.byref(fw_info))) + _check_res( + amdsmi_wrapper.amdsmi_get_fw_info( + processor_handle, ctypes.byref(fw_info) + ) + ) + + # Certain FW blocks are padded with 0s in the front intentionally + # But the C library converts the hex to an integer which trims the leading 0s + # Nor do we have a flag that defines the expected format for each FW block + # We can expect the following blocks to have a padded value and a specified format hex_format_fw = [AmdSmiFwBlock.AMDSMI_FW_ID_PSP_SOSDRV, AmdSmiFwBlock.AMDSMI_FW_ID_TA_RAS, @@ -2185,20 +2193,33 @@ def amdsmi_get_fw_info( AmdSmiFwBlock.AMDSMI_FW_ID_VCE, AmdSmiFwBlock.AMDSMI_FW_ID_VCN] + # PM(AKA: SMC) firmware's hex value looks like 0x12345678 + # However, they are parsed as: int(0x12).int(0x34).int(0x56).int(0x78) + # Which results in the following: 12.34.56.78 dec_format_fw = [AmdSmiFwBlock.AMDSMI_FW_ID_PM] firmwares = [] for i in range(0, fw_info.num_fw_info): fw_name = AmdSmiFwBlock(fw_info.fw_info_list[i].fw_id) - fw_version = fw_info.fw_info_list[i].fw_version + fw_version = fw_info.fw_info_list[i].fw_version # This is in int format (base 10) if fw_name in hex_format_fw: - fw_version_string = ".".join(re.findall('..?', hex(fw_version)[2:])) + # Convert the fw_version from a int to a hex string padded leading 0s + fw_version_string = hex(fw_version)[2:].zfill(8) + + # Join every two hex digits with a dot + fw_version_string = ".".join(re.findall('..?', fw_version_string)) elif fw_name in dec_format_fw: + # Convert the fw_version from a int to a hex string padded leading 0s + fw_version_string = hex(fw_version)[2:].zfill(8) + # Convert every two hex digits to decimal and join them with a dot dec_version_string = '' - for ver1,ver2 in zip(hex(fw_version)[2::2], hex(fw_version)[3::2]): - dec_version_string += str(int(f"0x{ver1}{ver2}", 0)) + "." + for index, _ in enumerate(fw_version_string): + if index % 2 != 0: + continue + hex_digits = f"0x{fw_version_string[index:index+2]}" + dec_version_string += str(int(hex_digits, 16)).zfill(2) + "." fw_version_string = dec_version_string.strip('.') else: fw_version_string = str(fw_version) diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 5aa163656a..c7650bb4aa 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -759,19 +759,6 @@ amdsmi_card_form_factor_t = ctypes.c_uint32 # enum class struct_amdsmi_pcie_info_t(Structure): pass -class struct_pcie_static_(Structure): - pass - -struct_pcie_static_._pack_ = 1 # source:False -struct_pcie_static_._fields_ = [ - ('max_pcie_width', ctypes.c_uint16), - ('PADDING_0', ctypes.c_ubyte * 2), - ('max_pcie_speed', ctypes.c_uint32), - ('pcie_interface_version', ctypes.c_uint32), - ('slot_type', amdsmi_card_form_factor_t), - ('reserved', ctypes.c_uint64 * 10), -] - class struct_pcie_metric_(Structure): pass @@ -790,6 +777,19 @@ struct_pcie_metric_._fields_ = [ ('reserved', ctypes.c_uint64 * 13), ] +class struct_pcie_static_(Structure): + pass + +struct_pcie_static_._pack_ = 1 # source:False +struct_pcie_static_._fields_ = [ + ('max_pcie_width', ctypes.c_uint16), + ('PADDING_0', ctypes.c_ubyte * 2), + ('max_pcie_speed', ctypes.c_uint32), + ('pcie_interface_version', ctypes.c_uint32), + ('slot_type', amdsmi_card_form_factor_t), + ('reserved', ctypes.c_uint64 * 10), +] + struct_amdsmi_pcie_info_t._pack_ = 1 # source:False struct_amdsmi_pcie_info_t._fields_ = [ ('pcie_static', struct_pcie_static_), @@ -1351,6 +1351,15 @@ AMDSMI_GPU_BLOCK_LAST = 262144 AMDSMI_GPU_BLOCK_RESERVED = 9223372036854775808 amdsmi_gpu_block_t = ctypes.c_uint64 # enum +# values for enumeration 'amdsmi_clk_limit_type_t' +amdsmi_clk_limit_type_t__enumvalues = { + 0: 'CLK_LIMIT_MIN', + 1: 'CLK_LIMIT_MAX', +} +CLK_LIMIT_MIN = 0 +CLK_LIMIT_MAX = 1 +amdsmi_clk_limit_type_t = ctypes.c_uint32 # enum + # values for enumeration 'amdsmi_ras_err_state_t' amdsmi_ras_err_state_t__enumvalues = { 0: 'AMDSMI_RAS_ERR_STATE_NONE', @@ -2061,6 +2070,9 @@ amdsmi_get_gpu_reg_table_info.argtypes = [amdsmi_processor_handle, amdsmi_reg_ty amdsmi_set_gpu_clk_range = _libraries['libamd_smi.so'].amdsmi_set_gpu_clk_range amdsmi_set_gpu_clk_range.restype = amdsmi_status_t amdsmi_set_gpu_clk_range.argtypes = [amdsmi_processor_handle, uint64_t, uint64_t, amdsmi_clk_type_t] +amdsmi_set_gpu_clk_limit = _libraries['libamd_smi.so'].amdsmi_set_gpu_clk_limit +amdsmi_set_gpu_clk_limit.restype = amdsmi_status_t +amdsmi_set_gpu_clk_limit.argtypes = [amdsmi_processor_handle, amdsmi_clk_type_t, amdsmi_clk_limit_type_t, uint64_t] amdsmi_free_name_value_pairs = _libraries['libamd_smi.so'].amdsmi_free_name_value_pairs amdsmi_free_name_value_pairs.restype = None amdsmi_free_name_value_pairs.argtypes = [ctypes.POINTER(None)] @@ -2583,11 +2595,12 @@ __all__ = \ 'AMDSMI_VRAM_VENDOR__PLACEHOLDER5', 'AMDSMI_VRAM_VENDOR__SAMSUNG', 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', - 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'RD_BW0', 'WR_BW0', - 'amd_metrics_table_header_t', 'amdsmi_asic_info_t', - 'amdsmi_bdf_t', 'amdsmi_bit_field_t', 'amdsmi_board_info_t', - 'amdsmi_cache_property_type_t', 'amdsmi_card_form_factor_t', - 'amdsmi_clean_gpu_local_data', 'amdsmi_clk_info_t', + 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'CLK_LIMIT_MAX', 'CLK_LIMIT_MIN', + 'RD_BW0', 'WR_BW0', 'amd_metrics_table_header_t', + 'amdsmi_asic_info_t', 'amdsmi_bdf_t', 'amdsmi_bit_field_t', + 'amdsmi_board_info_t', 'amdsmi_cache_property_type_t', + 'amdsmi_card_form_factor_t', 'amdsmi_clean_gpu_local_data', + 'amdsmi_clk_info_t', 'amdsmi_clk_limit_type_t', 'amdsmi_clk_type_t', 'amdsmi_compute_partition_type_t', 'amdsmi_container_types_t', 'amdsmi_counter_command_t', 'amdsmi_counter_value_t', 'amdsmi_cpu_apb_disable', @@ -2711,7 +2724,8 @@ __all__ = \ 'amdsmi_set_cpu_socket_boostlimit', 'amdsmi_set_cpu_socket_lclk_dpm_level', 'amdsmi_set_cpu_socket_power_cap', 'amdsmi_set_cpu_xgmi_width', - 'amdsmi_set_gpu_clk_range', 'amdsmi_set_gpu_compute_partition', + 'amdsmi_set_gpu_clk_limit', 'amdsmi_set_gpu_clk_range', + 'amdsmi_set_gpu_compute_partition', 'amdsmi_set_gpu_event_notification_mask', 'amdsmi_set_gpu_fan_speed', 'amdsmi_set_gpu_memory_partition', 'amdsmi_set_gpu_od_clk_info', 'amdsmi_set_gpu_od_volt_info',