[SWDEV-540665] Move Virtualization checks in APIs into amd-smi APIs (#643)
* Remove vm checks in rocm-smi
* Move virtualization checks up the stack into amd-smi
---------
Signed-off-by: adapryor <Adam.pryor@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Co-authored-by: Maisam Arif <Maisam.Arif@amd.com>
[ROCm/amdsmi commit: f8afba0a5f]
このコミットが含まれているのは:
@@ -1288,11 +1288,6 @@ rsmi_dev_overdrive_level_get(uint32_t dv_ind, uint32_t *od) {
|
||||
CHK_SUPPORT_NAME_ONLY(od)
|
||||
DEVICE_MUTEX
|
||||
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
rsmi_status_t ret = get_dev_value_str(amd::smi::kDevOverDriveLevel, dv_ind,
|
||||
&val_str);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
@@ -1363,11 +1358,6 @@ rsmi_dev_overdrive_level_set_v1(uint32_t dv_ind, uint32_t od) {
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
DEVICE_MUTEX
|
||||
return set_dev_value(amd::smi::kDevOverDriveLevel, dv_ind, od);
|
||||
CATCH
|
||||
@@ -1490,10 +1480,6 @@ static rsmi_status_t get_power_profiles(uint32_t dv_ind,
|
||||
}
|
||||
assert(val_vec.size() <= RSMI_MAX_NUM_POWER_PROFILES);
|
||||
if (val_vec.size() > RSMI_MAX_NUM_POWER_PROFILES + 1 || val_vec.empty()) {
|
||||
// Guest may not have power related information.
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
return RSMI_STATUS_UNEXPECTED_SIZE;
|
||||
}
|
||||
// -1 for the header line, below
|
||||
@@ -1764,11 +1750,6 @@ rsmi_status_t rsmi_dev_clk_range_set(uint32_t dv_ind, uint64_t minclkvalue,
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
// Can only set the clock type for sys and mem type
|
||||
if (clkType != RSMI_CLK_TYPE_SYS && clkType != RSMI_CLK_TYPE_MEM) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
@@ -2172,11 +2153,6 @@ rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind,
|
||||
return RSMI_STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
ret = rsmi_dev_gpu_clk_freq_get(dv_ind, clk_type, &freqs);
|
||||
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
@@ -3213,10 +3189,7 @@ rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask) {
|
||||
LOG_TRACE(ss);
|
||||
REQUIRE_ROOT_ACCESS
|
||||
DEVICE_MUTEX
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bws);
|
||||
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
@@ -3657,11 +3630,6 @@ rsmi_dev_fan_speed_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t speed) {
|
||||
REQUIRE_ROOT_ACCESS
|
||||
DEVICE_MUTEX
|
||||
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
ret = rsmi_dev_fan_speed_max_get(dv_ind, sensor_ind, &max_speed);
|
||||
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
@@ -4093,11 +4061,6 @@ rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap) {
|
||||
REQUIRE_ROOT_ACCESS
|
||||
DEVICE_MUTEX
|
||||
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
ret = rsmi_dev_power_cap_range_get(dv_ind, sensor_ind, &max, &min);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return ret;
|
||||
@@ -4147,10 +4110,6 @@ rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t dummy,
|
||||
|
||||
(void)dummy;
|
||||
DEVICE_MUTEX
|
||||
// Bare Metal only feature
|
||||
if (amd::smi::is_vm_guest()) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
rsmi_status_t ret = set_power_profile(dv_ind, profile);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -1501,6 +1501,15 @@ amdsmi_status_t amdsmi_reset_gpu_fan(amdsmi_processor_handle processor_handle,
|
||||
|
||||
amdsmi_status_t amdsmi_set_gpu_fan_speed(amdsmi_processor_handle processor_handle,
|
||||
uint32_t sensor_ind, uint64_t speed) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_fan_speed_set, processor_handle, 0,
|
||||
sensor_ind, speed);
|
||||
}
|
||||
@@ -3392,19 +3401,36 @@ amdsmi_get_power_cap_info(amdsmi_processor_handle processor_handle,
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_set_power_cap(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_set_power_cap(amdsmi_processor_handle processor_handle,
|
||||
uint32_t sensor_ind, uint64_t cap) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_power_cap_set, processor_handle, 0,
|
||||
sensor_ind, cap);
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_gpu_power_profile_presets(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_get_gpu_power_profile_presets(amdsmi_processor_handle processor_handle,
|
||||
uint32_t sensor_ind,
|
||||
amdsmi_power_profile_status_t *status) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
// nullptr api supported
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_power_profile_presets_get, processor_handle, 0,
|
||||
sensor_ind, reinterpret_cast<rsmi_power_profile_status_t*>(status));
|
||||
}
|
||||
@@ -3416,8 +3442,17 @@ amdsmi_status_t amdsmi_set_gpu_perf_determinism_mode(
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_set_gpu_power_profile(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_set_gpu_power_profile(amdsmi_processor_handle processor_handle,
|
||||
uint32_t reserved, amdsmi_power_profile_preset_masks_t profile) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_power_profile_set, processor_handle, 0,
|
||||
reserved,
|
||||
static_cast<rsmi_power_profile_preset_masks_t>(profile));
|
||||
@@ -3443,6 +3478,15 @@ amdsmi_status_t
|
||||
|
||||
amdsmi_status_t amdsmi_set_gpu_pci_bandwidth(amdsmi_processor_handle processor_handle,
|
||||
uint64_t bw_bitmask) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_pci_bandwidth_set, processor_handle, 0,
|
||||
bw_bitmask);
|
||||
}
|
||||
@@ -3539,6 +3583,14 @@ amdsmi_status_t amdsmi_set_clk_freq(amdsmi_processor_handle processor_handle,
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_gpu_clk_freq_set, processor_handle, 0,
|
||||
static_cast<rsmi_clk_type_t>(clk_type), freq_bitmask);
|
||||
}
|
||||
@@ -3619,6 +3671,15 @@ amdsmi_status_t amdsmi_get_gpu_memory_usage(amdsmi_processor_handle processor_ha
|
||||
amdsmi_status_t amdsmi_get_gpu_overdrive_level(
|
||||
amdsmi_processor_handle processor_handle,
|
||||
uint32_t *od) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_overdrive_level_get, processor_handle, 0, od);
|
||||
}
|
||||
|
||||
@@ -3630,6 +3691,15 @@ amdsmi_status_t amdsmi_get_gpu_mem_overdrive_level(
|
||||
|
||||
amdsmi_status_t amdsmi_set_gpu_overdrive_level(
|
||||
amdsmi_processor_handle processor_handle, uint32_t od) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_overdrive_level_set_v1, processor_handle, 0, od);
|
||||
}
|
||||
amdsmi_status_t amdsmi_get_gpu_pci_replay_counter(
|
||||
@@ -3684,6 +3754,15 @@ amdsmi_status_t amdsmi_set_gpu_clk_range(amdsmi_processor_handle processor_handl
|
||||
uint64_t minclkvalue,
|
||||
uint64_t maxclkvalue,
|
||||
amdsmi_clk_type_t clkType) {
|
||||
|
||||
// Bare Metal and passthrough only feature
|
||||
amdsmi_virtualization_mode_t virt_mode;
|
||||
if (amdsmi_get_gpu_virtualization_mode(processor_handle, &virt_mode) == AMDSMI_STATUS_SUCCESS) {
|
||||
if (virt_mode == AMDSMI_VIRTUALIZATION_MODE_GUEST) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return rsmi_wrapper(rsmi_dev_clk_range_set, processor_handle, 0,
|
||||
minclkvalue, maxclkvalue,
|
||||
static_cast<rsmi_clk_type_t>(clkType));
|
||||
@@ -4801,7 +4880,7 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
}
|
||||
|
||||
static const std::map<amdsmi_virtualization_mode_t, std::string>
|
||||
virtualization_mode_map = {
|
||||
virtualization_mode_map = {
|
||||
{AMDSMI_VIRTUALIZATION_MODE_UNKNOWN, "UNKNOWN"},
|
||||
{AMDSMI_VIRTUALIZATION_MODE_BAREMETAL, "BAREMETAL"},
|
||||
{ AMDSMI_VIRTUALIZATION_MODE_HOST, "HOST"},
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする