From: jsg Date: Thu, 17 Aug 2023 03:50:28 +0000 (+0000) Subject: drm/amd/pm: expose swctf threshold setting for legacy powerplay X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7a71db80ea97dee3418ad8ff484b1d3c88be91e7;p=openbsd drm/amd/pm: expose swctf threshold setting for legacy powerplay From Evan Quan b844033ea813cb028a1961514ef37010fef9f543 in linux-6.1.y/6.1.46 064329c595da56eff6d7a7e7760660c726433139 in mainline linux --- diff --git a/sys/dev/pci/drm/amd/pm/inc/amdgpu_dpm.h b/sys/dev/pci/drm/amd/pm/inc/amdgpu_dpm.h index 76abd40b7f2..2a239451a10 100644 --- a/sys/dev/pci/drm/amd/pm/inc/amdgpu_dpm.h +++ b/sys/dev/pci/drm/amd/pm/inc/amdgpu_dpm.h @@ -89,6 +89,8 @@ struct amdgpu_dpm_thermal { int max_mem_crit_temp; /* memory max emergency(shutdown) temp */ int max_mem_emergency_temp; + /* SWCTF threshold */ + int sw_ctf_threshold; /* was last interrupt low to high or high to low */ bool high_to_low; /* interrupt source */ diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/hardwaremanager.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/hardwaremanager.c index 981dc8c7112..90452b66e10 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/hardwaremanager.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/hardwaremanager.c @@ -241,7 +241,8 @@ int phm_start_thermal_controller(struct pp_hwmgr *hwmgr) TEMP_RANGE_MAX, TEMP_RANGE_MIN, TEMP_RANGE_MAX, - TEMP_RANGE_MAX}; + TEMP_RANGE_MAX, + 0}; struct amdgpu_device *adev = hwmgr->adev; if (!hwmgr->not_vf) @@ -265,6 +266,7 @@ int phm_start_thermal_controller(struct pp_hwmgr *hwmgr) adev->pm.dpm.thermal.min_mem_temp = range.mem_min; adev->pm.dpm.thermal.max_mem_crit_temp = range.mem_crit_max; adev->pm.dpm.thermal.max_mem_emergency_temp = range.mem_emergency_max; + adev->pm.dpm.thermal.sw_ctf_threshold = range.sw_ctf_threshold; return ret; } diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c index 98dfe66d4be..1e522011617 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c @@ -5381,6 +5381,8 @@ static int smu7_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, thermal_data->max = data->thermal_temp_setting.temperature_shutdown * PP_TEMPERATURE_UNITS_PER_CENTIGRADES; + thermal_data->sw_ctf_threshold = thermal_data->max; + return 0; } diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c index bee0412d313..fae35939380 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c @@ -5221,6 +5221,9 @@ static int vega10_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, { struct vega10_hwmgr *data = hwmgr->backend; PPTable_t *pp_table = &(data->smc_state_table.pp_table); + struct phm_ppt_v2_information *pp_table_info = + (struct phm_ppt_v2_information *)(hwmgr->pptable); + struct phm_tdp_table *tdp_table = pp_table_info->tdp_table; memcpy(thermal_data, &SMU7ThermalWithDelayPolicy[0], sizeof(struct PP_TemperatureRange)); @@ -5237,6 +5240,13 @@ static int vega10_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, thermal_data->mem_emergency_max = (pp_table->ThbmLimit + CTF_OFFSET_HBM)* PP_TEMPERATURE_UNITS_PER_CENTIGRADES; + if (tdp_table->usSoftwareShutdownTemp > pp_table->ThotspotLimit && + tdp_table->usSoftwareShutdownTemp < VEGA10_THERMAL_MAXIMUM_ALERT_TEMP) + thermal_data->sw_ctf_threshold = tdp_table->usSoftwareShutdownTemp; + else + thermal_data->sw_ctf_threshold = VEGA10_THERMAL_MAXIMUM_ALERT_TEMP; + thermal_data->sw_ctf_threshold *= PP_TEMPERATURE_UNITS_PER_CENTIGRADES; + return 0; } diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c index 269ab37573c..8a517062f43 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c @@ -2742,6 +2742,8 @@ static int vega12_notify_cac_buffer_info(struct pp_hwmgr *hwmgr, static int vega12_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *thermal_data) { + struct phm_ppt_v3_information *pptable_information = + (struct phm_ppt_v3_information *)hwmgr->pptable; struct vega12_hwmgr *data = (struct vega12_hwmgr *)(hwmgr->backend); PPTable_t *pp_table = &(data->smc_state_table.pp_table); @@ -2760,6 +2762,8 @@ static int vega12_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, PP_TEMPERATURE_UNITS_PER_CENTIGRADES; thermal_data->mem_emergency_max = (pp_table->ThbmLimit + CTF_OFFSET_HBM)* PP_TEMPERATURE_UNITS_PER_CENTIGRADES; + thermal_data->sw_ctf_threshold = pptable_information->us_software_shutdown_temp * + PP_TEMPERATURE_UNITS_PER_CENTIGRADES; return 0; } diff --git a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c index 1705da11e6f..78158ee7f69 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c +++ b/sys/dev/pci/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c @@ -4213,6 +4213,8 @@ static int vega20_notify_cac_buffer_info(struct pp_hwmgr *hwmgr, static int vega20_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *thermal_data) { + struct phm_ppt_v3_information *pptable_information = + (struct phm_ppt_v3_information *)hwmgr->pptable; struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); PPTable_t *pp_table = &(data->smc_state_table.pp_table); @@ -4231,6 +4233,8 @@ static int vega20_get_thermal_temperature_range(struct pp_hwmgr *hwmgr, PP_TEMPERATURE_UNITS_PER_CENTIGRADES; thermal_data->mem_emergency_max = (pp_table->ThbmLimit + CTF_OFFSET_HBM)* PP_TEMPERATURE_UNITS_PER_CENTIGRADES; + thermal_data->sw_ctf_threshold = pptable_information->us_software_shutdown_temp * + PP_TEMPERATURE_UNITS_PER_CENTIGRADES; return 0; } diff --git a/sys/dev/pci/drm/amd/pm/powerplay/inc/power_state.h b/sys/dev/pci/drm/amd/pm/powerplay/inc/power_state.h index a5f2227a397..0ffc2347829 100644 --- a/sys/dev/pci/drm/amd/pm/powerplay/inc/power_state.h +++ b/sys/dev/pci/drm/amd/pm/powerplay/inc/power_state.h @@ -131,6 +131,7 @@ struct PP_TemperatureRange { int mem_min; int mem_crit_max; int mem_emergency_max; + int sw_ctf_threshold; }; struct PP_StateValidationBlock {