From 8d347bb6c4927d3abfaa6a12329782c60ea64ca2 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Tue, 6 Dec 2022 12:39:43 -0600 Subject: [PATCH] Return errors when set clock range Instead of using assert to abort the application, the fix will return the error code if the input parameters is incorrect. Change-Id: I00861ddf1198386fb322ea06232a7178fb5ef4bd --- rocm_smi/src/rocm_smi.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rocm_smi/src/rocm_smi.cc b/rocm_smi/src/rocm_smi.cc index 7d49aef5ad..a2824bfa24 100755 --- a/rocm_smi/src/rocm_smi.cc +++ b/rocm_smi/src/rocm_smi.cc @@ -1166,14 +1166,21 @@ rsmi_status_t rsmi_dev_clk_range_set(uint32_t dv_ind, uint64_t minclkvalue, TRY rsmi_status_t ret; - assert(minclkvalue < maxclkvalue); + if (minclkvalue >= maxclkvalue) { + return RSMI_STATUS_INVALID_ARGS; + } + + // 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; + } + std::string min_sysvalue, max_sysvalue; std::map ClkStateMap = { {RSMI_CLK_TYPE_SYS, "s"}, {RSMI_CLK_TYPE_MEM, "m"}, }; DEVICE_MUTEX - assert(clkType == RSMI_CLK_TYPE_SYS || clkType == RSMI_CLK_TYPE_MEM); // Set perf. level to manual so that we can then set the power profile ret = rsmi_dev_perf_level_set_v1(dv_ind, RSMI_DEV_PERF_LEVEL_MANUAL);