Commit a056ddce authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

drm/amd/powerplay: correct SW smu11 thermal range settings

Problems with current settings:
1. The min value was overrided to 0 on Vega20 & Navi10. While
   the expected should be -273.15 C.
2. The thermal min/max threshold was output in wrong unit on
   Navi10 & Arcturus. As TEMP_RANGE_MIN/MAX is already in
   millicelsius. And "*1000" in smu_v11_0_start_thermal_control
   makes the output wrongly.
Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarKenneth Feng <kenneth.feng@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 69174eeb
...@@ -878,23 +878,14 @@ static int arcturus_force_clk_levels(struct smu_context *smu, ...@@ -878,23 +878,14 @@ static int arcturus_force_clk_levels(struct smu_context *smu,
return ret; return ret;
} }
static const struct smu_temperature_range arcturus_thermal_policy[] =
{
{-273150, 99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000},
{ 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000},
};
static int arcturus_get_thermal_temperature_range(struct smu_context *smu, static int arcturus_get_thermal_temperature_range(struct smu_context *smu,
struct smu_temperature_range *range) struct smu_temperature_range *range)
{ {
PPTable_t *pptable = smu->smu_table.driver_pptable; PPTable_t *pptable = smu->smu_table.driver_pptable;
if (!range) if (!range)
return -EINVAL; return -EINVAL;
memcpy(range, &arcturus_thermal_policy[0], sizeof(struct smu_temperature_range));
range->max = pptable->TedgeLimit * range->max = pptable->TedgeLimit *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) * range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) *
...@@ -908,7 +899,6 @@ static int arcturus_get_thermal_temperature_range(struct smu_context *smu, ...@@ -908,7 +899,6 @@ static int arcturus_get_thermal_temperature_range(struct smu_context *smu,
range->mem_emergency_max = (pptable->TmemLimit + CTF_OFFSET_HBM)* range->mem_emergency_max = (pptable->TmemLimit + CTF_OFFSET_HBM)*
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
return 0; return 0;
} }
......
...@@ -63,6 +63,12 @@ ...@@ -63,6 +63,12 @@
#define WORKLOAD_MAP(profile, workload) \ #define WORKLOAD_MAP(profile, workload) \
[profile] = {1, (workload)} [profile] = {1, (workload)}
static const struct smu_temperature_range smu11_thermal_policy[] =
{
{-273150, 99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000},
{ 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000},
};
struct smu_11_0_cmn2aisc_mapping { struct smu_11_0_cmn2aisc_mapping {
int valid_mapping; int valid_mapping;
int map_to; int map_to;
......
...@@ -1504,9 +1504,8 @@ static int navi10_get_thermal_temperature_range(struct smu_context *smu, ...@@ -1504,9 +1504,8 @@ static int navi10_get_thermal_temperature_range(struct smu_context *smu,
if (!range || !powerplay_table) if (!range || !powerplay_table)
return -EINVAL; return -EINVAL;
/* The unit is temperature */ range->max = powerplay_table->software_shutdown_temp *
range->min = 0; SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->max = powerplay_table->software_shutdown_temp;
return 0; return 0;
} }
......
...@@ -1127,23 +1127,17 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, ...@@ -1127,23 +1127,17 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu,
} }
static int smu_v11_0_set_thermal_range(struct smu_context *smu, static int smu_v11_0_set_thermal_range(struct smu_context *smu,
struct smu_temperature_range *range) struct smu_temperature_range range)
{ {
struct amdgpu_device *adev = smu->adev; struct amdgpu_device *adev = smu->adev;
int low = SMU_THERMAL_MINIMUM_ALERT_TEMP; int low = SMU_THERMAL_MINIMUM_ALERT_TEMP;
int high = SMU_THERMAL_MAXIMUM_ALERT_TEMP; int high = SMU_THERMAL_MAXIMUM_ALERT_TEMP;
uint32_t val; uint32_t val;
if (!range) low = max(SMU_THERMAL_MINIMUM_ALERT_TEMP,
return -EINVAL; range.min / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES);
high = min(SMU_THERMAL_MAXIMUM_ALERT_TEMP,
if (low < range->min) range.max / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES);
low = range->min;
if (high > range->max)
high = range->max;
low = max(SMU_THERMAL_MINIMUM_ALERT_TEMP, range->min);
high = min(SMU_THERMAL_MAXIMUM_ALERT_TEMP, range->max);
if (low > high) if (low > high)
return -EINVAL; return -EINVAL;
...@@ -1179,27 +1173,20 @@ static int smu_v11_0_enable_thermal_alert(struct smu_context *smu) ...@@ -1179,27 +1173,20 @@ static int smu_v11_0_enable_thermal_alert(struct smu_context *smu)
static int smu_v11_0_start_thermal_control(struct smu_context *smu) static int smu_v11_0_start_thermal_control(struct smu_context *smu)
{ {
int ret = 0; int ret = 0;
struct smu_temperature_range range = { struct smu_temperature_range range;
TEMP_RANGE_MIN,
TEMP_RANGE_MAX,
TEMP_RANGE_MAX,
TEMP_RANGE_MIN,
TEMP_RANGE_MAX,
TEMP_RANGE_MAX,
TEMP_RANGE_MIN,
TEMP_RANGE_MAX,
TEMP_RANGE_MAX};
struct amdgpu_device *adev = smu->adev; struct amdgpu_device *adev = smu->adev;
if (!smu->pm_enabled) if (!smu->pm_enabled)
return ret; return ret;
memcpy(&range, &smu11_thermal_policy[0], sizeof(struct smu_temperature_range));
ret = smu_get_thermal_temperature_range(smu, &range); ret = smu_get_thermal_temperature_range(smu, &range);
if (ret) if (ret)
return ret; return ret;
if (smu->smu_table.thermal_controller_type) { if (smu->smu_table.thermal_controller_type) {
ret = smu_v11_0_set_thermal_range(smu, &range); ret = smu_v11_0_set_thermal_range(smu, range);
if (ret) if (ret)
return ret; return ret;
...@@ -1212,17 +1199,15 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu) ...@@ -1212,17 +1199,15 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)
return ret; return ret;
} }
adev->pm.dpm.thermal.min_temp = range.min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.min_temp = range.min;
adev->pm.dpm.thermal.max_temp = range.max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.max_temp = range.max;
adev->pm.dpm.thermal.max_edge_emergency_temp = range.edge_emergency_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.max_edge_emergency_temp = range.edge_emergency_max;
adev->pm.dpm.thermal.min_hotspot_temp = range.hotspot_min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.min_hotspot_temp = range.hotspot_min;
adev->pm.dpm.thermal.max_hotspot_crit_temp = range.hotspot_crit_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.max_hotspot_crit_temp = range.hotspot_crit_max;
adev->pm.dpm.thermal.max_hotspot_emergency_temp = range.hotspot_emergency_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.max_hotspot_emergency_temp = range.hotspot_emergency_max;
adev->pm.dpm.thermal.min_mem_temp = range.mem_min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.min_mem_temp = range.mem_min;
adev->pm.dpm.thermal.max_mem_crit_temp = range.mem_crit_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.max_mem_crit_temp = range.mem_crit_max;
adev->pm.dpm.thermal.max_mem_emergency_temp = range.mem_emergency_max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES; adev->pm.dpm.thermal.max_mem_emergency_temp = range.mem_emergency_max;
adev->pm.dpm.thermal.min_temp = range.min * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
adev->pm.dpm.thermal.max_temp = range.max * SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
return ret; return ret;
} }
......
...@@ -3113,14 +3113,18 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu, ...@@ -3113,14 +3113,18 @@ static int vega20_get_thermal_temperature_range(struct smu_context *smu,
if (!range || !powerplay_table) if (!range || !powerplay_table)
return -EINVAL; return -EINVAL;
/* The unit is temperature */ range->max = powerplay_table->usSoftwareShutdownTemp *
range->min = 0; SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->max = powerplay_table->usSoftwareShutdownTemp; range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) *
range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE); SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->hotspot_crit_max = pptable->ThotspotLimit; range->hotspot_crit_max = pptable->ThotspotLimit *
range->hotspot_emergency_max = (pptable->ThotspotLimit + CTF_OFFSET_HOTSPOT); SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->mem_crit_max = pptable->ThbmLimit; range->hotspot_emergency_max = (pptable->ThotspotLimit + CTF_OFFSET_HOTSPOT) *
range->mem_emergency_max = (pptable->ThbmLimit + CTF_OFFSET_HBM); SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->mem_crit_max = pptable->ThbmLimit *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
range->mem_emergency_max = (pptable->ThbmLimit + CTF_OFFSET_HBM) *
SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment