[SWDEV-453922] AMD SMI to provide mapping feature of other enumeration methods (#51)

Added enumeration mapping for 
- drm render
- drm card
- hsa id 
- hip id
- hip uuid (rocminfo uuid)

Signed-off-by: AL Musaffar, Yazen <Yazen.ALMusaffar@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>
This commit is contained in:
AL Musaffar, Yazen
2025-03-07 09:09:12 -06:00
committed by GitHub
parent d5b2763aba
commit 2936e00fed
11 changed files with 417 additions and 88 deletions
+44 -6
View File
@@ -174,7 +174,7 @@ typedef enum {
*
* Refer to amd.com documentation for more detail:
* https://www.amd.com/content/dam/amd/en/documents/instinct-tech-docs/white-papers/amd-cdna-3-white-paper.pdf
*
*
* @cond @tag{gpu_bm_linux} @tag{host} @tag{guest_windows} @endcond
*/
#define AMDSMI_MAX_NUM_XCP 8
@@ -680,6 +680,19 @@ typedef union {
uint64_t as_uint;
} amdsmi_bdf_t;
/**
* @brief Structure holds enumeration information
*
* @cond @tag{gpu_bm_linux} @tag{host} @endcond
*/
typedef struct {
uint32_t drm_render; // the render node under /sys/class/drm/renderD*
uint32_t drm_card; // the graphic card device under /sys/class/drm/card*
uint32_t hsa_id; // the HSA enumeration ID
uint32_t hip_id; // the HIP enumeration ID
char hip_uuid[AMDSMI_MAX_STRING_LENGTH]; // the HIP unique identifer
} amdsmi_enumeration_info_t;
/**
* @brief Card Form Factor
*
@@ -813,6 +826,7 @@ typedef struct {
uint32_t reserved[22];
} amdsmi_asic_info_t;
/**
* @brief Structure holds kfd information
*
@@ -2448,6 +2462,7 @@ amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle,
uint32_t *processor_count,
amdsmi_processor_handle* processor_handles);
#ifdef ENABLE_ESMI_LIB
/**
* @brief Get the list of the cpu core handles in a system.
@@ -2541,13 +2556,13 @@ amdsmi_get_gpu_device_bdf(amdsmi_processor_handle processor_handle, amdsmi_bdf_t
*
* @ingroup tagProcDiscovery
*
* @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf}
* @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf}
* @platform{guest_windows}
*
* @param[in] processor_handle Device which to query
*
* @param[in,out] uuid_length Length of the uuid string. As input, must be
* equal or greater than SMI_GPU_UUID_SIZE and be allocated by
* equal or greater than AMDSMI_GPU_UUID_SIZE and be allocated by
* user. As output it is the length of the uuid string.
*
* @param[out] uuid Pointer to string to store the UUID. Must be
@@ -2558,6 +2573,28 @@ amdsmi_get_gpu_device_bdf(amdsmi_processor_handle processor_handle, amdsmi_bdf_t
amdsmi_status_t
amdsmi_get_gpu_device_uuid(amdsmi_processor_handle processor_handle, unsigned int *uuid_length, char *uuid);
/**
* @brief Returns the Enumeration information for the device
*
* @ingroup tagProcDiscovery
*
* @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf}
* @platform{guest_windows}
*
* @details This function returns Enumeration information of the corresponding
* processor_handle. It will return the render number, card number,
* HSA ID, HIP ID, and the HIP UUID.
*
* @param[in] processor_handle Device which to query
*
* @param[out] info Reference to Enumeration information structure.
* Must be allocated by user.
*
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
*/
amdsmi_status_t
amdsmi_get_gpu_enumeration_info(amdsmi_processor_handle processor_handle, amdsmi_enumeration_info_t *info);
/** @} End tagProcDiscovery */
/*****************************************************************************/
@@ -2746,7 +2783,7 @@ amdsmi_get_gpu_subsystem_name(amdsmi_processor_handle processor_handle, char *na
* @brief Returns the virtualization mode for the target device.
*
* @ingroup tagIdentQuery
*
*
* @platform{gpu_bm_linux} @platform{host}
*
* @details The virtualization mode is detected and returned as an enum.
@@ -3194,7 +3231,7 @@ amdsmi_get_gpu_memory_total(amdsmi_processor_handle processor_handle, amdsmi_mem
/**
* @brief Get the current memory usage
*
*
* @ingroup tagMemoryQuery
*
* @platform{gpu_bm_linux}
@@ -3279,7 +3316,7 @@ amdsmi_get_gpu_bad_page_threshold(amdsmi_processor_handle processor_handle, uint
*
* @details This call will verify the device @p processor_handle for the
* checksum of RAS EEPROM.
*
*
* @param[in] processor_handle a processor handle
*
* @note This function requires root access
@@ -5718,6 +5755,7 @@ amdsmi_get_gpu_driver_info(amdsmi_processor_handle processor_handle, amdsmi_driv
amdsmi_status_t
amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_info_t *info);
/**
* @brief Returns the KFD (Kernel Fusion Driver) information for the device
*
@@ -80,6 +80,11 @@ class AMDSmiGPUDevice: public AMDSmiProcessor {
amdsmi_status_t amdgpu_query_driver_name(std::string& name) const;
amdsmi_status_t amdgpu_query_driver_date(std::string& date) const;
// New methods for -e feature
std::string bdf_to_string() const;
uint32_t get_card_from_bdf() const;
uint32_t get_render_id() const;
private:
uint32_t gpu_id_;
uint32_t fd_;