diff --git a/docs/ROCm_SMI_Manual.pdf b/docs/ROCm_SMI_Manual.pdf index 876670d61a..53f5645fdb 100644 Binary files a/docs/ROCm_SMI_Manual.pdf and b/docs/ROCm_SMI_Manual.pdf differ diff --git a/include/rocm_smi/rocm_smi.h b/include/rocm_smi/rocm_smi.h index a2ce6f5f21..798ba579b0 100755 --- a/include/rocm_smi/rocm_smi.h +++ b/include/rocm_smi/rocm_smi.h @@ -771,8 +771,15 @@ rsmi_status_t rsmi_num_monitor_devices(uint32_t *num_devices); * * @param[inout] id a pointer to uint64_t to which the device id will be * written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_id_get(uint32_t dv_ind, uint16_t *id); @@ -789,8 +796,15 @@ rsmi_status_t rsmi_dev_id_get(uint32_t dv_ind, uint16_t *id); * * @param[inout] id a pointer to uint64_t to which the device vendor id will * be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_vendor_id_get(uint32_t dv_ind, uint16_t *id); @@ -813,10 +827,17 @@ rsmi_status_t rsmi_dev_vendor_id_get(uint32_t dv_ind, uint16_t *id); * * @param[inout] name a pointer to a caller provided char buffer to which the * name will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * * @param[in] len the length of the caller provided buffer @p name. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not * large enough to hold the entire name. In this case, only @p len bytes will * be written. @@ -840,10 +861,20 @@ rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len); * * @param[inout] brand a pointer to a caller provided char buffer to which the * brand will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * * @param[in] len the length of the caller provided buffer @p brand. - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not + * large enough to hold the entire name. In this case, only @p len bytes will + * be written. * */ rsmi_status_t rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len); @@ -866,10 +897,17 @@ rsmi_status_t rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len); * * @param[inout] name a pointer to a caller provided char buffer to which the * name will be written - * + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. + * @param[in] len the length of the caller provided buffer @p name. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not * large enough to hold the entire name. In this case, only @p len bytes will * be written. @@ -915,10 +953,17 @@ rsmi_status_t rsmi_dev_vram_vendor_get(uint32_t dv_ind, char *brand, * * @param[inout] serial_num a pointer to caller-provided memory to which the * serial number will be written - * + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. + * @param[in] len the length of the caller provided buffer @p serial_num. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not * large enough to hold the entire name. In this case, only @p len bytes will * be written. @@ -938,8 +983,15 @@ rsmi_status_t rsmi_dev_serial_number_get(uint32_t dv_ind, * * @param[inout] id a pointer to uint64_t to which the subsystem device id * will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_subsystem_id_get(uint32_t dv_ind, uint16_t *id); @@ -962,10 +1014,17 @@ rsmi_status_t rsmi_dev_subsystem_id_get(uint32_t dv_ind, uint16_t *id); * * @param[inout] name a pointer to a caller provided char buffer to which the * name will be written - * + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. + * @param[in] len the length of the caller provided buffer @p name. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not * large enough to hold the entire name. In this case, only @p len bytes will * be written. @@ -988,6 +1047,7 @@ rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len); * @retval :: RSMI_STATUS_SUCCESS is returned upon successful call. * @retval :: RSMI_STATUS_INIT_ERROR if failed to get minor number during * initialization. + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1005,9 +1065,15 @@ rsmi_dev_drm_render_minor_get(uint32_t dv_ind, uint32_t *minor); * * @param[inout] id a pointer to uint64_t to which the device subsystem vendor * id will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_subsystem_vendor_id_get(uint32_t dv_ind, uint16_t *id); @@ -1022,8 +1088,15 @@ rsmi_status_t rsmi_dev_subsystem_vendor_id_get(uint32_t dv_ind, uint16_t *id); * * @param[inout] id a pointer to uint64_t to which the unique ID of the GPU * is written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *id); @@ -1079,9 +1152,15 @@ rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth_t *bandwidth); * * @param[inout] bdfid a pointer to uint64_t to which the device bdfid value * will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid); @@ -1106,6 +1185,8 @@ rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid); * size will be written. If pointer is NULL, it will be ignored. * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments */ rsmi_status_t rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent, uint64_t *received, uint64_t *max_pkt_sz); @@ -1122,8 +1203,15 @@ rsmi_status_t rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent, * * @param[inout] counter a pointer to uint64_t to which the sum of the NAK's * received and generated by the GPU is written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_pci_replay_counter_get(uint32_t dv_ind, uint64_t *counter); @@ -1159,6 +1247,10 @@ rsmi_status_t rsmi_dev_pci_replay_counter_get(uint32_t dv_ind, * bandwidths that are to be enabled (1) and disabled (0). Only the lowest * ::rsmi_frequencies_t::num_supported (of ::rsmi_pcie_bandwidth_t) bits of * this mask are relevant. + * + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_PERMISSION function requires root access + * */ rsmi_status_t rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask); @@ -1184,9 +1276,15 @@ rsmi_status_t rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask); * * @param[inout] power a pointer to uint64_t to which the average power * consumption will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power); @@ -1206,9 +1304,15 @@ rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power); * * @param[inout] cap a pointer to a uint64_t that indicates the power cap, * in microwatts + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_power_cap_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *cap); @@ -1226,11 +1330,22 @@ rsmi_dev_power_cap_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *cap); * * @param[inout] max a pointer to a uint64_t that indicates the maximum * possible power cap, in microwatts + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * * @param[inout] min a pointer to a uint64_t that indicates the minimum * possible power cap, in microwatts + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1256,31 +1371,34 @@ rsmi_dev_power_cap_range_get(uint32_t dv_ind, uint32_t sensor_ind, * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. * If a device has more than one sensor, it could be greater than 0. * - * @param[inout] cap a uint64_t that indicates the desired power cap, in + * @param[in] cap a uint64_t that indicates the desired power cap, in * microwatts * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap); /** - * @brief Set the power profile + * @brief Set the power profile * - * @details Given a device index @p dv_ind and a @p profile, this function will - * attempt to set the current profile to the provided profile. The provided - * profile must be one of the currently supported profiles, as indicated by a - * call to ::rsmi_dev_power_profile_presets_get() + * @details Given a device index @p dv_ind and a @p profile, this function will + * attempt to set the current profile to the provided profile. The provided + * profile must be one of the currently supported profiles, as indicated by a + * call to ::rsmi_dev_power_profile_presets_get() * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] reserved Not currently used. Set to 0. + * @param[in] reserved Not currently used. Set to 0. * - * @param[in] profile a ::rsmi_power_profile_preset_masks_t that hold the mask - * of the desired new power profile + * @param[in] profile a ::rsmi_power_profile_preset_masks_t that hold the mask + * of the desired new power profile * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t @@ -1311,8 +1429,15 @@ rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t reserved, * * @param[inout] total a pointer to uint64_t to which the total amount of * memory will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1334,8 +1459,15 @@ rsmi_dev_memory_total_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, * * @param[inout] used a pointer to uint64_t to which the amount of memory * currently being used will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1343,51 +1475,64 @@ rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, uint64_t *used); /** - * @brief Get percentage of time any device memory is being used + * @brief Get percentage of time any device memory is being used * - * @details Given a device index @p dv_ind, this function returns the - * percentage of time that any device memory is being used for the specified - * device. + * @details Given a device index @p dv_ind, this function returns the + * percentage of time that any device memory is being used for the specified + * device. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] busy_percent a pointer to the uint32_t to which the busy - * percent will be written + * @param[inout] busy_percent a pointer to the uint32_t to which the busy + * percent will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_memory_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent); /** - * @brief Get information about reserved ("retired") memory pages + * @brief Get information about reserved ("retired") memory pages * - * @details Given a device index @p dv_ind, this function returns retired page - * information @p records corresponding to the device with the provided device - * index @p dv_ind. The number of retired page records is returned through @p - * num_pages. @p records may be NULL on input. In this case, the number of - * records available for retrieval will be returned through @p num_pages. + * @details Given a device index @p dv_ind, this function returns retired page + * information @p records corresponding to the device with the provided device + * index @p dv_ind. The number of retired page records is returned through @p + * num_pages. @p records may be NULL on input. In this case, the number of + * records available for retrieval will be returned through @p num_pages. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] num_pages a pointer to a uint32. As input, the value passed - * through this parameter is the number of ::rsmi_retired_page_record_t's that - * may be safely written to the memory pointed to by @p records. This is the - * limit on how many records will be written to @p records. On return, @p - * num_pages will contain the number of records written to @p records, or the - * number of records that could have been written if enough memory had been - * provided. + * @param[inout] num_pages a pointer to a uint32. As input, the value passed + * through this parameter is the number of ::rsmi_retired_page_record_t's that + * may be safely written to the memory pointed to by @p records. This is the + * limit on how many records will be written to @p records. On return, @p + * num_pages will contain the number of records written to @p records, or the + * number of records that could have been written if enough memory had been + * provided. + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @param[inout] records A pointer to a block of memory to which the - * ::rsmi_retired_page_record_t values will be written. This value may be NULL. - * In this case, this function can be used to query how many records are - * available to read. + * @param[inout] records A pointer to a block of memory to which the + * ::rsmi_retired_page_record_t values will be written. This value may be NULL. + * In this case, this function can be used to query how many records are + * available to read. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - * ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if more records were available - * than allowed by the provided, allocated memory. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if more records were available + * than allowed by the provided, allocated memory. */ rsmi_status_t rsmi_dev_memory_reserved_pages_get(uint32_t dv_ind, uint32_t *num_pages, @@ -1414,31 +1559,45 @@ rsmi_dev_memory_reserved_pages_get(uint32_t dv_ind, uint32_t *num_pages, * * @param[inout] speed a pointer to uint32_t to which the speed will be * written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_fan_rpms_get(uint32_t dv_ind, uint32_t sensor_ind, int64_t *speed); /** - * @brief Get the fan speed for the specified device as a value relative to - * ::RSMI_MAX_FAN_SPEED + * @brief Get the fan speed for the specified device as a value relative to + * ::RSMI_MAX_FAN_SPEED * - * @details Given a device index @p dv_ind and a pointer to a uint32_t - * @p speed, this function will write the current fan speed (a value - * between 0 and the maximum fan speed, ::RSMI_MAX_FAN_SPEED) to the uint32_t - * pointed to by @p speed + * @details Given a device index @p dv_ind and a pointer to a uint32_t + * @p speed, this function will write the current fan speed (a value + * between 0 and the maximum fan speed, ::RSMI_MAX_FAN_SPEED) to the uint32_t + * pointed to by @p speed * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. - * If a device has more than one sensor, it could be greater than 0. + * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. + * If a device has more than one sensor, it could be greater than 0. * - * @param[inout] speed a pointer to uint32_t to which the speed will be - * written + * @param[inout] speed a pointer to uint32_t to which the speed will be + * written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_fan_speed_get(uint32_t dv_ind, @@ -1458,8 +1617,15 @@ rsmi_status_t rsmi_dev_fan_speed_get(uint32_t dv_ind, * * @param[inout] max_speed a pointer to uint32_t to which the maximum speed * will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_fan_speed_max_get(uint32_t dv_ind, @@ -1484,8 +1650,15 @@ rsmi_status_t rsmi_dev_fan_speed_max_get(uint32_t dv_ind, * * @param[inout] temperature a pointer to int64_t to which the temperature * will be written, in millidegrees Celcius. + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type, @@ -1498,36 +1671,43 @@ rsmi_status_t rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type, * @{ */ /** - * @brief Reset the fan to automatic driver control + * @brief Reset the fan to automatic driver control * - * @details This function returns control of the fan to the system + * @details This function returns control of the fan to the system * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. - * If a device has more than one sensor, it could be greater than 0. + * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. + * If a device has more than one sensor, it could be greater than 0. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + */ rsmi_status_t rsmi_dev_fan_reset(uint32_t dv_ind, uint32_t sensor_ind); /** - * @brief Set the fan speed for the specified device with the provided speed, - * in RPMs. + * @brief Set the fan speed for the specified device with the provided speed, + * in RPMs. * - * @details Given a device index @p dv_ind and a integer value indicating - * speed @p speed, this function will attempt to set the fan speed to @p speed. - * An error will be returned if the specified speed is outside the allowable - * range for the device. The maximum value is 255 and the minimum is 0. + * @details Given a device index @p dv_ind and a integer value indicating + * speed @p speed, this function will attempt to set the fan speed to @p speed. + * An error will be returned if the specified speed is outside the allowable + * range for the device. The maximum value is 255 and the minimum is 0. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. - * If a device has more than one sensor, it could be greater than 0. + * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. + * If a device has more than one sensor, it could be greater than 0. * - * @param[in] speed the speed to which the function will attempt to set the fan + * @param[in] speed the speed to which the function will attempt to set the fan + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_PERMISSION function requires root access * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. */ rsmi_status_t rsmi_dev_fan_speed_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t speed); @@ -1541,19 +1721,26 @@ rsmi_status_t rsmi_dev_fan_speed_set(uint32_t dv_ind, uint32_t sensor_ind, */ /** - * @brief Get percentage of time device is busy doing any processing + * @brief Get percentage of time device is busy doing any processing * - * @details Given a device index @p dv_ind, this function returns the - * percentage of time that the specified device is busy. The device is - * considered busy if any one or more of its sub-blocks are working, and idle - * if none of the sub-blocks are working. + * @details Given a device index @p dv_ind, this function returns the + * percentage of time that the specified device is busy. The device is + * considered busy if any one or more of its sub-blocks are working, and idle + * if none of the sub-blocks are working. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] busy_percent a pointer to the uint32_t to which the busy - * percent will be written + * @param[inout] busy_percent a pointer to the uint32_t to which the busy + * percent will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1571,8 +1758,15 @@ rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent); * * @param[inout] perf a pointer to ::rsmi_dev_perf_level_t to which the * performance level will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_perf_level_get(uint32_t dv_ind, @@ -1590,8 +1784,15 @@ rsmi_status_t rsmi_dev_perf_level_get(uint32_t dv_ind, * * @param[inout] od a pointer to uint32_t to which the overdrive percentage * will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_overdrive_level_get(uint32_t dv_ind, uint32_t *od); @@ -1612,85 +1813,117 @@ rsmi_status_t rsmi_dev_overdrive_level_get(uint32_t dv_ind, uint32_t *od); * @param[inout] f a pointer to a caller provided ::rsmi_frequencies_t structure * to which the frequency information will be written. Frequency values are in * Hz. + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, rsmi_clk_type_t clk_type, rsmi_frequencies_t *f); /** - * @brief This function retrieves the voltage/frequency curve information + * @brief This function retrieves the voltage/frequency curve information * - * @details Given a device index @p dv_ind and a pointer to a - * ::rsmi_od_volt_freq_data_t structure @p odv, this function will populate @p - * odv. See ::rsmi_od_volt_freq_data_t for more details. + * @details Given a device index @p dv_ind and a pointer to a + * ::rsmi_od_volt_freq_data_t structure @p odv, this function will populate @p + * odv. See ::rsmi_od_volt_freq_data_t for more details. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] odv a pointer to an ::rsmi_od_volt_freq_data_t structure + * @param[inout] odv a pointer to an ::rsmi_od_volt_freq_data_t structure + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data_t *odv); /** - * @brief This function will retrieve the current valid regions in the - * frequency/voltage space. + * @brief This function will retrieve the current valid regions in the + * frequency/voltage space. * - * @details Given a device index @p dv_ind, a pointer to an unsigned integer - * @p num_regions and a buffer of ::rsmi_freq_volt_region_t structures, @p - * buffer, this function will populate @p buffer with the current - * frequency-volt space regions. The caller should assign @p buffer to memory - * that can be written to by this function. The caller should also - * indicate the number of ::rsmi_freq_volt_region_t structures that can safely - * be written to @p buffer in @p num_regions. + * @details Given a device index @p dv_ind, a pointer to an unsigned integer + * @p num_regions and a buffer of ::rsmi_freq_volt_region_t structures, @p + * buffer, this function will populate @p buffer with the current + * frequency-volt space regions. The caller should assign @p buffer to memory + * that can be written to by this function. The caller should also + * indicate the number of ::rsmi_freq_volt_region_t structures that can safely + * be written to @p buffer in @p num_regions. * - * The number of regions to expect this function provide (@p num_regions) can - * be obtained by calling ::rsmi_dev_od_volt_info_get(). + * The number of regions to expect this function provide (@p num_regions) can + * be obtained by calling ::rsmi_dev_od_volt_info_get(). * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] num_regions As input, this is the number of - * ::rsmi_freq_volt_region_t structures that can be written to @p buffer. As - * output, this is the number of ::rsmi_freq_volt_region_t structures that were - * actually written. + * @param[inout] num_regions As input, this is the number of + * ::rsmi_freq_volt_region_t structures that can be written to @p buffer. As + * output, this is the number of ::rsmi_freq_volt_region_t structures that were + * actually written. + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @param[inout] buffer a caller provided buffer to which - * ::rsmi_freq_volt_region_t structures will be written + * @param[inout] buffer a caller provided buffer to which + * ::rsmi_freq_volt_region_t structures will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_od_volt_curve_regions_get(uint32_t dv_ind, uint32_t *num_regions, rsmi_freq_volt_region_t *buffer); /** - * @brief Get the list of available preset power profiles and an indication of - * which profile is currently active. + * @brief Get the list of available preset power profiles and an indication of + * which profile is currently active. * - * @details Given a device index @p dv_ind and a pointer to a - * ::rsmi_power_profile_status_t @p status, this function will set the bits of - * the ::rsmi_power_profile_status_t.available_profiles bit field of @p status to - * 1 if the profile corresponding to the respective - * ::rsmi_power_profile_preset_masks_t profiles are enabled. For example, if both - * the VIDEO and VR power profiles are available selections, then - * ::RSMI_PWR_PROF_PRST_VIDEO_MASK AND'ed with - * ::rsmi_power_profile_status_t.available_profiles will be non-zero as will - * ::RSMI_PWR_PROF_PRST_VR_MASK AND'ed with - * ::rsmi_power_profile_status_t.available_profiles. Additionally, - * ::rsmi_power_profile_status_t.current will be set to the - * ::rsmi_power_profile_preset_masks_t of the profile that is currently active. + * @details Given a device index @p dv_ind and a pointer to a + * ::rsmi_power_profile_status_t @p status, this function will set the bits of + * the ::rsmi_power_profile_status_t.available_profiles bit field of @p status to + * 1 if the profile corresponding to the respective + * ::rsmi_power_profile_preset_masks_t profiles are enabled. For example, if both + * the VIDEO and VR power profiles are available selections, then + * ::RSMI_PWR_PROF_PRST_VIDEO_MASK AND'ed with + * ::rsmi_power_profile_status_t.available_profiles will be non-zero as will + * ::RSMI_PWR_PROF_PRST_VR_MASK AND'ed with + * ::rsmi_power_profile_status_t.available_profiles. Additionally, + * ::rsmi_power_profile_status_t.current will be set to the + * ::rsmi_power_profile_preset_masks_t of the profile that is currently active. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. - * If a device has more than one sensor, it could be greater than 0. + * @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0. + * If a device has more than one sensor, it could be greater than 0. * - * @param[inout] status a pointer to ::rsmi_power_profile_status_t that will be - * populated by a call to this function + * @param[inout] status a pointer to ::rsmi_power_profile_status_t that will be + * populated by a call to this function + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1718,6 +1951,9 @@ rsmi_dev_power_profile_presets_get(uint32_t dv_ind, uint32_t sensor_ind, * @param[in] perf_lvl the value to which the performance level should be set * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t @@ -1756,7 +1992,10 @@ rsmi_dev_perf_level_set(int32_t dv_ind, rsmi_dev_perf_level_t perf_lvl); * * @param[in] od the value to which the overdrive level should be set * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t rsmi_dev_overdrive_level_set(int32_t dv_ind, uint32_t od); @@ -1788,6 +2027,12 @@ rsmi_status_t rsmi_dev_overdrive_level_set(int32_t dv_ind, uint32_t od); * @param[in] freq_bitmask A bitmask indicating the indices of the * frequencies that are to be enabled (1) and disabled (0). Only the lowest * ::rsmi_frequencies_t.num_supported bits of this mask are relevant. + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_PERMISSION function requires root access + * */ rsmi_status_t rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind, rsmi_clk_type_t clk_type, uint64_t freq_bitmask); @@ -1817,66 +2062,85 @@ rsmi_status_t rsmi_version_get(rsmi_version_t *version); /** - * @brief Get the driver version string for the current system. + * @brief Get the driver version string for the current system. * - * @details Given a software component @p component, a pointer to a char - * buffer, @p ver_str, this function will write the driver version string - * (up to @p len characters) for the current system to @p ver_str. The caller - * must ensure that it is safe to write at least @p len characters to @p - * ver_str. + * @details Given a software component @p component, a pointer to a char + * buffer, @p ver_str, this function will write the driver version string + * (up to @p len characters) for the current system to @p ver_str. The caller + * must ensure that it is safe to write at least @p len characters to @p + * ver_str. * - * @param[in] component The component for which the version string is being - * requested + * @param[in] component The component for which the version string is being + * requested * - * @param[inout] ver_str A pointer to a buffer of char's to which the VBIOS - * name will be written + * @param[inout] ver_str A pointer to a buffer of char's to which the version + * of @p component will be written * - * @param[in] len The number of char's pointed to by @p ver_str which can - * safely be written to by this function. + * @param[in] len the length of the caller provided buffer @p name. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not + * large enough to hold the entire name. In this case, only @p len bytes will + * be written. */ rsmi_status_t rsmi_version_str_get(rsmi_sw_component_t component, char *ver_str, uint32_t len); /** - * @brief Get the VBIOS identifer string + * @brief Get the VBIOS identifer string * - * @details Given a device ID @p dv_ind, and a pointer to a char buffer, - * @p vbios, this function will write the VBIOS string (up to @p len - * characters) for device @p dv_ind to @p vbios. The caller must ensure that - * it is safe to write at least @p len characters to @p vbios. + * @details Given a device ID @p dv_ind, and a pointer to a char buffer, + * @p vbios, this function will write the VBIOS string (up to @p len + * characters) for device @p dv_ind to @p vbios. The caller must ensure that + * it is safe to write at least @p len characters to @p vbios. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] vbios A pointer to a buffer of char's to which the VBIOS name - * will be written + * @param[inout] vbios A pointer to a buffer of char's to which the VBIOS name + * will be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @param[in] len The number of char's pointed to by @p vbios which can safely - * be written to by this function. + * @param[in] len The number of char's pointed to by @p vbios which can safely + * be written to by this function. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len); /** - * @brief Get the firmware versions for a device + * @brief Get the firmware versions for a device * - * @details Given a device ID @p dv_ind, and a pointer to a uint64_t, - * @p fw_version, this function will write the FW Versions as a string (up to @p len - * characters) for device @p dv_ind to @p vbios. The caller must ensure that - * it is safe to write at least @p len characters to @p vbios. + * @details Given a device ID @p dv_ind, and a pointer to a uint64_t, + * @p fw_version, this function will write the FW Versions as a string (up to @p len + * characters) for device @p dv_ind to @p vbios. The caller must ensure that + * it is safe to write at least @p len characters to @p vbios. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] block The firmware block for which the version is being requested + * @param[in] block The firmware block for which the version is being requested * - * @param[inout] fw_version The version for the firmware block + * @param[inout] fw_version The version for the firmware block + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -1893,86 +2157,102 @@ rsmi_dev_firmware_version_get(uint32_t dv_ind, rsmi_fw_block_t block, */ /** - * @brief Retrieve the error counts for a GPU block + * @brief Retrieve the error counts for a GPU block * - * @details Given a device index @p dv_ind, an ::rsmi_gpu_block_t @p block and a - * pointer to an ::rsmi_error_count_t @p ec, this function will write the error - * count values for the GPU block indicated by @p block to memory pointed to by - * @p ec. + * @details Given a device index @p dv_ind, an ::rsmi_gpu_block_t @p block and a + * pointer to an ::rsmi_error_count_t @p ec, this function will write the error + * count values for the GPU block indicated by @p block to memory pointed to by + * @p ec. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] block The block for which error counts should be retrieved + * @param[in] block The block for which error counts should be retrieved * - * @param[inout] ec A pointer to an ::rsmi_error_count_t to which the error - * counts should be written + * @param[inout] ec A pointer to an ::rsmi_error_count_t to which the error + * counts should be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - * ::RSMI_STATUS_NOT_SUPPORTED will be returned if either ECC is not enabled - * for the specified block @p block, or if there is no kernel support for ECC - * for that block. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_ecc_count_get(uint32_t dv_ind, rsmi_gpu_block_t block, rsmi_error_count_t *ec); /** - * @brief Retrieve the enabled ECC bit-mask + * @brief Retrieve the enabled ECC bit-mask * - * @details Given a device index @p dv_ind, and a pointer to a uint64_t @p - * enabled_mask, this function will write bits to memory pointed to by - * @p enabled_blocks. Upon a successful call, @p enabled_blocks can then be - * AND'd with elements of the ::rsmi_gpu_block_t ennumeration to determine if - * the corresponding block has ECC enabled. Note that whether a block has ECC - * enabled or not in the device is independent of whether there is kernel - * support for error counting for that block. Although a block may be enabled, - * but there may not be kernel support for reading error counters for that - * block. + * @details Given a device index @p dv_ind, and a pointer to a uint64_t @p + * enabled_mask, this function will write bits to memory pointed to by + * @p enabled_blocks. Upon a successful call, @p enabled_blocks can then be + * AND'd with elements of the ::rsmi_gpu_block_t ennumeration to determine if + * the corresponding block has ECC enabled. Note that whether a block has ECC + * enabled or not in the device is independent of whether there is kernel + * support for error counting for that block. Although a block may be enabled, + * but there may not be kernel support for reading error counters for that + * block. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] enabled_blocks A pointer to a uint64_t to which the enabled - * blocks bits will be written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @param[inout] enabled_blocks A pointer to a uint64_t to which the enabled + * blocks bits will be written. + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid */ rsmi_status_t rsmi_dev_ecc_enabled_get(uint32_t dv_ind, uint64_t *enabled_blocks); /** - * @brief Retrieve the ECC status for a GPU block + * @brief Retrieve the ECC status for a GPU block * - * @details Given a device index @p dv_ind, an ::rsmi_gpu_block_t @p block and - * a pointer to an ::rsmi_ras_err_state_t @p state, this function will write - * the current state for the GPU block indicated by @p block to memory pointed - * to by @p state. + * @details Given a device index @p dv_ind, an ::rsmi_gpu_block_t @p block and + * a pointer to an ::rsmi_ras_err_state_t @p state, this function will write + * the current state for the GPU block indicated by @p block to memory pointed + * to by @p state. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] block The block for which error counts should be retrieved + * @param[in] block The block for which error counts should be retrieved * - * @param[inout] state A pointer to an ::rsmi_ras_err_state_t to which the - * ECC state should be written + * @param[inout] state A pointer to an ::rsmi_ras_err_state_t to which the + * ECC state should be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t rsmi_dev_ecc_status_get(uint32_t dv_ind, rsmi_gpu_block_t block, rsmi_ras_err_state_t *state); /** - * @brief Get a description of a provided RSMI error status + * @brief Get a description of a provided RSMI error status * - * @details Set the provided pointer to a const char *, @p status_string, to - * a string containing a description of the provided error code @p status. + * @details Set the provided pointer to a const char *, @p status_string, to + * a string containing a description of the provided error code @p status. * - * @param[in] status The error status for which a description is desired + * @param[in] status The error status for which a description is desired * - * @param[inout] status_string A pointer to a const char * which will be made - * to point to a description of the provided error code + * @param[inout] status_string A pointer to a const char * which will be made + * to point to a description of the provided error code * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call * */ rsmi_status_t @@ -1988,45 +2268,53 @@ rsmi_status_string(rsmi_status_t status, const char **status_string); */ /** - * @brief Tell if an event group is supported by a given device + * @brief Tell if an event group is supported by a given device * - * @details Given a device index @p dv_ind and an event group specifier @p - * group, tell if @p group type events are supported by the device associated - * with @p dv_ind + * @details Given a device index @p dv_ind and an event group specifier @p + * group, tell if @p group type events are supported by the device associated + * with @p dv_ind * - * @param[in] dv_ind device index of device being queried + * @param[in] dv_ind device index of device being queried * - * @param[in] group ::rsmi_event_group_t identifier of group for which support - * is being queried + * @param[in] group ::rsmi_event_group_t identifier of group for which support + * is being queried * - * @retval - * ::RSMI_STATUS_SUCCESS if the device associatee with @p dv_ind - * support counting events of the type indicated by @p group. - * - * ::RSMI_STATUS_NOT_FOUND If the device does not support event group @p - * group + * @retval ::RSMI_STATUS_SUCCESS if the device associatee with @p dv_ind + * support counting events of the type indicated by @p group. + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * group * */ rsmi_status_t rsmi_dev_counter_group_supported(uint32_t dv_ind, rsmi_event_group_t group); /** - * @brief Create a performance counter object + * @brief Create a performance counter object * - * @details Create a performance counter object of type @p type for the device - * with a device index of @p dv_ind, and write a handle to the object to the - * memory location pointed to by @p evnt_handle. @p evnt_handle can be used - * with other performance event operations. The handle should be deallocated - * with ::rsmi_dev_counter_destroy() when no longer needed. + * @details Create a performance counter object of type @p type for the device + * with a device index of @p dv_ind, and write a handle to the object to the + * memory location pointed to by @p evnt_handle. @p evnt_handle can be used + * with other performance event operations. The handle should be deallocated + * with ::rsmi_dev_counter_destroy() when no longer needed. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] type the type of performance event to create + * @param[in] type the type of performance event to create * - * @param[inout] evnt_handle A pointer to a ::rsmi_event_handle_t which will be - * associated with a newly allocated counter + * @param[inout] evnt_handle A pointer to a ::rsmi_event_handle_t which will be + * associated with a newly allocated counter + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_OUT_OF_RESOURCES unable to allocate memory for counter + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t @@ -2034,32 +2322,36 @@ rsmi_dev_counter_create(uint32_t dv_ind, rsmi_event_type_t type, rsmi_event_handle_t *evnt_handle); /** - * @brief Deallocate a performance counter object + * @brief Deallocate a performance counter object * - * @details Deallocate the performance counter object with the provided - * ::rsmi_event_handle_t @p evnt_handle + * @details Deallocate the performance counter object with the provided + * ::rsmi_event_handle_t @p evnt_handle * - * @param[in] evnt_handle handle to event object to be deallocated + * @param[in] evnt_handle handle to event object to be deallocated * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t rsmi_dev_counter_destroy(rsmi_event_handle_t evnt_handle); /** - * @brief Issue performance counter control commands + * @brief Issue performance counter control commands * - * @details Issue a command @p cmd on the event counter associated with the - * provided handle @p evt_handle. + * @details Issue a command @p cmd on the event counter associated with the + * provided handle @p evt_handle. * - * @param[in] evt_handle an event handle + * @param[in] evt_handle an event handle * - * @param[in] cmd The event counter command to be issued + * @param[in] cmd The event counter command to be issued * - * @param[inout] cmd_args Currently not used. Should be set to NULL. + * @param[inout] cmd_args Currently not used. Should be set to NULL. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t @@ -2067,18 +2359,20 @@ rsmi_counter_control(rsmi_event_handle_t evt_handle, rsmi_counter_command_t cmd, void *cmd_args); /** - * @brief Read the current value of a performance counter + * @brief Read the current value of a performance counter * - * @details Read the current counter value of the counter associated with the - * provided handle @p evt_handle and write the value to the location pointed - * to by @p value. + * @details Read the current counter value of the counter associated with the + * provided handle @p evt_handle and write the value to the location pointed + * to by @p value. * - * @param[in] evt_handle an event handle + * @param[in] evt_handle an event handle * - * @param[inout] value pointer to memory of size of ::rsmi_counter_value_t to - * which the counter value will be written + * @param[inout] value pointer to memory of size of ::rsmi_counter_value_t to + * which the counter value will be written * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_PERMISSION function requires root access * */ rsmi_status_t @@ -2086,21 +2380,22 @@ rsmi_counter_read(rsmi_event_handle_t evt_handle, rsmi_counter_value_t *value); /** - * @brief Get the number of currently available counters + * @brief Get the number of currently available counters * - * @details Given a device index @p dv_ind, a performance event group @p grp, - * and a pointer to a uint32_t @p available, this function will write the - * number of @p grp type counters that are available on the device with index - * @p dv_ind to the memory that @p available points to. + * @details Given a device index @p dv_ind, a performance event group @p grp, + * and a pointer to a uint32_t @p available, this function will write the + * number of @p grp type counters that are available on the device with index + * @p dv_ind to the memory that @p available points to. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[in] grp an event device group + * @param[in] grp an event device group * - * @param[inout] available A pointer to a uint32_t to which the number of - * available counters will be written + * @param[inout] available A pointer to a uint32_t to which the number of + * available counters will be written * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t @@ -2116,55 +2411,55 @@ rsmi_counter_available_counters_get(uint32_t dv_ind, */ /** - * @brief Get process information about processes currently using GPU + * @brief Get process information about processes currently using GPU * - * @details Given a non-NULL pointer to an array @p procs of - * ::rsmi_process_info_t's, of length *@p num_items, this function will write - * up to *@p num_items instances of ::rsmi_process_info_t to the memory pointed - * to by @p procs. These instances contain information about each process - * utilizing a GPU. If @p procs is not NULL, @p num_items will be updated with - * the number of processes actually written. If @p procs is NULL, @p num_items - * will be updated with the number of processes for which there is current - * process information. Calling this function with @p procs being NULL is a way - * to determine how much memory should be allocated for when @p procs is not - * NULL. + * @details Given a non-NULL pointer to an array @p procs of + * ::rsmi_process_info_t's, of length *@p num_items, this function will write + * up to *@p num_items instances of ::rsmi_process_info_t to the memory pointed + * to by @p procs. These instances contain information about each process + * utilizing a GPU. If @p procs is not NULL, @p num_items will be updated with + * the number of processes actually written. If @p procs is NULL, @p num_items + * will be updated with the number of processes for which there is current + * process information. Calling this function with @p procs being NULL is a way + * to determine how much memory should be allocated for when @p procs is not + * NULL. * - * @param[inout] procs a pointer to memory provided by the caller to which - * process information will be written. This may be NULL in which case only @p - * num_items will be updated with the number of processes found. + * @param[inout] procs a pointer to memory provided by the caller to which + * process information will be written. This may be NULL in which case only @p + * num_items will be updated with the number of processes found. * - * @param[inout] num_items A pointer to a uint32_t, which on input, should - * contain the amount of memory in ::rsmi_process_info_t's which have been - * provided by the @p procs argument. On output, if @p procs is non-NULL, this - * will be updated with the number ::rsmi_process_info_t structs actually - * written. If @p procs is NULL, this argument will be updated with the number - * processes for which there is information. + * @param[inout] num_items A pointer to a uint32_t, which on input, should + * contain the amount of memory in ::rsmi_process_info_t's which have been + * provided by the @p procs argument. On output, if @p procs is non-NULL, this + * will be updated with the number ::rsmi_process_info_t structs actually + * written. If @p procs is NULL, this argument will be updated with the number + * processes for which there is information. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call - * - * ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if there were more - * processes for which information was available, but not enough space was - * provided as indicated by @p procs and @p num_items, on input. + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if there were more + * processes for which information was available, but not enough space was + * provided as indicated by @p procs and @p num_items, on input. */ rsmi_status_t rsmi_compute_process_info_get(rsmi_process_info_t *procs, uint32_t *num_items); /** - * @brief Get process information about a specific process + * @brief Get process information about a specific process * - * @details Given a pointer to an ::rsmi_process_info_t @p proc and a process id - * @p pid, this function will write the process information for @p pid, if - * available, to the memory pointed to by @p proc. + * @details Given a pointer to an ::rsmi_process_info_t @p proc and a process id + * @p pid, this function will write the process information for @p pid, if + * available, to the memory pointed to by @p proc. * - * @param[in] pid The process ID for which process information is being requested + * @param[in] pid The process ID for which process information is being requested * - * @param[inout] proc a pointer to a ::rsmi_process_info_t to which - * process information for @p pid will be written if it is found. + * @param[inout] proc a pointer to a ::rsmi_process_info_t to which + * process information for @p pid will be written if it is found. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call - * - * ::RSMI_STATUS_NOT_FOUND is returned if there was no process information - * found for the provided @p pid + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid + * @retval ::RSMI_STATUS_NOT_FOUND is returned if there was no process information + * found for the provided @p pid * */ rsmi_status_t @@ -2180,19 +2475,26 @@ rsmi_compute_process_info_by_pid_get(uint32_t pid, rsmi_process_info_t *proc); */ /** - * @brief Retrieve the XGMI error status for a device + * @brief Retrieve the XGMI error status for a device * - * @details Given a device index @p dv_ind, and a pointer to an - * ::rsmi_xgmi_status_t @p status, this function will write the current XGMI - * error state ::rsmi_xgmi_status_t for the device @p dv_ind to the memory - * pointed to by @p status. + * @details Given a device index @p dv_ind, and a pointer to an + * ::rsmi_xgmi_status_t @p status, this function will write the current XGMI + * error state ::rsmi_xgmi_status_t for the device @p dv_ind to the memory + * pointed to by @p status. * - * @param[in] dv_ind a device index + * @param[in] dv_ind a device index * - * @param[inout] status A pointer to an ::rsmi_xgmi_status_t to which the - * XGMI error state should be written + * @param[inout] status A pointer to an ::rsmi_xgmi_status_t to which the + * XGMI error state should be written + * If this parameter is nullptr, this function will return + * ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided, + * arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the + * provided arguments. * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS call was successful + * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not + * support this function with the given arguments + * @retval ::RSMI_STATUS_INVALID_ARGS the provided arguments are not valid * */ rsmi_status_t diff --git a/include/rocm_smi/rocm_smi_device.h b/include/rocm_smi/rocm_smi_device.h index cc9ff84f39..42e13c2ca6 100755 --- a/include/rocm_smi/rocm_smi_device.h +++ b/include/rocm_smi/rocm_smi_device.h @@ -194,6 +194,8 @@ class Device { SupportedFuncMap *supported_funcs(void) {return &supported_funcs_;} void fillSupportedFuncs(void); void DumpSupportedFunctions(void); + bool DeviceAPISupported(std::string name, uint64_t variant, + uint64_t sub_variant); private: std::shared_ptr monitor_; diff --git a/src/rocm_smi.cc b/src/rocm_smi.cc index c7449c144e..d2c6b793e7 100755 --- a/src/rocm_smi.cc +++ b/src/rocm_smi.cc @@ -118,6 +118,34 @@ static rsmi_status_t handleException() { amd::smi::pthread_wrap _pw(*get_mutex(dv_ind)); \ amd::smi::ScopedPthread _lock(_pw); +/* This group of macros is used to facilitate checking of support for rsmi_dev* + * "getter" functions. When the return buffer is set to nullptr, the macro will + * check the previously gathered device support data to see if the function, + * with possible variants (e.g., memory types, firware types,...) and + * subvariants (e.g. monitors/sensors) are supported. + */ +// This macro assumes dev already available +#define CHK_API_SUPPORT_ONLY(RT_PTR, VR, SUB_VR) \ + if ((RT_PTR) == nullptr) { \ + if (!dev->DeviceAPISupported(__FUNCTION__, (VR), (SUB_VR))) { \ + return RSMI_STATUS_NOT_SUPPORTED; \ + } \ + return RSMI_STATUS_INVALID_ARGS; \ + } \ + +#define CHK_SUPPORT(RT_PTR, VR, SUB_VR) \ + GET_DEV_FROM_INDX \ + CHK_API_SUPPORT_ONLY(RT_PTR, VR, SUB_VR) + +#define CHK_SUPPORT_NAME_ONLY(RT_PTR) \ + CHK_SUPPORT((RT_PTR), RSMI_DEFAULT_VARIANT, RSMI_DEFAULT_VARIANT) \ + +#define CHK_SUPPORT_VAR(RT_PTR, VR) \ + CHK_SUPPORT((RT_PTR), (VR), RSMI_DEFAULT_VARIANT) \ + +#define CHK_SUPPORT_SUBVAR_ONLY(RT_PTR, SUB_VR) \ + CHK_SUPPORT((RT_PTR), RSMI_DEFAULT_VARIANT, (SUB_VR)) \ + static pthread_mutex_t *get_mutex(uint32_t dv_ind) { amd::smi::RocmSMI& smi = amd::smi::RocmSMI::getInstance(); @@ -392,7 +420,7 @@ static rsmi_status_t set_dev_mon_value(amd::smi::MonitorTypes type, assert(dev->monitor() != nullptr); - int ret = dev->monitor()->writeMonitor(type, sensor_ind, + int ret = dev->monitor()->writeMonitor(type, sensor_ind, std::to_string(val)); return errno_to_rsmi_status(ret); @@ -407,10 +435,8 @@ static rsmi_status_t get_power_mon_value(amd::smi::PowerMonTypes type, } uint32_t ret = smi.DiscoverAMDPowerMonitors(); - if (ret == EACCES) { - return RSMI_STATUS_PERMISSION; - } else if (ret != 0) { - return RSMI_STATUS_FILE_ERROR; + if (ret != 0) { + return errno_to_rsmi_status(ret); } std::shared_ptr dev = smi.monitor_devices()[dv_ind]; @@ -475,20 +501,15 @@ rsmi_num_monitor_devices(uint32_t *num_devices) { rsmi_status_t rsmi_dev_ecc_enabled_get(uint32_t dv_ind, uint64_t *enabled_blks) { TRY - if (enabled_blks == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } rsmi_status_t ret; std::string feature_line; std::string tmp_str; + CHK_SUPPORT_NAME_ONLY(enabled_blks) DEVICE_MUTEX ret = get_dev_value_line(amd::smi::kDevErrCntFeatures, dv_ind, &feature_line); - if (ret == RSMI_STATUS_FILE_ERROR) { - return RSMI_STATUS_NOT_SUPPORTED; - } if (ret != RSMI_STATUS_SUCCESS) { return ret; } @@ -526,9 +547,9 @@ static_assert(RSMI_RAS_ERR_STATE_LAST == RSMI_RAS_ERR_STATE_ENABLED, rsmi_status_t rsmi_dev_ecc_status_get(uint32_t dv_ind, rsmi_gpu_block_t block, rsmi_ras_err_state_t *state) { TRY - if (state == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + + CHK_SUPPORT_NAME_ONLY(state) + if (!is_power_of_2(block)) { return RSMI_STATUS_INVALID_ARGS; } @@ -560,9 +581,8 @@ rsmi_dev_ecc_count_get(uint32_t dv_ind, rsmi_gpu_block_t block, rsmi_status_t ret; TRY - if (ec == nullptr || block > RSMI_GPU_BLOCK_LAST) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_VAR(ec, block) + amd::smi::DevInfoTypes type; switch (block) { @@ -611,15 +631,12 @@ rsmi_dev_ecc_count_get(uint32_t dv_ind, rsmi_gpu_block_t block, return ret; CATCH } + rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid) { TRY - if (bdfid == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - GET_DEV_FROM_INDX - + CHK_SUPPORT_NAME_ONLY(bdfid) DEVICE_MUTEX *bdfid = dev->bdfid(); @@ -678,24 +695,28 @@ get_id(uint32_t dv_ind, amd::smi::DevInfoTypes typ, uint16_t *id) { rsmi_status_t rsmi_dev_id_get(uint32_t dv_ind, uint16_t *id) { + CHK_SUPPORT_NAME_ONLY(id) DEVICE_MUTEX return get_id(dv_ind, amd::smi::kDevDevID, id); } rsmi_status_t rsmi_dev_subsystem_id_get(uint32_t dv_ind, uint16_t *id) { + CHK_SUPPORT_NAME_ONLY(id) DEVICE_MUTEX return get_id(dv_ind, amd::smi::kDevSubSysDevID, id); } rsmi_status_t rsmi_dev_vendor_id_get(uint32_t dv_ind, uint16_t *id) { + CHK_SUPPORT_NAME_ONLY(id) DEVICE_MUTEX return get_id(dv_ind, amd::smi::kDevVendorID, id); } rsmi_status_t rsmi_dev_subsystem_vendor_id_get(uint32_t dv_ind, uint16_t *id) { + CHK_SUPPORT_NAME_ONLY(id) DEVICE_MUTEX return get_id(dv_ind, amd::smi::kDevSubSysVendorID, id); } @@ -704,6 +725,8 @@ rsmi_status_t rsmi_dev_perf_level_get(uint32_t dv_ind, rsmi_dev_perf_level_t *perf) { TRY std::string val_str; + + CHK_SUPPORT_NAME_ONLY(perf) DEVICE_MUTEX rsmi_status_t ret = get_dev_value_str(amd::smi::kDevPerfLevel, dv_ind, @@ -722,6 +745,7 @@ rsmi_status_t rsmi_dev_overdrive_level_get(uint32_t dv_ind, uint32_t *od) { TRY std::string val_str; + CHK_SUPPORT_NAME_ONLY(od) DEVICE_MUTEX rsmi_status_t ret = get_dev_value_str(amd::smi::kDevOverDriveLevel, dv_ind, @@ -1050,6 +1074,8 @@ rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, rsmi_clk_type_t clk_type, TRY amd::smi::DevInfoTypes dev_type; + CHK_SUPPORT_VAR(f, clk_type) + switch (clk_type) { case RSMI_CLK_TYPE_SYS: dev_type = amd::smi::kDevGPUSClk; @@ -1082,12 +1108,8 @@ rsmi_dev_firmware_version_get(uint32_t dv_ind, rsmi_fw_block_t block, uint64_t *fw_version) { rsmi_status_t ret; - if (fw_version == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - TRY - GET_DEV_FROM_INDX + CHK_SUPPORT_VAR(fw_version, block) std::string val_str; amd::smi::DevInfoTypes dev_type; @@ -1439,7 +1461,9 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t ret; TRY - if (name == nullptr || len == 0) { + CHK_SUPPORT_NAME_ONLY(name) + + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } @@ -1453,9 +1477,8 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len) { - GET_DEV_FROM_INDX - // Return 'invalid args' if arguments are invalid - if (brand == nullptr || len == 0) { + CHK_SUPPORT_NAME_ONLY(brand) + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } std::map brand_names = { @@ -1496,14 +1519,13 @@ rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len) { rsmi_status_t rsmi_dev_vram_vendor_get(uint32_t dv_ind, char *brand, uint32_t len) { - if (brand == nullptr || len == 0) { + TRY + CHK_SUPPORT_NAME_ONLY(brand) + + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } - - TRY - GET_DEV_FROM_INDX std::string val_str; - DEVICE_MUTEX int ret = dev->readDevInfo(amd::smi::kDevVramVendor, &val_str); @@ -1528,7 +1550,9 @@ rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t ret; TRY - if (name == nullptr || len == 0) { + CHK_SUPPORT_NAME_ONLY(name) + + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } @@ -1544,8 +1568,7 @@ rsmi_dev_drm_render_minor_get(uint32_t dv_ind, uint32_t *minor) { rsmi_status_t ret; TRY - if (minor == nullptr) - return RSMI_STATUS_INVALID_ARGS; + CHK_SUPPORT_NAME_ONLY(minor) DEVICE_MUTEX ret = get_dev_drm_render_minor(dv_ind, minor); @@ -1558,7 +1581,9 @@ rsmi_dev_vendor_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t ret; TRY - if (name == nullptr || len == 0) { + CHK_SUPPORT_NAME_ONLY(name) + + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } @@ -1572,11 +1597,7 @@ rsmi_dev_vendor_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth_t *b) { TRY - assert(b != nullptr); - - if (b == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_NAME_ONLY(b) DEVICE_MUTEX @@ -1632,9 +1653,13 @@ rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent, uint64_t *received, uint64_t *max_pkt_sz) { TRY rsmi_status_t ret; - std::string val_str; + // We don't do CHK_SUPPORT_NAME_ONLY in this case as the user may + // choose to have any of the inout parameters as 0. Let the return code from + // get_dev_value_line() tell if this function is supported or not. + // CHK_SUPPORT_NAME_ONLY(...) + DEVICE_MUTEX ret = get_dev_value_line(amd::smi::kDevPCIEThruPut, dv_ind, &val_str); @@ -1664,10 +1689,6 @@ rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type, rsmi_temperature_metric_t metric, int64_t *temperature) { TRY - if (temperature == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - rsmi_status_t ret; amd::smi::MonitorTypes mon_type; @@ -1732,6 +1753,9 @@ rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type, uint32_t sensor_index = m->getSensorIndex(static_cast(sensor_type)); + + CHK_API_SUPPORT_ONLY(temperature, metric, sensor_index) + ret = get_dev_mon_value(mon_type, dv_ind, sensor_index, temperature); return ret; @@ -1742,14 +1766,12 @@ rsmi_status_t rsmi_dev_fan_speed_get(uint32_t dv_ind, uint32_t sensor_ind, int64_t *speed) { TRY - if (speed == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - rsmi_status_t ret; ++sensor_ind; // fan sysfs files have 1-based indices + CHK_SUPPORT_SUBVAR_ONLY(speed, sensor_ind) + DEVICE_MUTEX ret = get_dev_mon_value(amd::smi::kMonFanSpeed, dv_ind, sensor_ind, speed); @@ -1762,11 +1784,10 @@ rsmi_status_t rsmi_dev_fan_rpms_get(uint32_t dv_ind, uint32_t sensor_ind, int64_t *speed) { TRY - if (speed == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } ++sensor_ind; // fan sysfs files have 1-based indices + CHK_SUPPORT_SUBVAR_ONLY(speed, sensor_ind) + rsmi_status_t ret; DEVICE_MUTEX @@ -1780,7 +1801,6 @@ rsmi_dev_fan_rpms_get(uint32_t dv_ind, uint32_t sensor_ind, int64_t *speed) { rsmi_status_t rsmi_dev_fan_reset(uint32_t dv_ind, uint32_t sensor_ind) { TRY - rsmi_status_t ret; ++sensor_ind; // fan sysfs files have 1-based indices @@ -1789,7 +1809,6 @@ rsmi_dev_fan_reset(uint32_t dv_ind, uint32_t sensor_ind) { ret = set_dev_mon_value(amd::smi::kMonFanCntrlEnable, dv_ind, sensor_ind, 2); - return ret; CATCH @@ -1837,15 +1856,9 @@ rsmi_status_t rsmi_dev_fan_speed_max_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *max_speed) { TRY - - if (max_speed == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - - ++sensor_ind; // fan sysfs files have 1-based indices - rsmi_status_t ret; - + ++sensor_ind; // fan sysfs files have 1-based indices + CHK_SUPPORT_SUBVAR_ONLY(max_speed, sensor_ind) DEVICE_MUTEX ret = get_dev_mon_value(amd::smi::kMonMaxFanSpeed, dv_ind, sensor_ind, @@ -1859,7 +1872,7 @@ rsmi_status_t rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data_t *odv) { TRY DEVICE_MUTEX - + CHK_SUPPORT_NAME_ONLY(odv) rsmi_status_t ret = get_od_clk_volt_info(dv_ind, odv); return ret; @@ -1867,10 +1880,12 @@ rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data_t *odv) { } rsmi_status_t rsmi_dev_od_volt_curve_regions_get(uint32_t dv_ind, - uint32_t *num_regions, rsmi_freq_volt_region_t *buffer) { + uint32_t *num_regions, rsmi_freq_volt_region_t *buffer) { TRY - if (buffer == nullptr || num_regions == nullptr || *num_regions == 0) { + CHK_SUPPORT_NAME_ONLY((num_regions == nullptr || buffer == nullptr) ? + nullptr : num_regions) + if (*num_regions == 0) { return RSMI_STATUS_INVALID_ARGS; } @@ -1885,12 +1900,9 @@ rsmi_status_t rsmi_dev_power_max_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power) { TRY - if (power == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - (void)sensor_ind; // Not used yet // ++sensor_ind; // power sysfs files have 1-based indices + CHK_SUPPORT_NAME_ONLY(power) rsmi_status_t ret; @@ -1905,11 +1917,9 @@ rsmi_status_t rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power) { TRY - if (power == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } ++sensor_ind; // power sysfs files have 1-based indices + CHK_SUPPORT_SUBVAR_ONLY(power, sensor_ind) rsmi_status_t ret; DEVICE_MUTEX @@ -1923,11 +1933,8 @@ rsmi_status_t rsmi_dev_power_cap_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *cap) { TRY - if (cap == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - ++sensor_ind; // power sysfs files have 1-based indices + CHK_SUPPORT_SUBVAR_ONLY(cap, sensor_ind) rsmi_status_t ret; @@ -1943,12 +1950,9 @@ rsmi_dev_power_cap_range_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *max, uint64_t *min) { TRY - if (max == nullptr || min == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - ++sensor_ind; // power sysfs files have 1-based indices - + CHK_SUPPORT_SUBVAR_ONLY((min == nullptr || max == nullptr ?nullptr : min), + sensor_ind) rsmi_status_t ret; DEVICE_MUTEX @@ -1958,7 +1962,6 @@ rsmi_dev_power_cap_range_get(uint32_t dv_ind, uint32_t sensor_ind, ret = get_dev_mon_value(amd::smi::kMonPowerCapMin, dv_ind, sensor_ind, min); } - return ret; CATCH } @@ -1993,11 +1996,12 @@ rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap) { } rsmi_status_t -rsmi_dev_power_profile_presets_get(uint32_t dv_ind, uint32_t sensor_ind, +rsmi_dev_power_profile_presets_get(uint32_t dv_ind, uint32_t reserved, rsmi_power_profile_status_t *status) { TRY - ++sensor_ind; // power sysfs files have 1-based indices + (void)reserved; + CHK_SUPPORT_NAME_ONLY(status) DEVICE_MUTEX rsmi_status_t ret = get_power_profiles(dv_ind, status, nullptr); @@ -2025,9 +2029,7 @@ rsmi_dev_memory_total_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, rsmi_status_t ret; amd::smi::DevInfoTypes mem_type_file; - if (total == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_VAR(total, mem_type) switch (mem_type) { case RSMI_MEM_TYPE_GTT: @@ -2060,9 +2062,7 @@ rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, rsmi_status_t ret; amd::smi::DevInfoTypes mem_type_file; - if (used == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_VAR(used, mem_type) switch (mem_type) { case RSMI_MEM_TYPE_GTT: @@ -2097,6 +2097,7 @@ rsmi_dev_memory_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent) { if (busy_percent == nullptr) { return RSMI_STATUS_INVALID_ARGS; } + CHK_SUPPORT_NAME_ONLY(busy_percent) uint64_t tmp_util = 0; @@ -2199,6 +2200,8 @@ rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent) { TRY std::string val_str; + CHK_SUPPORT_NAME_ONLY(busy_percent) + DEVICE_MUTEX rsmi_status_t ret = get_dev_value_str(amd::smi::kDevUsage, dv_ind, &val_str); @@ -2217,12 +2220,13 @@ rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent) { rsmi_status_t rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len) { - if (vbios == nullptr || len == 0) { + TRY + CHK_SUPPORT_NAME_ONLY(vbios) + + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } - TRY - GET_DEV_FROM_INDX std::string val_str; DEVICE_MUTEX @@ -2313,7 +2317,8 @@ rsmi_version_str_get(rsmi_sw_component_t component, char *ver_str, rsmi_status_t rsmi_dev_serial_number_get(uint32_t dv_ind, char *serial_num, uint32_t len) { - if (serial_num == nullptr || len == 0) { + CHK_SUPPORT_NAME_ONLY(serial_num) + if (len == 0) { return RSMI_STATUS_INVALID_ARGS; } @@ -2342,6 +2347,8 @@ rsmi_status_t rsmi_dev_serial_number_get(uint32_t dv_ind, rsmi_status_t rsmi_dev_pci_replay_counter_get(uint32_t dv_ind, uint64_t *counter) { TRY + CHK_SUPPORT_NAME_ONLY(counter) + DEVICE_MUTEX rsmi_status_t ret; @@ -2357,9 +2364,7 @@ rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *unique_id) { DEVICE_MUTEX rsmi_status_t ret; - if (unique_id == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_NAME_ONLY(unique_id) ret = get_dev_value_int(amd::smi::kDevUniqueId, dv_ind, unique_id); return ret; @@ -2372,14 +2377,10 @@ rsmi_dev_counter_create(uint32_t dv_ind, rsmi_event_type_t type, TRY DEVICE_MUTEX REQUIRE_ROOT_ACCESS - CHECK_DV_IND_RANGE - if (evnt_handle == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - if (type < RSMI_EVNT_FIRST || type > RSMI_EVNT_LAST) { - return RSMI_STATUS_INVALID_ARGS; - } + // Note we don't need to pass in the variant to CHK_SUPPORT_VAR because + // the success of this call doesn't depend on a sysfs file existing. + CHK_SUPPORT_NAME_ONLY(evnt_handle) *evnt_handle = reinterpret_cast( new amd::smi::evt::Event(type, dv_ind)); @@ -2480,9 +2481,7 @@ rsmi_counter_available_counters_get(uint32_t dv_ind, rsmi_status_t ret; TRY - if (available == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_VAR(available, grp) DEVICE_MUTEX uint64_t val; @@ -2551,10 +2550,7 @@ rsmi_dev_memory_reserved_pages_get(uint32_t dv_ind, uint32_t *num_pages, TRY rsmi_status_t ret; - - if (num_pages == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_NAME_ONLY(num_pages) std::vector val_vec; @@ -2642,9 +2638,7 @@ rsmi_dev_xgmi_error_status(uint32_t dv_ind, rsmi_xgmi_status_t *status) { TRY DEVICE_MUTEX - if (status == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } + CHK_SUPPORT_NAME_ONLY(status) rsmi_status_t ret; uint64_t status_code; @@ -2685,13 +2679,9 @@ rsmi_dev_xgmi_error_reset(uint32_t dv_ind) { rsmi_status_t ret; uint64_t status_code; + // Reading xgmi_error resets it ret = get_dev_value_int(amd::smi::kDevXGMIError, dv_ind, &status_code); - - if (ret != RSMI_STATUS_SUCCESS) { - return ret; - } - - return RSMI_STATUS_SUCCESS; + return ret; CATCH } @@ -2927,8 +2917,6 @@ rsmi_func_iter_next(rsmi_func_id_iter_handle_t handle) { } break; - break; - default: return RSMI_STATUS_INVALID_ARGS; } diff --git a/src/rocm_smi_device.cc b/src/rocm_smi_device.cc index 5e55886b8a..81318667a0 100755 --- a/src/rocm_smi_device.cc +++ b/src/rocm_smi_device.cc @@ -56,6 +56,7 @@ #include #include #include +#include #include "rocm_smi/rocm_smi_main.h" #include "rocm_smi/rocm_smi_device.h" @@ -913,6 +914,65 @@ void Device::fillSupportedFuncs(void) { // DumpSupportedFunctions(); } +bool Device::DeviceAPISupported(std::string name, uint64_t variant, + uint64_t sub_variant) { + SupportedFuncMapIt func_it; + VariantMapIt var_it; + SubVariantIt sub_var_it; + + fillSupportedFuncs(); + func_it = supported_funcs_.find(name); + + if (func_it == supported_funcs_.end()) { + return false; + } + + if (variant != RSMI_DEFAULT_VARIANT) { + // if variant is != RSMI_DEFAULT_VARIANT, we should not have a nullptr + assert(func_it->second != nullptr); + var_it = func_it->second->find(variant); + + if (var_it == func_it->second->end()) { + return false; + } + + if (sub_variant == RSMI_DEFAULT_VARIANT) { + return true; + } else { // sub_variant != RSMI_DEFAULT_VARIANT + // if variant is != RSMI_DEFAULT_VARIANT, we should not have a nullptr + assert(var_it->second != nullptr); + + sub_var_it = std::find(var_it->second->begin(), + var_it->second->end(), sub_variant); + if (sub_var_it == var_it->second->end()) { + return false; + } else { + return true; + } + } + } else { // variant == RSMI_DEFAULT_VARIANT + if (func_it->second != nullptr) { + var_it = func_it->second->find(variant); + } + if (sub_variant == RSMI_DEFAULT_VARIANT) { + return true; + } else { // sub_variant != RSMI_DEFAULT_VARIANT + if (func_it->second == nullptr) { + return false; + } + sub_var_it = std::find(var_it->second->begin(), + var_it->second->end(), sub_variant); + if (sub_var_it == var_it->second->end()) { + return false; + } else { + return true; + } + } + } + assert(!"We should not reach here"); + return false; +} + #undef RET_IF_NONZERO } // namespace smi } // namespace amd diff --git a/tests/rocm_smi_test/functional/err_cnt_read.cc b/tests/rocm_smi_test/functional/err_cnt_read.cc index 834914ba9c..9b1a8b6e93 100755 --- a/tests/rocm_smi_test/functional/err_cnt_read.cc +++ b/tests/rocm_smi_test/functional/err_cnt_read.cc @@ -98,9 +98,18 @@ void TestErrCntRead::Run(void) { std::cout << "\t**Error Count Enabled Mask get is not supported on this machine" << std::endl; + // Verify api support checking functionality is working + err = rsmi_dev_ecc_enabled_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); + continue; } else { CHK_ERR_ASRT(err) + + // Verify api support checking functionality is working + err = rsmi_dev_ecc_enabled_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); + IF_VERB(STANDARD) { std::cout << "Block Error Mask: 0x" << std::hex << enabled_mask << std::endl; @@ -116,6 +125,10 @@ void TestErrCntRead::Run(void) { GetBlockNameStr(static_cast(b)) << " block: " << GetErrStateNameStr(err_state) << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_ecc_status_get(i, static_cast(b), + nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); err = rsmi_dev_ecc_count_get(i, static_cast(b), &ec); @@ -123,6 +136,11 @@ void TestErrCntRead::Run(void) { std::cout << "\t**Error Count for " << GetBlockNameStr(static_cast(b)) << ": Not supported for this device" << std::endl; + // Verify api support checking functionality is working + err = rsmi_dev_ecc_count_get(i, static_cast(b), + nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); + } else { CHK_ERR_ASRT(err) IF_VERB(STANDARD) { @@ -133,6 +151,11 @@ void TestErrCntRead::Run(void) { << std::endl; std::cout << "\t\tUncorrectable errors: " << ec.uncorrectable_err << std::endl; + + // Verify api support checking functionality is working + err = rsmi_dev_ecc_count_get(i, static_cast(b), + nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } } diff --git a/tests/rocm_smi_test/functional/fan_read.cc b/tests/rocm_smi_test/functional/fan_read.cc index 0e0d6ba35d..a370d98031 100755 --- a/tests/rocm_smi_test/functional/fan_read.cc +++ b/tests/rocm_smi_test/functional/fan_read.cc @@ -99,12 +99,20 @@ void TestFanRead::Run(void) { } err = rsmi_dev_fan_speed_get(i, 0, &val_i64); CHK_ERR_ASRT(err) + + // Verify api support checking functionality is working + err = rsmi_dev_fan_speed_get(i, 0, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); + err = rsmi_dev_fan_speed_max_get(i, 0, &val_ui64); CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << val_i64/static_cast(val_ui64)*100; std::cout << "% ("<< val_i64 << "/" << val_ui64 << ")" << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_fan_speed_max_get(i, 0, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); IF_VERB(STANDARD) { std::cout << "\t**Current fan RPMs: "; @@ -114,5 +122,9 @@ void TestFanRead::Run(void) { IF_VERB(STANDARD) { std::cout << val_i64 << std::endl; } + + // Verify api support checking functionality is working + err = rsmi_dev_fan_rpms_get(i, 0, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } diff --git a/tests/rocm_smi_test/functional/frequencies_read.cc b/tests/rocm_smi_test/functional/frequencies_read.cc index cf604f3b3b..959f789b0c 100755 --- a/tests/rocm_smi_test/functional/frequencies_read.cc +++ b/tests/rocm_smi_test/functional/frequencies_read.cc @@ -113,15 +113,21 @@ void TestFrequenciesRead::Run(void) { for (uint32_t i = 0; i < num_monitor_devs(); ++i) { auto freq_output = [&](rsmi_clk_type_t t, const char *name) { err = rsmi_dev_gpu_clk_freq_get(i, t, &f); - if (err == RSMI_STATUS_NOT_SUPPORTED || err == RSMI_STATUS_FILE_ERROR) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Get " << name << ": Not supported on this machine" << std::endl; + // Verify api support checking functionality is working + err = rsmi_dev_gpu_clk_freq_get(i, t, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Supported " << name << " clock frequencies: "; std::cout << f.num_supported << std::endl; print_frequencies(&f); + // Verify api support checking functionality is working + err = rsmi_dev_gpu_clk_freq_get(i, t, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } }; @@ -135,15 +141,21 @@ void TestFrequenciesRead::Run(void) { freq_output(RSMI_CLK_TYPE_SOC, "SOC Clock"); err = rsmi_dev_pci_bandwidth_get(i, &b); - if (err == RSMI_STATUS_NOT_SUPPORTED || err == RSMI_STATUS_FILE_ERROR) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Get PCIE Bandwidth: Not supported on this machine" << std::endl; + // Verify api support checking functionality is working + err = rsmi_dev_pci_bandwidth_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Supported PCIe bandwidths: "; std::cout << b.transfer_rate.num_supported << std::endl; print_frequencies(&b.transfer_rate, b.lanes); + // Verify api support checking functionality is working + err = rsmi_dev_pci_bandwidth_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } } diff --git a/tests/rocm_smi_test/functional/frequencies_read_write.cc b/tests/rocm_smi_test/functional/frequencies_read_write.cc index 0961c98850..5eb8786be1 100755 --- a/tests/rocm_smi_test/functional/frequencies_read_write.cc +++ b/tests/rocm_smi_test/functional/frequencies_read_write.cc @@ -106,8 +106,7 @@ void TestFrequenciesReadWrite::Run(void) { auto freq_read = [&]() -> bool { ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f); - if (ret == RSMI_STATUS_NOT_SUPPORTED || - ret == RSMI_STATUS_FILE_ERROR) { + if (ret == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Set " << FreqEnumToStr(rsmi_clk) << ": Not supported on this machine" << std::endl; return false; diff --git a/tests/rocm_smi_test/functional/id_info_read.cc b/tests/rocm_smi_test/functional/id_info_read.cc index 95bf7bc0dc..834c76683e 100755 --- a/tests/rocm_smi_test/functional/id_info_read.cc +++ b/tests/rocm_smi_test/functional/id_info_read.cc @@ -101,130 +101,202 @@ void TestIdInfoRead::Run(void) { // Get the device ID, name, vendor ID and vendor name for the device err = rsmi_dev_id_get(i, &id); - if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + if (err == RSMI_STATUS_NOT_SUPPORTED) { + rsmi_status_t ret; + // Verify api support checking functionality is working + ret = rsmi_dev_id_get(i, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { std::cout << "\t**Device ID: 0x" << std::hex << id << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_name_get(i, buffer, kBufferLen); - if (err == RSMI_STATUS_NOT_FOUND) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Device Marketing name not found on this system." << std::endl; - } else if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + // Verify api support checking functionality is working + err = rsmi_dev_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Device Marketing name: " << buffer << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_brand_get(i, buffer, kBufferLen); - if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + if (err == RSMI_STATUS_NOT_SUPPORTED) { + // Verify api support checking functionality is working + err = rsmi_dev_brand_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Device Brand name: " << buffer << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_brand_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_vram_vendor_get(i, buffer, kBufferLen); if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Vram Vendor string not supported on this system." << std::endl; - } else if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + err = rsmi_dev_vram_vendor_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Device Vram Vendor name: " << buffer << std::endl; } + err = rsmi_dev_brand_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_vendor_id_get(i, &id); - if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + if (err == RSMI_STATUS_NOT_SUPPORTED) { + // Verify api support checking functionality is working + err = rsmi_dev_vendor_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Vendor ID: 0x" << std::hex << id << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_vendor_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_drm_render_minor_get(i, &drm_render_minor); - if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + if (err == RSMI_STATUS_NOT_SUPPORTED) { + // Verify api support checking functionality is working + err = rsmi_dev_drm_render_minor_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**DRM Render Minor: " << drm_render_minor << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_drm_render_minor_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_vendor_name_get(i, buffer, kBufferLen); - if (err == RSMI_STATUS_NOT_FOUND) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Device Vendor name string not found on this system." << std::endl; - } else if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + // Verify api support checking functionality is working + err = rsmi_dev_vendor_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Device Vendor name: " << buffer << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_vendor_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } // Get the device ID, name, vendor ID and vendor name for the sub-device err = rsmi_dev_subsystem_id_get(i, &id); - if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + if (err == RSMI_STATUS_NOT_SUPPORTED) { + // Verify api support checking functionality is working + err = rsmi_dev_subsystem_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Subsystem ID: 0x" << std::hex << id << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_subsystem_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_subsystem_name_get(i, buffer, kBufferLen); - if (err == RSMI_STATUS_NOT_FOUND) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Subsystem name string not found on this system." << std::endl; - } else if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + // Verify api support checking functionality is working + err = rsmi_dev_subsystem_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Subsystem name: " << buffer << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_subsystem_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_subsystem_vendor_id_get(i, &id); - if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + if (err == RSMI_STATUS_NOT_SUPPORTED) { + // Verify api support checking functionality is working + err = rsmi_dev_subsystem_vendor_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Sub-system Vendor ID: 0x" << std::hex << id << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_subsystem_vendor_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_vendor_name_get(i, buffer, kBufferLen); - if (err == RSMI_STATUS_NOT_FOUND) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Subsystem Vendor name string not found on this system." << std::endl; - } else if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) + // Verify api support checking functionality is working + err = rsmi_dev_vendor_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Subsystem Vendor name: " << buffer << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_vendor_name_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_dev_pci_id_get(i, &val_ui64); + // Don't check for RSMI_STATUS_NOT_SUPPORTED since this should always be + // supported. It is not based on a sysfs file. CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**PCI ID (BDFID): 0x" << std::hex << val_ui64; std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_pci_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); err = rsmi_dev_serial_number_get(i, buffer, kBufferLen); if (err == RSMI_STATUS_NOT_SUPPORTED) { + // Verify api support checking functionality is working + err = rsmi_dev_serial_number_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); + std::cout << "\t**Serial Number string not supported on this system." << std::endl; - } else if (err != RSMI_STATUS_SUCCESS) { - CHK_ERR_ASRT(err) } else { + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**Device Serial Number:" << buffer << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_serial_number_get(i, nullptr, kBufferLen); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } } diff --git a/tests/rocm_smi_test/functional/mem_page_info_read.cc b/tests/rocm_smi_test/functional/mem_page_info_read.cc index 874bb38c71..fe1ed7c7c7 100755 --- a/tests/rocm_smi_test/functional/mem_page_info_read.cc +++ b/tests/rocm_smi_test/functional/mem_page_info_read.cc @@ -98,6 +98,11 @@ void TestMemPageInfoRead::Run(void) { std::cout << "\t**Memory page information is not supported for this device" << std::endl; + + // Verify api support checking functionality is working + err = rsmi_dev_memory_reserved_pages_get(i, nullptr, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); + continue; } else { CHK_ERR_ASRT(err) @@ -105,6 +110,9 @@ void TestMemPageInfoRead::Run(void) { std::cout << "\tNumber of memory page records: " << num_pages << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_memory_reserved_pages_get(i, nullptr, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } if (num_pages > 0) { diff --git a/tests/rocm_smi_test/functional/overdrive_read.cc b/tests/rocm_smi_test/functional/overdrive_read.cc index cd4bfc9c8d..d89d32741d 100755 --- a/tests/rocm_smi_test/functional/overdrive_read.cc +++ b/tests/rocm_smi_test/functional/overdrive_read.cc @@ -98,6 +98,9 @@ void TestOverdriveRead::Run(void) { CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**OverDrive Level:" << val_ui32 << std::endl; + // Verify api support checking functionality is working + err = rsmi_dev_overdrive_level_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } } diff --git a/tests/rocm_smi_test/functional/pci_read_write.cc b/tests/rocm_smi_test/functional/pci_read_write.cc index 988b5e32d5..283b09be5c 100755 --- a/tests/rocm_smi_test/functional/pci_read_write.cc +++ b/tests/rocm_smi_test/functional/pci_read_write.cc @@ -102,11 +102,18 @@ void TestPciReadWrite::Run(void) { std::cout << "\t**rsmi_dev_pci_replay_counter_get() is not supported" " on this machine" << std::endl; + + // Verify api support checking functionality is working + ret = rsmi_dev_pci_replay_counter_get(dv_ind, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_NOT_SUPPORTED); } else { CHK_ERR_ASRT(ret) IF_VERB(STANDARD) { std::cout << "\tPCIe Replay Counter: " << u64int << std::endl; } + // Verify api support checking functionality is working + ret = rsmi_dev_pci_replay_counter_get(dv_ind, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS); } ret = rsmi_dev_pci_throughput_get(dv_ind, &sent, &received, &max_pkt_sz); @@ -114,6 +121,9 @@ void TestPciReadWrite::Run(void) { std::cout << "TEST FAILURE: Current PCIe throughput is not detected. " "This is likely because it is not indicated in the pcie_bw sysfs " "file. Aborting test." << std::endl; + + // We don't need to verify api support checking functionality is working + // as the user may choose to have any of the input parameters as 0. return; } CHK_ERR_ASRT(ret) @@ -133,6 +143,10 @@ void TestPciReadWrite::Run(void) { std::cout << "TEST FAILURE: Current PCIe bandwidth is not detected. " "This is likely because it is not indicated in the pp_dpm_pcie sysfs " "file. Aborting test." << std::endl; + // Verify api support checking functionality is working + ret = rsmi_dev_pci_bandwidth_get(dv_ind, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_NOT_SUPPORTED); + return; } CHK_ERR_ASRT(ret) @@ -141,6 +155,9 @@ void TestPciReadWrite::Run(void) { std::cout << "\tInitial PCIe BW index is " << bw.transfer_rate.current << std::endl; } + // Verify api support checking functionality is working + ret = rsmi_dev_pci_bandwidth_get(dv_ind, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS); // First set the bitmask to all supported bandwidths freq_bitmask = ~(~0 << bw.transfer_rate.num_supported); diff --git a/tests/rocm_smi_test/functional/perf_cntr_read_write.cc b/tests/rocm_smi_test/functional/perf_cntr_read_write.cc index b9fde50d53..c06a011570 100755 --- a/tests/rocm_smi_test/functional/perf_cntr_read_write.cc +++ b/tests/rocm_smi_test/functional/perf_cntr_read_write.cc @@ -139,6 +139,13 @@ TestPerfCntrReadWrite::testEventsIndividually(uint32_t dv_ind) { static_cast(evnt), &evt_handle); CHK_ERR_ASRT(ret) + // Note that rsmi_dev_counter_create() should never return + // RSMI_STATUS_NOT_SUPPORTED. It will return RSMI_STATUS_OUT_OF_RESOURCES + // if it is unable to create a counter. + ret = rsmi_dev_counter_create(dv_ind, + static_cast(evnt), nullptr); + ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS); + IF_VERB(STANDARD) { std::cout << "\t\tStart Counting..." << std::endl; } @@ -202,7 +209,6 @@ TestPerfCntrReadWrite::testEventsSimultaneously(uint32_t dv_ind) { std::cout << "****************************" << std::endl; for (PerfCntrEvtGrp grp : s_event_groups) { - ret = rsmi_dev_counter_group_supported(dv_ind, grp.group()); if (ret == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\tEvent Group " << grp.name() << diff --git a/tests/rocm_smi_test/functional/perf_level_read.cc b/tests/rocm_smi_test/functional/perf_level_read.cc index 4dfb78c54e..ad3934e957 100755 --- a/tests/rocm_smi_test/functional/perf_level_read.cc +++ b/tests/rocm_smi_test/functional/perf_level_read.cc @@ -100,5 +100,8 @@ void TestPerfLevelRead::Run(void) { std::cout << "\t**Performance Level:" << std::dec << (uint32_t)pfl << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_perf_level_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } diff --git a/tests/rocm_smi_test/functional/power_cap_read_write.cc b/tests/rocm_smi_test/functional/power_cap_read_write.cc index aef8337631..2a56d9ae4e 100755 --- a/tests/rocm_smi_test/functional/power_cap_read_write.cc +++ b/tests/rocm_smi_test/functional/power_cap_read_write.cc @@ -98,9 +98,15 @@ void TestPowerCapReadWrite::Run(void) { ret = rsmi_dev_power_cap_range_get(dv_ind, 0, &max, &min); CHK_ERR_ASRT(ret) + // Verify api support checking functionality is working + ret = rsmi_dev_power_cap_range_get(dv_ind, 0, nullptr, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS); ret = rsmi_dev_power_cap_get(dv_ind, 0, &orig); CHK_ERR_ASRT(ret) + // Verify api support checking functionality is working + ret = rsmi_dev_power_cap_get(dv_ind, 0, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS); new_cap = (max + min)/2; diff --git a/tests/rocm_smi_test/functional/power_read.cc b/tests/rocm_smi_test/functional/power_read.cc index bef80da4bb..4d6a276b1b 100755 --- a/tests/rocm_smi_test/functional/power_read.cc +++ b/tests/rocm_smi_test/functional/power_read.cc @@ -113,6 +113,9 @@ void TestPowerRead::Run(void) { if (err == RSMI_STATUS_SUCCESS) { std::cout << static_cast(val_ui64)/1000 << " mW" << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_power_ave_get(i, 0, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } } diff --git a/tests/rocm_smi_test/functional/power_read_write.cc b/tests/rocm_smi_test/functional/power_read_write.cc index 32fbc32454..1694425e58 100755 --- a/tests/rocm_smi_test/functional/power_read_write.cc +++ b/tests/rocm_smi_test/functional/power_read_write.cc @@ -121,6 +121,10 @@ void TestPowerReadWrite::Run(void) { ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status); CHK_ERR_ASRT(ret) + // Verify api support checking functionality is working + ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, nullptr); + ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS); + IF_VERB(STANDARD) { std::cout << "The available power profiles are:" << std::endl; uint64_t tmp = 1; diff --git a/tests/rocm_smi_test/functional/sys_info_read.cc b/tests/rocm_smi_test/functional/sys_info_read.cc index 964e371b50..f86d41a277 100755 --- a/tests/rocm_smi_test/functional/sys_info_read.cc +++ b/tests/rocm_smi_test/functional/sys_info_read.cc @@ -105,7 +105,14 @@ void TestSysInfoRead::Run(void) { std::cout << "\t**VBIOS read: Not supported on this machine" << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_vbios_version_get(i, nullptr, 80); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { + // Verify api support checking functionality is working + err = rsmi_dev_vbios_version_get(i, nullptr, 80); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); + CHK_ERR_ASRT(err) } } else { @@ -120,18 +127,27 @@ void TestSysInfoRead::Run(void) { std::cout << "\t**PCI ID (BDFID): 0x" << std::hex << val_ui64; std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_pci_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); err = rsmi_dev_unique_id_get(i, &val_ui64); if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**rsmi_dev_unique_id() is not supported" " on this machine" << std::endl; + // Verify api support checking functionality is working + err = rsmi_dev_unique_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**GPU Unique ID : " << std::hex << val_ui64 << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_unique_id_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } err = rsmi_version_get(&ver); @@ -148,15 +164,23 @@ void TestSysInfoRead::Run(void) { for (int x = RSMI_FW_BLOCK_FIRST; x <= RSMI_FW_BLOCK_LAST; ++x) { rsmi_fw_block_t block = static_cast(x); err = rsmi_dev_firmware_version_get(i, block, &val_ui64); - if (err) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**No FW block " << NameFromFWEnum(block) << " available on this system" << std::endl; + + // Verify api support checking functionality is working + err = rsmi_dev_firmware_version_get(i, block, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); continue; } + CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**FW VERSION for " << NameFromFWEnum(block) << ": " << val_ui64 << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_firmware_version_get(i, block, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); } } } diff --git a/tests/rocm_smi_test/functional/temp_read.cc b/tests/rocm_smi_test/functional/temp_read.cc index b2e63ac5f1..2dfcc0d5d1 100755 --- a/tests/rocm_smi_test/functional/temp_read.cc +++ b/tests/rocm_smi_test/functional/temp_read.cc @@ -112,12 +112,19 @@ void TestTempRead::Run(void) { IF_VERB(STANDARD) { std::cout << "\t**" << label << ": " << "Not supported on this machine" << std::endl; + + // Verify api support checking functionality is working + err = rsmi_dev_temp_metric_get(i, type, met, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); return; } } else { CHK_ERR_ASRT(err) } } + // Verify api support checking functionality is working + err = rsmi_dev_temp_metric_get(i, type, met, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); IF_VERB(STANDARD) { std::cout << "\t**" << label << ": " << val_i64/1000 << diff --git a/tests/rocm_smi_test/functional/volt_freq_curv_read.cc b/tests/rocm_smi_test/functional/volt_freq_curv_read.cc index 60b8080a1a..eead207aa4 100755 --- a/tests/rocm_smi_test/functional/volt_freq_curv_read.cc +++ b/tests/rocm_smi_test/functional/volt_freq_curv_read.cc @@ -154,15 +154,20 @@ void TestVoltCurvRead::Run(void) { PrintDeviceHeader(i); err = rsmi_dev_od_volt_info_get(i, &odv); - if (err == RSMI_STATUS_FILE_ERROR || - err == RSMI_STATUS_NOT_SUPPORTED) { + if (err == RSMI_STATUS_NOT_SUPPORTED) { IF_VERB(STANDARD) { std::cout << "\t**rsmi_dev_od_volt_info_get: Not supported on this machine" << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_od_volt_info_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } else { CHK_ERR_ASRT(err) + // Verify api support checking functionality is working + err = rsmi_dev_od_volt_info_get(i, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); } if (err == RSMI_STATUS_SUCCESS) { diff --git a/tests/rocm_smi_test/functional/xgmi_read_write.cc b/tests/rocm_smi_test/functional/xgmi_read_write.cc index 747ac927c8..4287e0af65 100755 --- a/tests/rocm_smi_test/functional/xgmi_read_write.cc +++ b/tests/rocm_smi_test/functional/xgmi_read_write.cc @@ -95,22 +95,25 @@ void TestXGMIReadWrite::Run(void) { err = rsmi_dev_xgmi_error_status(dv_ind, &err_stat); - if (err != RSMI_STATUS_SUCCESS) { - if (err == RSMI_STATUS_NOT_SUPPORTED) { - IF_VERB(STANDARD) { - std::cout << "\t**XGMI Error Status: Not supported on this machine" - << std::endl; - return; - } - } else { - CHK_ERR_ASRT(err) - } - } else { + if (err == RSMI_STATUS_NOT_SUPPORTED) { IF_VERB(STANDARD) { - std::cout << "\t**XGMI Error Status: " << - static_cast(err_stat) << std::endl; + std::cout << "\t**XGMI Error Status: Not supported on this machine" + << std::endl; } + // Verify api support checking functionality is working + err = rsmi_dev_xgmi_error_status(dv_ind, nullptr); + ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); + + continue; } + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**XGMI Error Status: " << + static_cast(err_stat) << std::endl; + } + // Verify api support checking functionality is working + err = rsmi_dev_xgmi_error_status(dv_ind, nullptr); + ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); // TODO(cfree) We need to find a way to generate xgmi errors so this // test won't be meaningless