[SWDEV-462952] Updated passthrough to use virtualization mode struct
Signed-off-by: gabrpham <Gabriel.Pham@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>
[ROCm/amdsmi commit: e663bed7d6]
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
760c386dd8
commit
5c1f610cc1
@@ -7,6 +7,10 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
|
||||
|
||||
### Added
|
||||
|
||||
- **Added dynamic virtualization mode detection**.
|
||||
- Added new C and Python API `amdsmi_get_gpu_virtualization_mode_info`
|
||||
- Added new C and Python enum `amdsmi_virtualization_mode_t`
|
||||
|
||||
- **Added TVIOL_ACTIVE to `amd-smi monitor`**.
|
||||
Added temperature violation active or not status to `amd-smi monitor`. TVIOL_ACTIVE will be displayed as below:
|
||||
- True if active
|
||||
|
||||
@@ -82,16 +82,18 @@ class AMDSMIHelpers():
|
||||
self._is_passthrough = True
|
||||
|
||||
# Check for passthrough system dynamically via drm querying id_flags
|
||||
if self.is_amdgpu_initialized() and not self._is_passthrough:
|
||||
device_handles = amdsmi_interface.amdsmi_get_processor_handles()
|
||||
for dev in device_handles:
|
||||
passthrough_info = amdsmi_interface.amdsmi_get_gpu_passthrough_info(dev)
|
||||
# isolate the relevant bits and then shift them over to get the correct values
|
||||
ids_flags = (passthrough_info['ids_flags'] & amdsmi_interface.AmdSmiPassthroughInfoFlags.MASK) >> amdsmi_interface.AmdSmiPassthroughInfoFlags.SHIFT
|
||||
if ids_flags & amdsmi_interface.AmdSmiPassthroughInfoFlags.PT == 0x2:
|
||||
self._is_baremetal = True
|
||||
self._is_virtual_os = False
|
||||
self._is_passthrough = True
|
||||
try:
|
||||
if self.is_amdgpu_initialized() and not self._is_passthrough:
|
||||
device_handles = amdsmi_interface.amdsmi_get_processor_handles()
|
||||
for dev in device_handles:
|
||||
virtualization_info = amdsmi_interface.amdsmi_get_gpu_virtualization_mode_info(dev)
|
||||
if virtualization_info['mode'] == amdsmi_interface.AmdSmiVirtualizationMode.PASSTHROUGH:
|
||||
self._is_baremetal = True
|
||||
self._is_virtual_os = False
|
||||
self._is_passthrough = True
|
||||
break # Once passthrough is determined, we can immediately break
|
||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||
logging.debug("Unable to determine virtualization status: " + e.get_error_code())
|
||||
|
||||
def increment_set_count(self):
|
||||
self._count_of_sets_called += 1
|
||||
|
||||
@@ -731,6 +731,79 @@ except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_violation_status
|
||||
|
||||
Description: Returns dictionary of violation status information for the given GPU.
|
||||
|
||||
Input parameters:
|
||||
|
||||
* `processor_handle` The identifier of the given device as an instance of `amdsmi_processor_handle`.
|
||||
* `*violation_status` pointer to object of type amdsmi_violation_status_t to get the violation status information
|
||||
|
||||
Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`reference_timestamp` | CPU Time Since Epoch in Microseconds
|
||||
`violation_timestamp` | Time of Violation in Nanoseconds
|
||||
`acc_counter` | Current Accumulated Counter
|
||||
`acc_prochot_thrm` | Current Accumulated Processor Hot Violation Count
|
||||
`acc_ppt_pwr` | Current Accumulated Package Power Tracking (PPT) PVIOL
|
||||
`acc_socket_thrm` | Current Accumulated Socket Thermal Count #TVIOL
|
||||
`acc_vr_thrm` | Current Accumulated Voltage Regulator Count
|
||||
`acc_hbm_thrm` | Current Accumulated High Bandwidth Memory (HBM) Thermal Count
|
||||
`acc_gfx_clk_below_host_limit` | Current Graphic Clock Below Host Limit Count
|
||||
`per_prochot_thrm` | Processor hot violation % (greater than 0% is a violation)
|
||||
`per_ppt_pwr` | PVIOL Package Power Tracking (PPT) violation % (greater than 0% is a violation)
|
||||
`per_socket_thrm` | TVIOL; Socket thermal violation % (greater than 0% is a violation)
|
||||
`per_vr_thrm` | Voltage regulator violation % (greater than 0% is a violation)
|
||||
`per_hbm_thrm` | High Bandwidth Memory (HBM) thermal violation % (greater than 0% is a violation)
|
||||
`per_gfx_clk_below_host_limit` | Graphics clock below host limit violation % (greater than 0% is a violation)
|
||||
`active_prochot_thrm` | Processor hot violation; 1 = active 0 = not active
|
||||
`active_ppt_pwr` | Package Power Tracking (PPT) violation; 1 = active 0 = not active
|
||||
`active_socket_thrm` | Socket thermal violation; 1 = active 0 = not active
|
||||
`active_vr_thrm` | Voltage regulator violation; 1 = active 0 = not active
|
||||
`active_hbm_thrm` | High Bandwidth Memory (HBM) thermal violation; 1 = active 0 = not active
|
||||
`active_gfx_clk_below_host_limit` | Graphics Clock Below Host Limit Violation; 1 = Active 0 = Not Active
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_violation_status` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
* `AmdSmiRetryException`
|
||||
* `AmdSmiParameterException`
|
||||
* `AmdSmiTimeoutException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
violation_status = amdsmi_interface.amdsmi_get_violation_status(args.gpu)
|
||||
throttle_status['accumulation_counter'] = violation_status['acc_counter']
|
||||
throttle_status['prochot_accumulated'] = violation_status['acc_prochot_thrm']
|
||||
throttle_status['ppt_accumulated'] = violation_status['acc_ppt_pwr']
|
||||
throttle_status['socket_thermal_accumulated'] = violation_status['acc_socket_thrm']
|
||||
throttle_status['vr_thermal_accumulated'] = violation_status['acc_vr_thrm']
|
||||
throttle_status['hbm_thermal_accumulated'] = violation_status['acc_hbm_thrm']
|
||||
throttle_status['gfx_clk_below_host_limit_accumulated'] = violation_status['acc_gfx_clk_below_host_limit']
|
||||
|
||||
throttle_status['prochot_violation_status'] = violation_status['active_prochot_thrm']
|
||||
throttle_status['ppt_violation_status'] = violation_status['active_ppt_pwr']
|
||||
throttle_status['socket_thermal_violation_status'] = violation_status['active_socket_thrm']
|
||||
throttle_status['vr_thermal_violation_status'] = violation_status['active_vr_thrm']
|
||||
throttle_status['hbm_thermal_violation_status'] = violation_status['active_hbm_thrm']
|
||||
throttle_status['gfx_clk_below_host_limit_violation_status'] = violation_status['active_gfx_clk_below_host_limit']
|
||||
|
||||
throttle_status['prochot_violation_activity'] = violation_status['per_prochot_thrm']
|
||||
throttle_status['ppt_violation_activity'] = violation_status['per_ppt_pwr']
|
||||
throttle_status['socket_thermal_violation_activity'] = violation_status['per_socket_thrm']
|
||||
throttle_status['vr_thermal_violation_activity'] = violation_status['per_vr_thrm']
|
||||
throttle_status['hbm_thermal_violation_activity'] = violation_status['per_hbm_thrm']
|
||||
throttle_status['gfx_clk_below_host_limit_violation_activity'] = violation_status['per_gfx_clk_below_host_limit']
|
||||
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_clock_info
|
||||
|
||||
Description: Returns the clock measure for the given GPU.
|
||||
@@ -3954,6 +4027,40 @@ finally:
|
||||
print(e)
|
||||
```
|
||||
|
||||
|
||||
### amdsmi_get_gpu_virtualization_mode_info
|
||||
|
||||
Description: Retrieve the virtualization mode for the selected GPU.
|
||||
|
||||
Input parameters:
|
||||
* `processor_handle` The identifier of the given device.
|
||||
|
||||
Output: Dictionary holding the following fields.
|
||||
* `mode` AmdSmiVirtualizationMode; an IntEnum denoting the possible virtualization modes
|
||||
Field | Description
|
||||
---|---
|
||||
`UNKNOWN` | Virtualization mode not detected
|
||||
`BAREMETAL` | Baremetal paltform detected
|
||||
`HOST` | Host/Hypervisor platform detected
|
||||
`GUEST` | Guest/Virtual Machine detected
|
||||
`PASSTHROUGH` | GPU Passthrough mode detected
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_gpu_virtualization_mode_info` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
device_handles = amdsmi_interface.amdsmi_get_processor_handles()
|
||||
for dev in device_handles:
|
||||
virtualization_info = amdsmi_interface.amdsmi_get_gpu_virtualization_mode_info(dev)
|
||||
print(virtualization_info['mode'])
|
||||
except amdsmi_exception.AmdSmiLibraryException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
## CPU APIs
|
||||
|
||||
### amdsmi_get_processor_info
|
||||
@@ -4982,76 +5089,3 @@ try:
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_violation_status
|
||||
|
||||
Description: Returns dictionary of violation status information for the given GPU.
|
||||
|
||||
Input parameters:
|
||||
|
||||
* `processor_handle` The identifier of the given device as an instance of `amdsmi_processor_handle`.
|
||||
* `*violation_status` pointer to object of type amdsmi_violation_status_t to get the violation status information
|
||||
|
||||
Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`reference_timestamp` | CPU Time Since Epoch in Microseconds
|
||||
`violation_timestamp` | Time of Violation in Nanoseconds
|
||||
`acc_counter` | Current Accumulated Counter
|
||||
`acc_prochot_thrm` | Current Accumulated Processor Hot Violation Count
|
||||
`acc_ppt_pwr` | Current Accumulated Package Power Tracking (PPT) PVIOL
|
||||
`acc_socket_thrm` | Current Accumulated Socket Thermal Count #TVIOL
|
||||
`acc_vr_thrm` | Current Accumulated Voltage Regulator Count
|
||||
`acc_hbm_thrm` | Current Accumulated High Bandwidth Memory (HBM) Thermal Count
|
||||
`acc_gfx_clk_below_host_limit` | Current Graphic Clock Below Host Limit Count
|
||||
`per_prochot_thrm` | Processor hot violation % (greater than 0% is a violation)
|
||||
`per_ppt_pwr` | PVIOL Package Power Tracking (PPT) violation % (greater than 0% is a violation)
|
||||
`per_socket_thrm` | TVIOL; Socket thermal violation % (greater than 0% is a violation)
|
||||
`per_vr_thrm` | Voltage regulator violation % (greater than 0% is a violation)
|
||||
`per_hbm_thrm` | High Bandwidth Memory (HBM) thermal violation % (greater than 0% is a violation)
|
||||
`per_gfx_clk_below_host_limit` | Graphics clock below host limit violation % (greater than 0% is a violation)
|
||||
`active_prochot_thrm` | Processor hot violation; 1 = active 0 = not active
|
||||
`active_ppt_pwr` | Package Power Tracking (PPT) violation; 1 = active 0 = not active
|
||||
`active_socket_thrm` | Socket thermal violation; 1 = active 0 = not active
|
||||
`active_vr_thrm` | Voltage regulator violation; 1 = active 0 = not active
|
||||
`active_hbm_thrm` | High Bandwidth Memory (HBM) thermal violation; 1 = active 0 = not active
|
||||
`active_gfx_clk_below_host_limit` | Graphics Clock Below Host Limit Violation; 1 = Active 0 = Not Active
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_violation_status` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
* `AmdSmiRetryException`
|
||||
* `AmdSmiParameterException`
|
||||
* `AmdSmiTimeoutException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
violation_status = amdsmi_interface.amdsmi_get_violation_status(args.gpu)
|
||||
throttle_status['accumulation_counter'] = violation_status['acc_counter']
|
||||
throttle_status['prochot_accumulated'] = violation_status['acc_prochot_thrm']
|
||||
throttle_status['ppt_accumulated'] = violation_status['acc_ppt_pwr']
|
||||
throttle_status['socket_thermal_accumulated'] = violation_status['acc_socket_thrm']
|
||||
throttle_status['vr_thermal_accumulated'] = violation_status['acc_vr_thrm']
|
||||
throttle_status['hbm_thermal_accumulated'] = violation_status['acc_hbm_thrm']
|
||||
throttle_status['gfx_clk_below_host_limit_accumulated'] = violation_status['acc_gfx_clk_below_host_limit']
|
||||
|
||||
throttle_status['prochot_violation_status'] = violation_status['active_prochot_thrm']
|
||||
throttle_status['ppt_violation_status'] = violation_status['active_ppt_pwr']
|
||||
throttle_status['socket_thermal_violation_status'] = violation_status['active_socket_thrm']
|
||||
throttle_status['vr_thermal_violation_status'] = violation_status['active_vr_thrm']
|
||||
throttle_status['hbm_thermal_violation_status'] = violation_status['active_hbm_thrm']
|
||||
throttle_status['gfx_clk_below_host_limit_violation_status'] = violation_status['active_gfx_clk_below_host_limit']
|
||||
|
||||
throttle_status['prochot_violation_activity'] = violation_status['per_prochot_thrm']
|
||||
throttle_status['ppt_violation_activity'] = violation_status['per_ppt_pwr']
|
||||
throttle_status['socket_thermal_violation_activity'] = violation_status['per_socket_thrm']
|
||||
throttle_status['vr_thermal_violation_activity'] = violation_status['per_vr_thrm']
|
||||
throttle_status['hbm_thermal_violation_activity'] = violation_status['per_hbm_thrm']
|
||||
throttle_status['gfx_clk_below_host_limit_violation_activity'] = violation_status['per_gfx_clk_below_host_limit']
|
||||
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
@@ -1682,14 +1682,15 @@ typedef struct {
|
||||
|
||||
|
||||
/**
|
||||
* @brief This structure contains information about passthrough mode in guest systems.
|
||||
* @brief This structure contains information about virtualization mode of current system.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t device_id;
|
||||
uint32_t rev_id;
|
||||
uint32_t vendor_id;
|
||||
uint64_t ids_flags;
|
||||
} amdsmi_passthrough_info_t;
|
||||
typedef enum {
|
||||
AMDSMI_VIRTUALIZATION_MODE_UNKNOWN = 0,
|
||||
AMDSMI_VIRTUALIZATION_MODE_BAREMETAL,
|
||||
AMDSMI_VIRTUALIZATION_MODE_HOST,
|
||||
AMDSMI_VIRTUALIZATION_MODE_GUEST,
|
||||
AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH
|
||||
} amdsmi_virtualization_mode_t;
|
||||
|
||||
//! Place-holder "variant" for functions that have don't have any variants,
|
||||
//! but do have monitors or sensors.
|
||||
@@ -5332,9 +5333,26 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_link_type_t link_type,
|
||||
amdsmi_topology_nearest_t* topology_nearest_info);
|
||||
|
||||
/**
|
||||
* @brief Returns the virtualization mode for the target device.
|
||||
*
|
||||
* @platform{gpu_bm_linux} @platform{host}
|
||||
*
|
||||
* @details Once called topology_nearest_info will get populated with a list of
|
||||
* all nearest devices for a given link_type. The list has a count of
|
||||
* the number of devices found and their respective handles/identifiers.
|
||||
*
|
||||
* @param[in] processor_handle The identifier of the given device.
|
||||
*
|
||||
* @param[in,out] mode Reference to the enum representing virtualization mode.
|
||||
* - When zero, the virtualization mode is unknown
|
||||
* - When non-zero, the virtualization mode is detected
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail.
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_gpu_passthrough_info(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_passthrough_info_t* info);
|
||||
amdsmi_get_gpu_virtualization_mode(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_virtualization_mode_t* mode);
|
||||
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -236,6 +236,9 @@ from .amdsmi_interface import amdsmi_get_gpu_metrics_header_info
|
||||
from .amdsmi_interface import amdsmi_get_gpu_reg_table_info
|
||||
from .amdsmi_interface import amdsmi_get_gpu_pm_metrics_info
|
||||
|
||||
# # Virtualization Mode Detection
|
||||
from .amdsmi_interface import amdsmi_get_gpu_virtualization_mode_info
|
||||
|
||||
# # Enums
|
||||
from .amdsmi_interface import AmdSmiInitFlags
|
||||
from .amdsmi_interface import AmdSmiContainerTypes
|
||||
@@ -265,6 +268,7 @@ from .amdsmi_interface import AmdSmiIoLinkType
|
||||
from .amdsmi_interface import AmdSmiLinkType
|
||||
from .amdsmi_interface import AmdSmiUtilizationCounterType
|
||||
from .amdsmi_interface import AmdSmiProcessorType
|
||||
from .amdsmi_interface import AmdSmiVirtualizationMode
|
||||
|
||||
# Exceptions
|
||||
from .amdsmi_exception import AmdSmiLibraryException
|
||||
|
||||
@@ -438,12 +438,13 @@ class AmdSmiRegType(IntEnum):
|
||||
USR1 = amdsmi_wrapper.AMDSMI_REG_USR1
|
||||
|
||||
|
||||
class AmdSmiPassthroughInfoFlags(IntEnum):
|
||||
MASK = 0x300
|
||||
SHIFT = 0x8
|
||||
PF = 0x0
|
||||
VT = 0x1
|
||||
PT = 0x2
|
||||
class AmdSmiVirtualizationMode(IntEnum):
|
||||
UNKNOWN = amdsmi_wrapper.AMDSMI_VIRTUALIZATION_MODE_UNKNOWN
|
||||
BAREMETAL = amdsmi_wrapper.AMDSMI_VIRTUALIZATION_MODE_BAREMETAL
|
||||
HOST = amdsmi_wrapper.AMDSMI_VIRTUALIZATION_MODE_HOST
|
||||
GUEST = amdsmi_wrapper.AMDSMI_VIRTUALIZATION_MODE_GUEST
|
||||
PASSTHROUGH = amdsmi_wrapper.AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH
|
||||
|
||||
|
||||
class AmdSmiEventReader:
|
||||
def __init__(
|
||||
@@ -4466,24 +4467,21 @@ def amdsmi_get_link_topology_nearest(
|
||||
'processor_list': device_list
|
||||
}
|
||||
|
||||
def amdsmi_get_gpu_passthrough_info(
|
||||
def amdsmi_get_gpu_virtualization_mode_info(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle
|
||||
) -> Dict[str, int]:
|
||||
) -> Dict[str, AmdSmiVirtualizationMode]:
|
||||
|
||||
# make info struct here
|
||||
info = amdsmi_wrapper.amdsmi_passthrough_info_t()
|
||||
mode = amdsmi_wrapper.amdsmi_virtualization_mode_t()
|
||||
|
||||
# call lib function here
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_gpu_passthrough_info(
|
||||
amdsmi_wrapper.amdsmi_get_gpu_virtualization_mode(
|
||||
processor_handle,
|
||||
ctypes.byref(info)
|
||||
ctypes.byref(mode)
|
||||
)
|
||||
)
|
||||
|
||||
return {
|
||||
"device_id": info.device_id,
|
||||
"rev_id": info.rev_id,
|
||||
"vendor_id": info.vendor_id,
|
||||
"ids_flags": info.ids_flags
|
||||
"mode": AmdSmiVirtualizationMode(mode.value)
|
||||
}
|
||||
|
||||
@@ -1990,20 +1990,20 @@ struct_amdsmi_topology_nearest_t._fields_ = [
|
||||
|
||||
amdsmi_topology_nearest_t = struct_amdsmi_topology_nearest_t
|
||||
|
||||
class struct_amdsmi_passthrough_info_t(Structure):
|
||||
pass
|
||||
|
||||
struct_amdsmi_passthrough_info_t._pack_ = 1 # source:False
|
||||
struct_amdsmi_passthrough_info_t._fields_ = [
|
||||
('device_id', ctypes.c_uint32),
|
||||
('rev_id', ctypes.c_uint32),
|
||||
('vendor_id', ctypes.c_uint32),
|
||||
('PADDING_0', ctypes.c_ubyte * 4),
|
||||
('ids_flags', ctypes.c_uint64),
|
||||
]
|
||||
|
||||
amdsmi_passthrough_info_t = struct_amdsmi_passthrough_info_t
|
||||
|
||||
# values for enumeration 'amdsmi_virtualization_mode_t'
|
||||
amdsmi_virtualization_mode_t__enumvalues = {
|
||||
0: 'AMDSMI_VIRTUALIZATION_MODE_UNKNOWN',
|
||||
1: 'AMDSMI_VIRTUALIZATION_MODE_BAREMETAL',
|
||||
2: 'AMDSMI_VIRTUALIZATION_MODE_HOST',
|
||||
3: 'AMDSMI_VIRTUALIZATION_MODE_GUEST',
|
||||
4: 'AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH',
|
||||
}
|
||||
AMDSMI_VIRTUALIZATION_MODE_UNKNOWN = 0
|
||||
AMDSMI_VIRTUALIZATION_MODE_BAREMETAL = 1
|
||||
AMDSMI_VIRTUALIZATION_MODE_HOST = 2
|
||||
AMDSMI_VIRTUALIZATION_MODE_GUEST = 3
|
||||
AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH = 4
|
||||
amdsmi_virtualization_mode_t = ctypes.c_uint32 # enum
|
||||
class struct_amdsmi_hsmp_driver_version_t(Structure):
|
||||
pass
|
||||
|
||||
@@ -2014,7 +2014,6 @@ struct_amdsmi_hsmp_driver_version_t._fields_ = [
|
||||
]
|
||||
|
||||
amdsmi_hsmp_driver_version_t = struct_amdsmi_hsmp_driver_version_t
|
||||
|
||||
class struct_amdsmi_smu_fw_version_t(Structure):
|
||||
pass
|
||||
|
||||
@@ -2570,9 +2569,9 @@ amdsmi_get_gpu_total_ecc_count.argtypes = [amdsmi_processor_handle, ctypes.POINT
|
||||
amdsmi_get_link_topology_nearest = _libraries['libamd_smi.so'].amdsmi_get_link_topology_nearest
|
||||
amdsmi_get_link_topology_nearest.restype = amdsmi_status_t
|
||||
amdsmi_get_link_topology_nearest.argtypes = [amdsmi_processor_handle, amdsmi_link_type_t, ctypes.POINTER(struct_amdsmi_topology_nearest_t)]
|
||||
amdsmi_get_gpu_passthrough_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_passthrough_info
|
||||
amdsmi_get_gpu_passthrough_info.restype = amdsmi_status_t
|
||||
amdsmi_get_gpu_passthrough_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_passthrough_info_t)]
|
||||
amdsmi_get_gpu_virtualization_mode = _libraries['libamd_smi.so'].amdsmi_get_gpu_virtualization_mode
|
||||
amdsmi_get_gpu_virtualization_mode.restype = amdsmi_status_t
|
||||
amdsmi_get_gpu_virtualization_mode.argtypes = [amdsmi_processor_handle, ctypes.POINTER(amdsmi_virtualization_mode_t)]
|
||||
amdsmi_get_cpu_core_energy = _libraries['libamd_smi.so'].amdsmi_get_cpu_core_energy
|
||||
amdsmi_get_cpu_core_energy.restype = amdsmi_status_t
|
||||
amdsmi_get_cpu_core_energy.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64)]
|
||||
@@ -2889,7 +2888,12 @@ __all__ = \
|
||||
'AMDSMI_TEMP_MAX', 'AMDSMI_TEMP_MAX_HYST', 'AMDSMI_TEMP_MIN',
|
||||
'AMDSMI_TEMP_MIN_HYST', 'AMDSMI_TEMP_OFFSET',
|
||||
'AMDSMI_UTILIZATION_COUNTER_FIRST',
|
||||
'AMDSMI_UTILIZATION_COUNTER_LAST', 'AMDSMI_VOLT_AVERAGE',
|
||||
'AMDSMI_UTILIZATION_COUNTER_LAST',
|
||||
'AMDSMI_VIRTUALIZATION_MODE_BAREMETAL',
|
||||
'AMDSMI_VIRTUALIZATION_MODE_GUEST',
|
||||
'AMDSMI_VIRTUALIZATION_MODE_HOST',
|
||||
'AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH',
|
||||
'AMDSMI_VIRTUALIZATION_MODE_UNKNOWN', 'AMDSMI_VOLT_AVERAGE',
|
||||
'AMDSMI_VOLT_CURRENT', 'AMDSMI_VOLT_FIRST', 'AMDSMI_VOLT_HIGHEST',
|
||||
'AMDSMI_VOLT_LAST', 'AMDSMI_VOLT_LOWEST', 'AMDSMI_VOLT_MAX',
|
||||
'AMDSMI_VOLT_MAX_CRIT', 'AMDSMI_VOLT_MIN', 'AMDSMI_VOLT_MIN_CRIT',
|
||||
@@ -2995,7 +2999,7 @@ __all__ = \
|
||||
'amdsmi_get_gpu_metrics_info',
|
||||
'amdsmi_get_gpu_od_volt_curve_regions',
|
||||
'amdsmi_get_gpu_od_volt_info', 'amdsmi_get_gpu_overdrive_level',
|
||||
'amdsmi_get_gpu_passthrough_info', 'amdsmi_get_gpu_pci_bandwidth',
|
||||
'amdsmi_get_gpu_pci_bandwidth',
|
||||
'amdsmi_get_gpu_pci_replay_counter',
|
||||
'amdsmi_get_gpu_pci_throughput', 'amdsmi_get_gpu_perf_level',
|
||||
'amdsmi_get_gpu_pm_metrics_info',
|
||||
@@ -3007,9 +3011,11 @@ __all__ = \
|
||||
'amdsmi_get_gpu_subsystem_id', 'amdsmi_get_gpu_subsystem_name',
|
||||
'amdsmi_get_gpu_topo_numa_affinity',
|
||||
'amdsmi_get_gpu_total_ecc_count', 'amdsmi_get_gpu_vbios_info',
|
||||
'amdsmi_get_gpu_vendor_name', 'amdsmi_get_gpu_volt_metric',
|
||||
'amdsmi_get_gpu_vram_info', 'amdsmi_get_gpu_vram_usage',
|
||||
'amdsmi_get_gpu_vram_vendor', 'amdsmi_get_gpu_xgmi_link_status',
|
||||
'amdsmi_get_gpu_vendor_name',
|
||||
'amdsmi_get_gpu_virtualization_mode',
|
||||
'amdsmi_get_gpu_volt_metric', 'amdsmi_get_gpu_vram_info',
|
||||
'amdsmi_get_gpu_vram_usage', 'amdsmi_get_gpu_vram_vendor',
|
||||
'amdsmi_get_gpu_xgmi_link_status',
|
||||
'amdsmi_get_hsmp_metrics_table',
|
||||
'amdsmi_get_hsmp_metrics_table_version', 'amdsmi_get_lib_version',
|
||||
'amdsmi_get_link_metrics', 'amdsmi_get_link_topology_nearest',
|
||||
@@ -3029,13 +3035,13 @@ __all__ = \
|
||||
'amdsmi_gpu_cache_info_t', 'amdsmi_gpu_control_counter',
|
||||
'amdsmi_gpu_counter_group_supported', 'amdsmi_gpu_create_counter',
|
||||
'amdsmi_gpu_destroy_counter', 'amdsmi_gpu_metrics_t',
|
||||
'amdsmi_gpu_read_counter', 'amdsmi_gpu_xcp_metrics_t',
|
||||
'amdsmi_gpu_xgmi_error_status', 'amdsmi_hsmp_driver_version_t',
|
||||
'amdsmi_gpu_validate_ras_eeprom',
|
||||
'amdsmi_hsmp_freqlimit_src_names', 'amdsmi_hsmp_metrics_table_t',
|
||||
'amdsmi_init', 'amdsmi_init_flags_t',
|
||||
'amdsmi_init_gpu_event_notification', 'amdsmi_io_bw_encoding_t',
|
||||
'amdsmi_io_link_type_t', 'amdsmi_is_P2P_accessible',
|
||||
'amdsmi_gpu_read_counter', 'amdsmi_gpu_validate_ras_eeprom',
|
||||
'amdsmi_gpu_xcp_metrics_t', 'amdsmi_gpu_xgmi_error_status',
|
||||
'amdsmi_hsmp_driver_version_t', 'amdsmi_hsmp_freqlimit_src_names',
|
||||
'amdsmi_hsmp_metrics_table_t', 'amdsmi_init',
|
||||
'amdsmi_init_flags_t', 'amdsmi_init_gpu_event_notification',
|
||||
'amdsmi_io_bw_encoding_t', 'amdsmi_io_link_type_t',
|
||||
'amdsmi_is_P2P_accessible',
|
||||
'amdsmi_is_gpu_power_management_enabled', 'amdsmi_kfd_info_t',
|
||||
'amdsmi_link_id_bw_type_t', 'amdsmi_link_metrics_t',
|
||||
'amdsmi_link_type_t', 'amdsmi_memory_page_status_t',
|
||||
@@ -3044,9 +3050,9 @@ __all__ = \
|
||||
'amdsmi_mm_ip_t', 'amdsmi_name_value_t', 'amdsmi_nps_caps_t',
|
||||
'amdsmi_od_vddc_point_t', 'amdsmi_od_volt_curve_t',
|
||||
'amdsmi_od_volt_freq_data_t', 'amdsmi_p2p_capability_t',
|
||||
'amdsmi_passthrough_info_t', 'amdsmi_pcie_bandwidth_t',
|
||||
'amdsmi_pcie_info_t', 'amdsmi_power_cap_info_t',
|
||||
'amdsmi_power_info_t', 'amdsmi_power_profile_preset_masks_t',
|
||||
'amdsmi_pcie_bandwidth_t', 'amdsmi_pcie_info_t',
|
||||
'amdsmi_power_cap_info_t', 'amdsmi_power_info_t',
|
||||
'amdsmi_power_profile_preset_masks_t',
|
||||
'amdsmi_power_profile_status_t', 'amdsmi_proc_info_t',
|
||||
'amdsmi_process_handle_t', 'amdsmi_process_info_t',
|
||||
'amdsmi_processor_handle', 'amdsmi_range_t',
|
||||
@@ -3083,8 +3089,9 @@ __all__ = \
|
||||
'amdsmi_utilization_counter_t',
|
||||
'amdsmi_utilization_counter_type_t', 'amdsmi_vbios_info_t',
|
||||
'amdsmi_version_t', 'amdsmi_violation_status_t',
|
||||
'amdsmi_voltage_metric_t', 'amdsmi_voltage_type_t',
|
||||
'amdsmi_vram_info_t', 'amdsmi_vram_type_t', 'amdsmi_vram_usage_t',
|
||||
'amdsmi_virtualization_mode_t', 'amdsmi_voltage_metric_t',
|
||||
'amdsmi_voltage_type_t', 'amdsmi_vram_info_t',
|
||||
'amdsmi_vram_type_t', 'amdsmi_vram_usage_t',
|
||||
'amdsmi_vram_vendor_type_t', 'amdsmi_xgmi_info_t',
|
||||
'amdsmi_xgmi_link_status_t', 'amdsmi_xgmi_link_status_type_t',
|
||||
'amdsmi_xgmi_status_t', 'processor_type_t', 'size_t',
|
||||
@@ -3112,7 +3119,6 @@ __all__ = \
|
||||
'struct_amdsmi_od_volt_curve_t',
|
||||
'struct_amdsmi_od_volt_freq_data_t',
|
||||
'struct_amdsmi_p2p_capability_t',
|
||||
'struct_amdsmi_passthrough_info_t',
|
||||
'struct_amdsmi_pcie_bandwidth_t', 'struct_amdsmi_pcie_info_t',
|
||||
'struct_amdsmi_power_cap_info_t', 'struct_amdsmi_power_info_t',
|
||||
'struct_amdsmi_power_profile_status_t',
|
||||
|
||||
@@ -3786,11 +3786,11 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_gpu_passthrough_info(amdsmi_processor_handle processor_handle, amdsmi_passthrough_info_t *info) {
|
||||
amdsmi_get_gpu_virtualization_mode(amdsmi_processor_handle processor_handle, amdsmi_virtualization_mode_t *mode) {
|
||||
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (info == nullptr) {
|
||||
if (mode == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
@@ -3808,10 +3808,29 @@ amdsmi_get_gpu_passthrough_info(amdsmi_processor_handle processor_handle, amdsmi
|
||||
|
||||
SMIGPUDEVICE_MUTEX(gpu_device->get_mutex())
|
||||
|
||||
info->device_id = dev_info.device_id;
|
||||
info->rev_id = dev_info.pci_rev;
|
||||
info->vendor_id = gpu_device->get_vendor_id();
|
||||
info->ids_flags = dev_info.ids_flags;
|
||||
// get drm version. If it's older than 3.62.0, then say not supported and exit.
|
||||
drmVersionPtr drm_version;
|
||||
int drm_fd = gpu_device->get_gpu_fd();
|
||||
drm_version = drmGetVersion(drm_fd);
|
||||
|
||||
// minimum version that supports getting of virtualization mode
|
||||
int major_version = 3;
|
||||
int minor_version = 62;
|
||||
int patch_version = 0;
|
||||
|
||||
if ((drm_version->version_major < major_version) || (drm_version->version_minor < minor_version) || (drm_version->version_patchlevel < patch_version)){
|
||||
*mode = AMDSMI_VIRTUALIZATION_MODE_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
uint32_t ids_flag = (dev_info.ids_flags & AMDGPU_IDS_FLAGS_MODE_MASK) >> AMDGPU_IDS_FLAGS_MODE_SHIFT;
|
||||
switch (ids_flag){
|
||||
case 0: *mode = AMDSMI_VIRTUALIZATION_MODE_BAREMETAL; break;
|
||||
case 1: *mode = AMDSMI_VIRTUALIZATION_MODE_GUEST; break;
|
||||
case 2: *mode = AMDSMI_VIRTUALIZATION_MODE_PASSTHROUGH; break;
|
||||
default: *mode = AMDSMI_VIRTUALIZATION_MODE_UNKNOWN; break;
|
||||
}
|
||||
}
|
||||
free(drm_version);
|
||||
}
|
||||
else {
|
||||
return AMDSMI_STATUS_DRM_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user