SWDEV-353742 - Port smilib function to amdsmi

Change-Id: I99df249755a5c665a8dd1777fa82d046e139bd77
Signed-off-by: Dalibor Stanisavljevic <Dalibor.Stanisavljevic@amd.com>
This commit is contained in:
Dalibor Stanisavljevic
2022-09-05 15:26:03 +02:00
committed by Bill(Shuzhou) Liu
parent 7fa3b36d7f
commit 3daf9c1063
18 changed files with 2577 additions and 449 deletions
+222 -174
View File
@@ -104,7 +104,7 @@ typedef enum device_type {
/**
* @brief Error codes retured by amd_smi_lib functions
*/
typedef enum amdsmi_status {
typedef enum amdsmi_status_t {
AMDSMI_STATUS_SUCCESS = 0, /**< Call succeeded */
AMDSMI_STATUS_INVAL, /**< Invalid parameters */
AMDSMI_STATUS_NOT_SUPPORTED, /**< Command not supported */
@@ -334,15 +334,15 @@ typedef struct amdsmi_board_info {
} amdsmi_board_info_t;
typedef struct amdsmi_temperature {
uint16_t cur_temp;
uint32_t cur_temp;
} amdsmi_temperature_t;
typedef struct amdsmi_temperature_limit {
uint16_t limit;
uint32_t limit;
} amdsmi_temperature_limit_t;
typedef struct amdsmi_power_limit {
uint16_t limit;
uint32_t limit;
} amdsmi_power_limit_t;
typedef struct amdsmi_power_measure {
@@ -369,17 +369,22 @@ typedef struct amdsmi_engine_usage {
typedef uint32_t amdsmi_process_handle;
typedef struct amdsmi_process_info {
char name[AMDSMI_NORMAL_STRING_LENGTH];
amdsmi_process_handle pid;
uint64_t mem; /** in bytes */
char name[AMDSMI_NORMAL_STRING_LENGTH];
amdsmi_process_handle pid;
uint64_t mem; /** in bytes */
struct {
uint16_t gfx[AMDSMI_MAX_MM_IP_COUNT];
uint16_t compute[AMDSMI_MAX_MM_IP_COUNT];
uint16_t sdma[AMDSMI_MAX_MM_IP_COUNT];
uint16_t enc[AMDSMI_MAX_MM_IP_COUNT];
uint16_t dec[AMDSMI_MAX_MM_IP_COUNT];
} engine_usage; /** percentage 0-100% times 100 */
struct {
uint16_t gfx[AMDSMI_MAX_MM_IP_COUNT];
uint16_t compute[AMDSMI_MAX_MM_IP_COUNT];
uint16_t sdma[AMDSMI_MAX_MM_IP_COUNT];
uint16_t enc[AMDSMI_MAX_MM_IP_COUNT];
uint16_t dec[AMDSMI_MAX_MM_IP_COUNT];
} usage; /** percentage 0-100% times 100 */
char container_name[AMDSMI_NORMAL_STRING_LENGTH];
uint64_t gtt_mem;
uint64_t cpu_mem;
uint64_t vram_mem;
} memory_usage; /** in bytes */
char container_name[AMDSMI_NORMAL_STRING_LENGTH];
} amdsmi_proc_info_t;
//! Guaranteed maximum possible number of supported frequencies
@@ -1071,8 +1076,8 @@ typedef struct {
* @brief This structure holds error counts.
*/
typedef struct {
uint64_t correctable_err; //!< Accumulated correctable errors
uint64_t uncorrectable_err; //!< Accumulated uncorrectable errors
uint64_t correctable_count; //!< Accumulated correctable errors
uint64_t uncorrectable_count; //!< Accumulated uncorrectable errors
} amdsmi_error_count_t;
/**
@@ -1795,7 +1800,50 @@ amdsmi_dev_memory_total_get(amdsmi_device_handle device_handle, amdsmi_memory_ty
amdsmi_status_t
amdsmi_dev_memory_usage_get(amdsmi_device_handle device_handle, amdsmi_memory_type_t mem_type,
uint64_t *used);
/**
* @brief The first call to this API returns the number of bad pages which
* should be used to allocate the buffer that should contain the bad page
* records.
* @details This call will query the device @p device_handle for the
* number of bad pages (written to @p num_pages address). The results are
* written to address held by the @p info pointer.
* @param[in] device_handle a device handle
* @param[out] num_pages Number of bad page records.
* @param[out] info Pointer to amdsmi_retired_page_record_t to which the
* results will be written to.
* @retval ::AMDSMI_STATUS_SUCCESS call was successful
* @retval ::AMDSMI_STATUS_INVAL the parameters are not valid or nullptr
* @retval ::AMDSMI_STATUS_NOT_SUPPORTED API not supported
*/
amdsmi_status_t
amdsmi_get_bad_page_info(amdsmi_device_handle device_handle, uint32_t *num_pages, amdsmi_retired_page_record_t *info);
/**
* @brief Returns if RAS features are enabled or disabled for given block
*
* @details Given a device handle @p device_handle, this function queries the
* state of RAS features for a specific block @p block. Result will be written
* to address held by pointer @p state.
*
* @param[in] device_handle Device handle which to query
*
* @param[in] block Block which to query
*
* @param[inout] state A pointer to amdsmi_ras_err_state_t to which the state
* of block will be written.
* If this parameter is nullptr, this function will return
* ::AMDSMI_STATUS_INVALID_ARGS if the function is supported with the provided
* arguments and ::AMDSMI_STATUS_NOT_SUPPORTED if it is not supported with the
* provided arguments.
*
* @retval ::AMDSMI_STATUS_SUCCESS call was successful
* @retval ::AMDSMI_STATUS_NOT_SUPPORTED installed software or hardware does not
* support this function with the given arguments.
* @retval ::AMDSMI_STATUS_INVALID_ARGS the provided arguments are not valid
*
*/
amdsmi_status_t
amdsmi_get_ras_features_enabled(amdsmi_device_handle device_handle, amdsmi_gpu_block block,
amdsmi_ras_err_state_t *state);
/**
* @brief Get percentage of time any device memory is being used
*
@@ -3676,11 +3724,11 @@ amdsmi_status_t amdsmi_event_notification_stop(amdsmi_device_handle device_handl
* \param [out] bdf - Reference to BDF. Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - Parameters are invalid
* * -::SMI_ERR_NOT_FOUND - Device cannot be found
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - Parameters are invalid
* * -::AMDSMI_STATUS_NOT_FOUND - Device cannot be found
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status_t
amdsmi_get_device_bdf(amdsmi_device_handle dev, amdsmi_bdf_t *bdf);
@@ -3698,13 +3746,13 @@ amdsmi_get_device_bdf(amdsmi_device_handle dev, amdsmi_bdf_t *bdf);
* allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - Parameters are invalid
* * -::SMI_ERR_NOT_FOUND - Device cannot be found
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - Parameters are invalid
* * -::AMDSMI_STATUS_NOT_FOUND - Device cannot be found
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_device_uuid(amdsmi_device_handle dev, unsigned int *uuid_length, char *uuid);
/** @} */
@@ -3726,13 +3774,13 @@ amdsmi_get_device_uuid(amdsmi_device_handle dev, unsigned int *uuid_length, char
* allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NOT_FOUND - Device cannot be found
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NOT_FOUND - Device cannot be found
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_driver_version(amdsmi_device_handle dev, int *length, char *version);
/** @} */
@@ -3750,15 +3798,15 @@ amdsmi_get_driver_version(amdsmi_device_handle dev, int *length, char *version);
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_asic_info(amdsmi_device_handle dev, amdsmi_asic_info_t *info);
/**
@@ -3770,15 +3818,15 @@ amdsmi_get_asic_info(amdsmi_device_handle dev, amdsmi_asic_info_t *info);
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialize
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialize
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_board_info(amdsmi_device_handle dev, amdsmi_board_info_t *info);
/**
@@ -3792,15 +3840,15 @@ amdsmi_get_board_info(amdsmi_device_handle dev, amdsmi_board_info_t *info);
* allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_power_cap_info(amdsmi_device_handle dev, uint32_t sensor_ind,
amdsmi_power_cap_info_t *info);
@@ -3814,15 +3862,15 @@ amdsmi_get_power_cap_info(amdsmi_device_handle dev, uint32_t sensor_ind,
*
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_xgmi_info(amdsmi_device_handle dev, amdsmi_xgmi_info_t *info);
/**
@@ -3835,15 +3883,15 @@ amdsmi_get_xgmi_info(amdsmi_device_handle dev, amdsmi_xgmi_info_t *info);
* allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_caps_info(amdsmi_device_handle dev, amdsmi_gpu_caps_t *info);
/** @} */
@@ -3860,15 +3908,15 @@ amdsmi_get_caps_info(amdsmi_device_handle dev, amdsmi_gpu_caps_t *info);
* \param [out] info - Reference to the fw info. Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_fw_info(amdsmi_device_handle dev, amdsmi_fw_info_t *info);
/**
@@ -3880,15 +3928,15 @@ amdsmi_get_fw_info(amdsmi_device_handle dev, amdsmi_fw_info_t *info);
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_vbios_info(amdsmi_device_handle dev, amdsmi_vbios_info_t *info);
/** @} */
@@ -3906,15 +3954,15 @@ amdsmi_get_vbios_info(amdsmi_device_handle dev, amdsmi_vbios_info_t *info);
* \param [out] info - Reference to the gpu engine usage structure. Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_gpu_activity(amdsmi_device_handle dev, amdsmi_engine_usage_t *info);
/**
@@ -3926,15 +3974,15 @@ amdsmi_get_gpu_activity(amdsmi_device_handle dev, amdsmi_engine_usage_t *info);
* \param [out] info - Reference to the gpu power structure. Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_power_measure(amdsmi_device_handle dev, amdsmi_power_measure_t *info);
/**
@@ -3950,15 +3998,15 @@ amdsmi_get_power_measure(amdsmi_device_handle dev, amdsmi_power_measure_t *info)
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_clock_measure(amdsmi_device_handle dev, amdsmi_clk_type_t clk_type, amdsmi_clock_measure_t *info);
/**
@@ -3973,15 +4021,15 @@ amdsmi_get_clock_measure(amdsmi_device_handle dev, amdsmi_clk_type_t clk_type, a
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_temperature_measure(amdsmi_device_handle dev, amdsmi_temperature_type_t temp_type, amdsmi_temperature_t *info);
/**
@@ -3996,16 +4044,16 @@ amdsmi_get_temperature_measure(amdsmi_device_handle dev, amdsmi_temperature_type
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_get_temperature_limit(amdsmi_device_handle dev, amdsmi_temperature_t temp_type, amdsmi_temperature_limit_t *limit);
amdsmi_status_t
amdsmi_get_temperature_limit(amdsmi_device_handle dev, amdsmi_temperature_type_t temp_type, amdsmi_temperature_limit_t *limit);
/**
* \brief Returns power limit of the GPU.
@@ -4017,15 +4065,15 @@ amdsmi_get_temperature_limit(amdsmi_device_handle dev, amdsmi_temperature_t temp
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_power_limit(amdsmi_device_handle dev, amdsmi_power_limit_t *limit);
/**
@@ -4039,15 +4087,15 @@ amdsmi_get_power_limit(amdsmi_device_handle dev, amdsmi_power_limit_t *limit);
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_vram_usage(amdsmi_device_handle dev, amdsmi_vram_info_t *info);
/** @} */
@@ -4072,15 +4120,15 @@ amdsmi_get_vram_usage(amdsmi_device_handle dev, amdsmi_vram_info_t *info);
*
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialize
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_INVAL - Parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialize
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_INVAL - Parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_target_frequency_range(amdsmi_device_handle dev, amdsmi_clk_type_t clk_type, amdsmi_frequency_range_t *range);
/** @} */
@@ -4109,13 +4157,13 @@ amdsmi_get_target_frequency_range(amdsmi_device_handle dev, amdsmi_clk_type_t cl
* in list or the number of running processes if equal to 0.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - The parameters are not valid or NULL
* * -::SMI_ERR_NOMEM - Provided buffer is not large enough
* * -::SMI_ERR_NOT_SUPPORTED - API not supported
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - The parameters are not valid or NULL
* * -::AMDSMI_STATUS_NOMEM - Provided buffer is not large enough
* * -::AMDSMI_STATUS_NOT_SUPPORTED - API not supported
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_process_list(amdsmi_device_handle dev, amdsmi_process_handle *list, uint32_t *max_processes);
/**
@@ -4129,12 +4177,12 @@ amdsmi_get_process_list(amdsmi_device_handle dev, amdsmi_process_handle *list, u
* information. Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - The parameters are not valid or NULL
* * -::SMI_ERR_NOT_SUPPORTED - API not supported
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - The parameters are not valid or NULL
* * -::AMDSMI_STATUS_NOT_SUPPORTED - API not supported
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_process_info(amdsmi_device_handle dev, amdsmi_process_handle process, amdsmi_proc_info_t *info);
/** @} */
@@ -4154,15 +4202,15 @@ amdsmi_get_process_info(amdsmi_device_handle dev, amdsmi_process_handle process,
* Must be allocated by user.
*
* \return
* * ::SMI_SUCCESS - Successful
* * -::SMI_ERR_RETRY - Device is busy. Please retry
* * -::SMI_ERR_NO_PERM - Library was not initialized
* * -::SMI_ERR_INVAL - The parameters are not valid or NULL
* * -::SMI_ERR_IO - Device is in an unrecoverable state
* * -::SMI_ERR_NOT_INIT - Device is uninitialized
* * -::SMI_ERR_API_FAILED - Other errors
* * ::AMDSMI_STATUS_SUCCESS - Successful
* * -::AMDSMI_STATUS_RETRY - Device is busy. Please retry
* * -::AMDSMI_STATUS_NO_PERM - Library was not initialized
* * -::AMDSMI_STATUS_INVAL - The parameters are not valid or NULL
* * -::AMDSMI_STATUS_IO - Device is in an unrecoverable state
* * -::AMDSMI_STATUS_NOT_INIT - Device is uninitialized
* * -::AMDSMI_STATUS_API_FAILED - Other errors
*/
amdsmi_status
amdsmi_status_t
amdsmi_get_ecc_error_count(amdsmi_device_handle dev, amdsmi_error_count_t *ec);
#ifdef __cplusplus
+10 -1
View File
@@ -58,7 +58,13 @@ class AMDSmiDrm {
public:
amdsmi_status_t init();
amdsmi_status_t cleanup();
int get_drm_fd_by_index(uint32_t gpu_index) const;
amdsmi_status_t get_drm_fd_by_index(uint32_t gpu_index, uint32_t *fd_info) const;
amdsmi_status_t get_bdf_by_index(uint32_t gpu_index, amdsmi_bdf_t *bdf_info) const;
amdsmi_status_t get_drm_path_by_index(uint32_t gpu_index, std::string *drm_path) const;
std::vector<amdsmi_bdf_t> get_bdfs();
std::vector<std::string>& get_drm_paths();
bool check_if_drm_is_supported();
amdsmi_status_t amdgpu_query_info(int fd, unsigned info_id,
unsigned size, void *value);
amdsmi_status_t amdgpu_query_fw(int fd, unsigned info_id, unsigned fw_type,
@@ -70,6 +76,9 @@ class AMDSmiDrm {
private:
using DrmCmdWriteFunc = int (*)(int, unsigned long, void *, unsigned long);
std::vector<int> drm_fds_; // drm file descriptor by gpu_index
std::vector<std::string> drm_paths_; // drm path (renderD128 for example)
std::vector<amdsmi_bdf_t> drm_bdfs_; // bdf
AMDSmiLibraryLoader lib_loader_; // lazy load libdrm
DrmCmdWriteFunc drm_cmd_write_; // drmCommandWrite
std::mutex drm_mutex_;
+22 -2
View File
@@ -47,16 +47,32 @@
#include "amd_smi/amd_smi.h"
#include "amd_smi/impl/amd_smi_device.h"
#include "amd_smi/impl/amd_smi_drm.h"
#include "shared_mutex.h" // NOLINT
namespace amd {
namespace smi {
class AMDSmiGPUDevice: public AMDSmiDevice {
public:
explicit AMDSmiGPUDevice(uint32_t gpu_id, AMDSmiDrm& drm):
AMDSmiDevice(AMD_GPU), gpu_id_(gpu_id), drm_(drm) {}
AMDSmiGPUDevice(uint32_t gpu_id, uint32_t fd, std::string path, amdsmi_bdf_t bdf, AMDSmiDrm& drm):
AMDSmiDevice(AMD_GPU), gpu_id_(gpu_id), fd_(fd), path_(path), bdf_(bdf), drm_(drm) {}
AMDSmiGPUDevice(uint32_t gpu_id, AMDSmiDrm& drm):
AMDSmiDevice(AMD_GPU), gpu_id_(gpu_id), drm_(drm) {
if (check_if_drm_is_supported()) this->get_drm_data();
}
~AMDSmiGPUDevice() {
if (check_if_drm_is_supported()) shared_mutex_close(mutex_);
}
amdsmi_status_t get_drm_data();
pthread_mutex_t* get_mutex();
uint32_t get_gpu_id() const;
uint32_t get_gpu_fd() const;
std::string& get_gpu_path();
amdsmi_bdf_t get_bdf();
bool check_if_drm_is_supported() { return drm_.check_if_drm_is_supported(); }
amdsmi_status_t amdgpu_query_info(unsigned info_id,
unsigned size, void *value) const;
amdsmi_status_t amdgpu_query_hw_ip(unsigned info_id, unsigned hw_ip_type,
@@ -66,7 +82,11 @@ class AMDSmiGPUDevice: public AMDSmiDevice {
amdsmi_status_t amdgpu_query_vbios(void *info) const;
private:
uint32_t gpu_id_;
uint32_t fd_;
std::string path_;
amdsmi_bdf_t bdf_;
AMDSmiDrm& drm_;
shared_mutex_t mutex_;
};
+1
View File
@@ -60,6 +60,7 @@ class AMDSmiSocket {
const std::string& get_socket_id() const { return socket_identifier_;}
void add_device(AMDSmiDevice* device) { devices_.push_back(device); }
std::vector<AMDSmiDevice*>& get_devices() { return devices_;}
amdsmi_status_t get_device_count(uint32_t* device_count) const;
private:
std::string socket_identifier_;
std::vector<AMDSmiDevice*> devices_;
+44
View File
@@ -0,0 +1,44 @@
/* * Copyright (C) 2022 Advanced Micro Devices. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef AMD_SMI_INCLUDE_AMD_SMI_UTILS_H_
#define AMD_SMI_INCLUDE_AMD_SMI_UTILS_H_
#include "amd_smi/amd_smi.h"
#include "amd_smi/impl/amd_smi_gpu_device.h"
#include "rocm_smi/rocm_smi_utils.h"
#define SMIGPUDEVICE_MUTEX(MUTEX) \
amd::smi::pthread_wrap _pw(*(MUTEX)); \
amd::smi::ScopedPthread _lock(_pw, true); \
if (_lock.mutex_not_acquired()) { \
return AMDSMI_STATUS_BUSY; \
}
amdsmi_status_t smi_amdgpu_find_hwmon_dir(amd::smi::AMDSmiGPUDevice* device, std::string* full_path);
amdsmi_status_t smi_amdgpu_get_board_info(amd::smi::AMDSmiGPUDevice* device, amdsmi_board_info_t *info);
amdsmi_status_t smi_amdgpu_get_power_cap(amd::smi::AMDSmiGPUDevice* device, int *cap);
amdsmi_status_t smi_amdgpu_get_ranges(amd::smi::AMDSmiGPUDevice* device, amdsmi_clk_type_t domain, int *max_freq, int *min_freq, int *num_dpm);
amdsmi_status_t smi_amdgpu_get_enabled_blocks(amd::smi::AMDSmiGPUDevice* device, uint64_t *enabled_blocks);
amdsmi_status_t smi_amdgpu_get_bad_page_info(amd::smi::AMDSmiGPUDevice* device, uint32_t *num_pages, amdsmi_retired_page_record_t *info);
amdsmi_status_t smi_amdgpu_get_ecc_error_count(amd::smi::AMDSmiGPUDevice* device, amdsmi_error_count_t *err_cnt);
#endif //
+38
View File
@@ -0,0 +1,38 @@
/*
* Copyright 2022 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __FDINFO__
#define __FDINFO__
#ifdef __cplusplus
extern "C" {
#endif
amdsmi_status_t gpuvsmi_get_pids(const amdsmi_bdf_t &bdf, std::vector<long int> &pids, uint64_t *size);
amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid, amdsmi_proc_info_t &info);
#ifdef __cplusplus
} // extern "C"
#endif
#endif