Commit b3b03052 authored by Rex Zhu's avatar Rex Zhu Committed by Alex Deucher

drm/amd/powerplay: refine powerplay code.

delete struct smumgr, put smu backend function table
in struct hwmgr
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarRex Zhu <Rex.Zhu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 221c89f9
...@@ -35,13 +35,13 @@ static inline int pp_check(struct pp_instance *handle) ...@@ -35,13 +35,13 @@ static inline int pp_check(struct pp_instance *handle)
if (handle == NULL || handle->pp_valid != PP_VALID) if (handle == NULL || handle->pp_valid != PP_VALID)
return -EINVAL; return -EINVAL;
if (handle->smu_mgr == NULL || handle->smu_mgr->smumgr_funcs == NULL) if (handle->hwmgr == NULL || handle->hwmgr->smumgr_funcs == NULL)
return -EINVAL; return -EINVAL;
if (handle->pm_en == 0) if (handle->pm_en == 0)
return PP_DPM_DISABLED; return PP_DPM_DISABLED;
if (handle->hwmgr == NULL || handle->hwmgr->hwmgr_func == NULL) if (handle->hwmgr->hwmgr_func == NULL)
return PP_DPM_DISABLED; return PP_DPM_DISABLED;
return 0; return 0;
...@@ -52,38 +52,32 @@ static int pp_early_init(void *handle) ...@@ -52,38 +52,32 @@ static int pp_early_init(void *handle)
int ret; int ret;
struct pp_instance *pp_handle = (struct pp_instance *)handle; struct pp_instance *pp_handle = (struct pp_instance *)handle;
ret = smum_early_init(pp_handle); ret = hwmgr_early_init(pp_handle);
if (ret) if (ret)
return ret; return -EINVAL;
if ((pp_handle->pm_en == 0) if ((pp_handle->pm_en == 0)
|| cgs_is_virtualization_enabled(pp_handle->device)) || cgs_is_virtualization_enabled(pp_handle->device))
return PP_DPM_DISABLED; return PP_DPM_DISABLED;
ret = hwmgr_early_init(pp_handle);
if (ret) {
pp_handle->pm_en = 0;
return PP_DPM_DISABLED;
}
return 0; return 0;
} }
static int pp_sw_init(void *handle) static int pp_sw_init(void *handle)
{ {
struct pp_smumgr *smumgr; struct pp_hwmgr *hwmgr;
int ret = 0; int ret = 0;
struct pp_instance *pp_handle = (struct pp_instance *)handle; struct pp_instance *pp_handle = (struct pp_instance *)handle;
ret = pp_check(pp_handle); ret = pp_check(pp_handle);
if (ret == 0 || ret == PP_DPM_DISABLED) { if (ret == 0 || ret == PP_DPM_DISABLED) {
smumgr = pp_handle->smu_mgr; hwmgr = pp_handle->hwmgr;
if (smumgr->smumgr_funcs->smu_init == NULL) if (hwmgr->smumgr_funcs->smu_init == NULL)
return -EINVAL; return -EINVAL;
ret = smumgr->smumgr_funcs->smu_init(pp_handle->hwmgr); ret = hwmgr->smumgr_funcs->smu_init(hwmgr);
pr_info("amdgpu: powerplay sw initialized\n"); pr_info("amdgpu: powerplay sw initialized\n");
} }
...@@ -92,39 +86,39 @@ static int pp_sw_init(void *handle) ...@@ -92,39 +86,39 @@ static int pp_sw_init(void *handle)
static int pp_sw_fini(void *handle) static int pp_sw_fini(void *handle)
{ {
struct pp_smumgr *smumgr; struct pp_hwmgr *hwmgr;
int ret = 0; int ret = 0;
struct pp_instance *pp_handle = (struct pp_instance *)handle; struct pp_instance *pp_handle = (struct pp_instance *)handle;
ret = pp_check(pp_handle); ret = pp_check(pp_handle);
if (ret == 0 || ret == PP_DPM_DISABLED) { if (ret == 0 || ret == PP_DPM_DISABLED) {
smumgr = pp_handle->smu_mgr; hwmgr = pp_handle->hwmgr;
if (smumgr->smumgr_funcs->smu_fini == NULL) if (hwmgr->smumgr_funcs->smu_fini == NULL)
return -EINVAL; return -EINVAL;
ret = smumgr->smumgr_funcs->smu_fini(pp_handle->hwmgr); ret = hwmgr->smumgr_funcs->smu_fini(pp_handle->hwmgr);
} }
return ret; return ret;
} }
static int pp_hw_init(void *handle) static int pp_hw_init(void *handle)
{ {
struct pp_smumgr *smumgr;
int ret = 0; int ret = 0;
struct pp_instance *pp_handle = (struct pp_instance *)handle; struct pp_instance *pp_handle = (struct pp_instance *)handle;
struct pp_hwmgr *hwmgr;
ret = pp_check(pp_handle); ret = pp_check(pp_handle);
if (ret == 0 || ret == PP_DPM_DISABLED) { if (ret == 0 || ret == PP_DPM_DISABLED) {
smumgr = pp_handle->smu_mgr; hwmgr = pp_handle->hwmgr;
if (smumgr->smumgr_funcs->start_smu == NULL) if (hwmgr->smumgr_funcs->start_smu == NULL)
return -EINVAL; return -EINVAL;
if(smumgr->smumgr_funcs->start_smu(pp_handle->hwmgr)) { if(hwmgr->smumgr_funcs->start_smu(pp_handle->hwmgr)) {
pr_err("smc start failed\n"); pr_err("smc start failed\n");
smumgr->smumgr_funcs->smu_fini(pp_handle->hwmgr); hwmgr->smumgr_funcs->smu_fini(pp_handle->hwmgr);
return -EINVAL;; return -EINVAL;;
} }
if (ret == PP_DPM_DISABLED) if (ret == PP_DPM_DISABLED)
...@@ -137,8 +131,6 @@ static int pp_hw_init(void *handle) ...@@ -137,8 +131,6 @@ static int pp_hw_init(void *handle)
return 0; return 0;
err: err:
pp_handle->pm_en = 0; pp_handle->pm_en = 0;
kfree(pp_handle->hwmgr);
pp_handle->hwmgr = NULL;
return PP_DPM_DISABLED; return PP_DPM_DISABLED;
} }
...@@ -232,7 +224,7 @@ static int pp_suspend(void *handle) ...@@ -232,7 +224,7 @@ static int pp_suspend(void *handle)
static int pp_resume(void *handle) static int pp_resume(void *handle)
{ {
struct pp_smumgr *smumgr; struct pp_hwmgr *hwmgr;
int ret, ret1; int ret, ret1;
struct pp_instance *pp_handle = (struct pp_instance *)handle; struct pp_instance *pp_handle = (struct pp_instance *)handle;
...@@ -241,15 +233,15 @@ static int pp_resume(void *handle) ...@@ -241,15 +233,15 @@ static int pp_resume(void *handle)
if (ret1 != 0 && ret1 != PP_DPM_DISABLED) if (ret1 != 0 && ret1 != PP_DPM_DISABLED)
return ret1; return ret1;
smumgr = pp_handle->smu_mgr; hwmgr = pp_handle->hwmgr;
if (smumgr->smumgr_funcs->start_smu == NULL) if (hwmgr->smumgr_funcs->start_smu == NULL)
return -EINVAL; return -EINVAL;
ret = smumgr->smumgr_funcs->start_smu(pp_handle->hwmgr); ret = hwmgr->smumgr_funcs->start_smu(pp_handle->hwmgr);
if (ret) { if (ret) {
pr_err("smc start failed\n"); pr_err("smc start failed\n");
smumgr->smumgr_funcs->smu_fini(pp_handle->hwmgr); hwmgr->smumgr_funcs->smu_fini(pp_handle->hwmgr);
return ret; return ret;
} }
...@@ -1157,13 +1149,9 @@ int amd_powerplay_destroy(void *handle) ...@@ -1157,13 +1149,9 @@ int amd_powerplay_destroy(void *handle)
{ {
struct pp_instance *instance = (struct pp_instance *)handle; struct pp_instance *instance = (struct pp_instance *)handle;
if (instance->pm_en) { kfree(instance->hwmgr);
kfree(instance->hwmgr); instance->hwmgr = NULL;
instance->hwmgr = NULL;
}
kfree(instance->smu_mgr);
instance->smu_mgr = NULL;
kfree(instance); kfree(instance);
instance = NULL; instance = NULL;
return 0; return 0;
...@@ -1174,7 +1162,7 @@ int amd_powerplay_reset(void *handle) ...@@ -1174,7 +1162,7 @@ int amd_powerplay_reset(void *handle)
struct pp_instance *instance = (struct pp_instance *)handle; struct pp_instance *instance = (struct pp_instance *)handle;
int ret; int ret;
if (cgs_is_virtualization_enabled(instance->smu_mgr->device)) if (cgs_is_virtualization_enabled(instance->hwmgr->device))
return PP_DPM_DISABLED; return PP_DPM_DISABLED;
ret = pp_check(instance); ret = pp_check(instance);
......
...@@ -37,6 +37,15 @@ ...@@ -37,6 +37,15 @@
#include "amd_acpi.h" #include "amd_acpi.h"
#include "pp_psm.h" #include "pp_psm.h"
extern const struct pp_smumgr_func ci_smu_funcs;
extern const struct pp_smumgr_func cz_smu_funcs;
extern const struct pp_smumgr_func iceland_smu_funcs;
extern const struct pp_smumgr_func tonga_smu_funcs;
extern const struct pp_smumgr_func fiji_smu_funcs;
extern const struct pp_smumgr_func polaris10_smu_funcs;
extern const struct pp_smumgr_func vega10_smu_funcs;
extern const struct pp_smumgr_func rv_smu_funcs;
extern int cz_init_function_pointers(struct pp_hwmgr *hwmgr); extern int cz_init_function_pointers(struct pp_hwmgr *hwmgr);
static int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr); static int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr);
static void hwmgr_init_default_caps(struct pp_hwmgr *hwmgr); static void hwmgr_init_default_caps(struct pp_hwmgr *hwmgr);
...@@ -132,7 +141,6 @@ int hwmgr_early_init(struct pp_instance *handle) ...@@ -132,7 +141,6 @@ int hwmgr_early_init(struct pp_instance *handle)
return -ENOMEM; return -ENOMEM;
handle->hwmgr = hwmgr; handle->hwmgr = hwmgr;
hwmgr->smumgr = handle->smu_mgr;
hwmgr->device = handle->device; hwmgr->device = handle->device;
hwmgr->chip_family = handle->chip_family; hwmgr->chip_family = handle->chip_family;
hwmgr->chip_id = handle->chip_id; hwmgr->chip_id = handle->chip_id;
...@@ -144,9 +152,11 @@ int hwmgr_early_init(struct pp_instance *handle) ...@@ -144,9 +152,11 @@ int hwmgr_early_init(struct pp_instance *handle)
hwmgr_init_default_caps(hwmgr); hwmgr_init_default_caps(hwmgr);
hwmgr_set_user_specify_caps(hwmgr); hwmgr_set_user_specify_caps(hwmgr);
hwmgr->fan_ctrl_is_in_default_mode = true; hwmgr->fan_ctrl_is_in_default_mode = true;
hwmgr->reload_fw = 1;
switch (hwmgr->chip_family) { switch (hwmgr->chip_family) {
case AMDGPU_FAMILY_CI: case AMDGPU_FAMILY_CI:
hwmgr->smumgr_funcs = &ci_smu_funcs;
ci_set_asic_special_caps(hwmgr); ci_set_asic_special_caps(hwmgr);
hwmgr->feature_mask &= ~(PP_VBI_TIME_SUPPORT_MASK | hwmgr->feature_mask &= ~(PP_VBI_TIME_SUPPORT_MASK |
PP_ENABLE_GFX_CG_THRU_SMU); PP_ENABLE_GFX_CG_THRU_SMU);
...@@ -154,21 +164,25 @@ int hwmgr_early_init(struct pp_instance *handle) ...@@ -154,21 +164,25 @@ int hwmgr_early_init(struct pp_instance *handle)
smu7_init_function_pointers(hwmgr); smu7_init_function_pointers(hwmgr);
break; break;
case AMDGPU_FAMILY_CZ: case AMDGPU_FAMILY_CZ:
hwmgr->smumgr_funcs = &cz_smu_funcs;
cz_init_function_pointers(hwmgr); cz_init_function_pointers(hwmgr);
break; break;
case AMDGPU_FAMILY_VI: case AMDGPU_FAMILY_VI:
switch (hwmgr->chip_id) { switch (hwmgr->chip_id) {
case CHIP_TOPAZ: case CHIP_TOPAZ:
hwmgr->smumgr_funcs = &iceland_smu_funcs;
topaz_set_asic_special_caps(hwmgr); topaz_set_asic_special_caps(hwmgr);
hwmgr->feature_mask &= ~ (PP_VBI_TIME_SUPPORT_MASK | hwmgr->feature_mask &= ~ (PP_VBI_TIME_SUPPORT_MASK |
PP_ENABLE_GFX_CG_THRU_SMU); PP_ENABLE_GFX_CG_THRU_SMU);
hwmgr->pp_table_version = PP_TABLE_V0; hwmgr->pp_table_version = PP_TABLE_V0;
break; break;
case CHIP_TONGA: case CHIP_TONGA:
hwmgr->smumgr_funcs = &tonga_smu_funcs;
tonga_set_asic_special_caps(hwmgr); tonga_set_asic_special_caps(hwmgr);
hwmgr->feature_mask &= ~PP_VBI_TIME_SUPPORT_MASK; hwmgr->feature_mask &= ~PP_VBI_TIME_SUPPORT_MASK;
break; break;
case CHIP_FIJI: case CHIP_FIJI:
hwmgr->smumgr_funcs = &fiji_smu_funcs;
fiji_set_asic_special_caps(hwmgr); fiji_set_asic_special_caps(hwmgr);
hwmgr->feature_mask &= ~ (PP_VBI_TIME_SUPPORT_MASK | hwmgr->feature_mask &= ~ (PP_VBI_TIME_SUPPORT_MASK |
PP_ENABLE_GFX_CG_THRU_SMU); PP_ENABLE_GFX_CG_THRU_SMU);
...@@ -176,6 +190,7 @@ int hwmgr_early_init(struct pp_instance *handle) ...@@ -176,6 +190,7 @@ int hwmgr_early_init(struct pp_instance *handle)
case CHIP_POLARIS11: case CHIP_POLARIS11:
case CHIP_POLARIS10: case CHIP_POLARIS10:
case CHIP_POLARIS12: case CHIP_POLARIS12:
hwmgr->smumgr_funcs = &polaris10_smu_funcs;
polaris_set_asic_special_caps(hwmgr); polaris_set_asic_special_caps(hwmgr);
hwmgr->feature_mask &= ~(PP_UVD_HANDSHAKE_MASK); hwmgr->feature_mask &= ~(PP_UVD_HANDSHAKE_MASK);
break; break;
...@@ -187,6 +202,7 @@ int hwmgr_early_init(struct pp_instance *handle) ...@@ -187,6 +202,7 @@ int hwmgr_early_init(struct pp_instance *handle)
case AMDGPU_FAMILY_AI: case AMDGPU_FAMILY_AI:
switch (hwmgr->chip_id) { switch (hwmgr->chip_id) {
case CHIP_VEGA10: case CHIP_VEGA10:
hwmgr->smumgr_funcs = &vega10_smu_funcs;
vega10_hwmgr_init(hwmgr); vega10_hwmgr_init(hwmgr);
break; break;
default: default:
...@@ -196,6 +212,7 @@ int hwmgr_early_init(struct pp_instance *handle) ...@@ -196,6 +212,7 @@ int hwmgr_early_init(struct pp_instance *handle)
case AMDGPU_FAMILY_RV: case AMDGPU_FAMILY_RV:
switch (hwmgr->chip_id) { switch (hwmgr->chip_id) {
case CHIP_RAVEN: case CHIP_RAVEN:
hwmgr->smumgr_funcs = &rv_smu_funcs;
rv_init_function_pointers(hwmgr); rv_init_function_pointers(hwmgr);
break; break;
default: default:
......
...@@ -1382,7 +1382,7 @@ static void smu7_init_dpm_defaults(struct pp_hwmgr *hwmgr) ...@@ -1382,7 +1382,7 @@ static void smu7_init_dpm_defaults(struct pp_hwmgr *hwmgr)
data->force_pcie_gen = PP_PCIEGenInvalid; data->force_pcie_gen = PP_PCIEGenInvalid;
data->ulv_supported = hwmgr->feature_mask & PP_ULV_MASK ? true : false; data->ulv_supported = hwmgr->feature_mask & PP_ULV_MASK ? true : false;
if (hwmgr->chip_id == CHIP_POLARIS12 || hwmgr->smumgr->is_kicker) { if (hwmgr->chip_id == CHIP_POLARIS12 || hwmgr->is_kicker) {
uint8_t tmp1, tmp2; uint8_t tmp1, tmp2;
uint16_t tmp3 = 0; uint16_t tmp3 = 0;
atomctrl_get_svi2_info(hwmgr, VOLTAGE_TYPE_VDDC, &tmp1, &tmp2, atomctrl_get_svi2_info(hwmgr, VOLTAGE_TYPE_VDDC, &tmp1, &tmp2,
...@@ -4623,7 +4623,7 @@ static int smu7_set_power_profile_state(struct pp_hwmgr *hwmgr, ...@@ -4623,7 +4623,7 @@ static int smu7_set_power_profile_state(struct pp_hwmgr *hwmgr,
static int smu7_avfs_control(struct pp_hwmgr *hwmgr, bool enable) static int smu7_avfs_control(struct pp_hwmgr *hwmgr, bool enable)
{ {
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
if (smu_data == NULL) if (smu_data == NULL)
return -EINVAL; return -EINVAL;
......
...@@ -763,7 +763,7 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr) ...@@ -763,7 +763,7 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr)
} else if (hwmgr->chip_id == CHIP_POLARIS11) { } else if (hwmgr->chip_id == CHIP_POLARIS11) {
result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11);
PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result);
if (hwmgr->smumgr->is_kicker) if (hwmgr->is_kicker)
result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11_Kicker); result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11_Kicker);
else else
result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11); result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11);
......
...@@ -235,6 +235,39 @@ struct phm_vce_clock_voltage_dependency_table { ...@@ -235,6 +235,39 @@ struct phm_vce_clock_voltage_dependency_table {
struct phm_vce_clock_voltage_dependency_record entries[1]; struct phm_vce_clock_voltage_dependency_record entries[1];
}; };
struct pp_smumgr_func {
int (*smu_init)(struct pp_hwmgr *hwmgr);
int (*smu_fini)(struct pp_hwmgr *hwmgr);
int (*start_smu)(struct pp_hwmgr *hwmgr);
int (*check_fw_load_finish)(struct pp_hwmgr *hwmgr,
uint32_t firmware);
int (*request_smu_load_fw)(struct pp_hwmgr *hwmgr);
int (*request_smu_load_specific_fw)(struct pp_hwmgr *hwmgr,
uint32_t firmware);
int (*get_argument)(struct pp_hwmgr *hwmgr);
int (*send_msg_to_smc)(struct pp_hwmgr *hwmgr, uint16_t msg);
int (*send_msg_to_smc_with_parameter)(struct pp_hwmgr *hwmgr,
uint16_t msg, uint32_t parameter);
int (*download_pptable_settings)(struct pp_hwmgr *hwmgr,
void **table);
int (*upload_pptable_settings)(struct pp_hwmgr *hwmgr);
int (*update_smc_table)(struct pp_hwmgr *hwmgr, uint32_t type);
int (*process_firmware_header)(struct pp_hwmgr *hwmgr);
int (*update_sclk_threshold)(struct pp_hwmgr *hwmgr);
int (*thermal_setup_fan_table)(struct pp_hwmgr *hwmgr);
int (*thermal_avfs_enable)(struct pp_hwmgr *hwmgr);
int (*init_smc_table)(struct pp_hwmgr *hwmgr);
int (*populate_all_graphic_levels)(struct pp_hwmgr *hwmgr);
int (*populate_all_memory_levels)(struct pp_hwmgr *hwmgr);
int (*initialize_mc_reg_table)(struct pp_hwmgr *hwmgr);
uint32_t (*get_offsetof)(uint32_t type, uint32_t member);
uint32_t (*get_mac_definition)(uint32_t value);
bool (*is_dpm_running)(struct pp_hwmgr *hwmgr);
int (*populate_requested_graphic_levels)(struct pp_hwmgr *hwmgr,
struct amd_pp_profile *request);
bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr);
};
struct pp_hwmgr_func { struct pp_hwmgr_func {
int (*backend_init)(struct pp_hwmgr *hw_mgr); int (*backend_init)(struct pp_hwmgr *hw_mgr);
int (*backend_fini)(struct pp_hwmgr *hw_mgr); int (*backend_fini)(struct pp_hwmgr *hw_mgr);
...@@ -706,10 +739,17 @@ struct pp_hwmgr { ...@@ -706,10 +739,17 @@ struct pp_hwmgr {
void *pptable; void *pptable;
struct phm_platform_descriptor platform_descriptor; struct phm_platform_descriptor platform_descriptor;
void *backend; void *backend;
void *smu_backend;
const struct pp_smumgr_func *smumgr_funcs;
bool is_kicker;
bool reload_fw;
enum PP_DAL_POWERLEVEL dal_power_level; enum PP_DAL_POWERLEVEL dal_power_level;
struct phm_dynamic_state_info dyn_state; struct phm_dynamic_state_info dyn_state;
const struct pp_hwmgr_func *hwmgr_func; const struct pp_hwmgr_func *hwmgr_func;
const struct pp_table_func *pptable_func; const struct pp_table_func *pptable_func;
struct pp_power_state *ps; struct pp_power_state *ps;
enum pp_power_source power_source; enum pp_power_source power_source;
uint32_t num_ps; uint32_t num_ps;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#ifndef _PP_INSTANCE_H_ #ifndef _PP_INSTANCE_H_
#define _PP_INSTANCE_H_ #define _PP_INSTANCE_H_
#include "smumgr.h"
#include "hwmgr.h" #include "hwmgr.h"
#define PP_VALID 0x1F1F1F1F #define PP_VALID 0x1F1F1F1F
...@@ -35,7 +34,6 @@ struct pp_instance { ...@@ -35,7 +34,6 @@ struct pp_instance {
bool pm_en; bool pm_en;
uint32_t feature_mask; uint32_t feature_mask;
void *device; void *device;
struct pp_smumgr *smu_mgr;
struct pp_hwmgr *hwmgr; struct pp_hwmgr *hwmgr;
struct mutex pp_lock; struct mutex pp_lock;
}; };
......
...@@ -23,24 +23,13 @@ ...@@ -23,24 +23,13 @@
#ifndef _SMUMGR_H_ #ifndef _SMUMGR_H_
#define _SMUMGR_H_ #define _SMUMGR_H_
#include <linux/types.h> #include <linux/types.h>
#include "pp_instance.h"
#include "amd_powerplay.h" #include "amd_powerplay.h"
#include "hwmgr.h"
struct pp_smumgr;
struct pp_instance;
struct pp_hwmgr;
#define smu_lower_32_bits(n) ((uint32_t)(n)) #define smu_lower_32_bits(n) ((uint32_t)(n))
#define smu_upper_32_bits(n) ((uint32_t)(((n)>>16)>>16)) #define smu_upper_32_bits(n) ((uint32_t)(((n)>>16)>>16))
extern const struct pp_smumgr_func ci_smu_funcs;
extern const struct pp_smumgr_func cz_smu_funcs;
extern const struct pp_smumgr_func iceland_smu_funcs;
extern const struct pp_smumgr_func tonga_smu_funcs;
extern const struct pp_smumgr_func fiji_smu_funcs;
extern const struct pp_smumgr_func polaris10_smu_funcs;
extern const struct pp_smumgr_func vega10_smu_funcs;
extern const struct pp_smumgr_func rv_smu_funcs;
enum AVFS_BTC_STATUS { enum AVFS_BTC_STATUS {
AVFS_BTC_BOOT = 0, AVFS_BTC_BOOT = 0,
...@@ -101,53 +90,6 @@ enum SMU_MAC_DEFINITION { ...@@ -101,53 +90,6 @@ enum SMU_MAC_DEFINITION {
SMU_UVD_MCLK_HANDSHAKE_DISABLE, SMU_UVD_MCLK_HANDSHAKE_DISABLE,
}; };
struct pp_smumgr_func {
int (*smu_init)(struct pp_hwmgr *hwmgr);
int (*smu_fini)(struct pp_hwmgr *hwmgr);
int (*start_smu)(struct pp_hwmgr *hwmgr);
int (*check_fw_load_finish)(struct pp_hwmgr *hwmgr,
uint32_t firmware);
int (*request_smu_load_fw)(struct pp_hwmgr *hwmgr);
int (*request_smu_load_specific_fw)(struct pp_hwmgr *hwmgr,
uint32_t firmware);
int (*get_argument)(struct pp_hwmgr *hwmgr);
int (*send_msg_to_smc)(struct pp_hwmgr *hwmgr, uint16_t msg);
int (*send_msg_to_smc_with_parameter)(struct pp_hwmgr *hwmgr,
uint16_t msg, uint32_t parameter);
int (*download_pptable_settings)(struct pp_hwmgr *hwmgr,
void **table);
int (*upload_pptable_settings)(struct pp_hwmgr *hwmgr);
int (*update_smc_table)(struct pp_hwmgr *hwmgr, uint32_t type);
int (*process_firmware_header)(struct pp_hwmgr *hwmgr);
int (*update_sclk_threshold)(struct pp_hwmgr *hwmgr);
int (*thermal_setup_fan_table)(struct pp_hwmgr *hwmgr);
int (*thermal_avfs_enable)(struct pp_hwmgr *hwmgr);
int (*init_smc_table)(struct pp_hwmgr *hwmgr);
int (*populate_all_graphic_levels)(struct pp_hwmgr *hwmgr);
int (*populate_all_memory_levels)(struct pp_hwmgr *hwmgr);
int (*initialize_mc_reg_table)(struct pp_hwmgr *hwmgr);
uint32_t (*get_offsetof)(uint32_t type, uint32_t member);
uint32_t (*get_mac_definition)(uint32_t value);
bool (*is_dpm_running)(struct pp_hwmgr *hwmgr);
int (*populate_requested_graphic_levels)(struct pp_hwmgr *hwmgr,
struct amd_pp_profile *request);
bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr);
};
struct pp_smumgr {
uint32_t chip_family;
uint32_t chip_id;
void *device;
void *backend;
uint32_t usec_timeout;
bool reload_fw;
const struct pp_smumgr_func *smumgr_funcs;
bool is_kicker;
};
extern int smum_early_init(struct pp_instance *handle);
extern int smum_get_argument(struct pp_hwmgr *hwmgr); extern int smum_get_argument(struct pp_hwmgr *hwmgr);
extern int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table); extern int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table);
......
...@@ -43,15 +43,15 @@ static int ci_smu_init(struct pp_hwmgr *hwmgr) ...@@ -43,15 +43,15 @@ static int ci_smu_init(struct pp_hwmgr *hwmgr)
for (i = 0; i < SMU7_MAX_LEVELS_GRAPHICS; i++) for (i = 0; i < SMU7_MAX_LEVELS_GRAPHICS; i++)
ci_priv->activity_target[i] = 30; ci_priv->activity_target[i] = 30;
hwmgr->smumgr->backend = ci_priv; hwmgr->smu_backend = ci_priv;
return 0; return 0;
} }
static int ci_smu_fini(struct pp_hwmgr *hwmgr) static int ci_smu_fini(struct pp_hwmgr *hwmgr)
{ {
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
hwmgr->smumgr->backend = NULL; hwmgr->smu_backend = NULL;
cgs_rel_firmware(hwmgr->device, CGS_UCODE_ID_SMU); cgs_rel_firmware(hwmgr->device, CGS_UCODE_ID_SMU);
return 0; return 0;
} }
......
...@@ -181,7 +181,7 @@ static int cz_load_mec_firmware(struct pp_hwmgr *hwmgr) ...@@ -181,7 +181,7 @@ static int cz_load_mec_firmware(struct pp_hwmgr *hwmgr)
if (hwmgr == NULL || hwmgr->device == NULL) if (hwmgr == NULL || hwmgr->device == NULL)
return -EINVAL; return -EINVAL;
cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
ret = cgs_get_firmware_info(hwmgr->device, ret = cgs_get_firmware_info(hwmgr->device,
CGS_UCODE_ID_CP_MEC, &info); CGS_UCODE_ID_CP_MEC, &info);
...@@ -330,7 +330,7 @@ static int cz_smu_populate_single_scratch_task( ...@@ -330,7 +330,7 @@ static int cz_smu_populate_single_scratch_task(
uint8_t type, bool is_last) uint8_t type, bool is_last)
{ {
uint8_t i; uint8_t i;
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr; struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr;
struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++]; struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++];
...@@ -367,7 +367,7 @@ static int cz_smu_populate_single_ucode_load_task( ...@@ -367,7 +367,7 @@ static int cz_smu_populate_single_ucode_load_task(
bool is_last) bool is_last)
{ {
uint8_t i; uint8_t i;
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr; struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr;
struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++]; struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++];
...@@ -393,7 +393,7 @@ static int cz_smu_populate_single_ucode_load_task( ...@@ -393,7 +393,7 @@ static int cz_smu_populate_single_ucode_load_task(
static int cz_smu_construct_toc_for_rlc_aram_save(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc_for_rlc_aram_save(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
cz_smu->toc_entry_aram = cz_smu->toc_entry_used_count; cz_smu->toc_entry_aram = cz_smu->toc_entry_used_count;
cz_smu_populate_single_scratch_task(hwmgr, cz_smu_populate_single_scratch_task(hwmgr,
...@@ -406,7 +406,7 @@ static int cz_smu_construct_toc_for_rlc_aram_save(struct pp_hwmgr *hwmgr) ...@@ -406,7 +406,7 @@ static int cz_smu_construct_toc_for_rlc_aram_save(struct pp_hwmgr *hwmgr)
static int cz_smu_initialize_toc_empty_job_list(struct pp_hwmgr *hwmgr) static int cz_smu_initialize_toc_empty_job_list(struct pp_hwmgr *hwmgr)
{ {
int i; int i;
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr; struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr;
for (i = 0; i < NUM_JOBLIST_ENTRIES; i++) for (i = 0; i < NUM_JOBLIST_ENTRIES; i++)
...@@ -417,7 +417,7 @@ static int cz_smu_initialize_toc_empty_job_list(struct pp_hwmgr *hwmgr) ...@@ -417,7 +417,7 @@ static int cz_smu_initialize_toc_empty_job_list(struct pp_hwmgr *hwmgr)
static int cz_smu_construct_toc_for_vddgfx_enter(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc_for_vddgfx_enter(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr; struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr;
toc->JobList[JOB_GFX_SAVE] = (uint8_t)cz_smu->toc_entry_used_count; toc->JobList[JOB_GFX_SAVE] = (uint8_t)cz_smu->toc_entry_used_count;
...@@ -435,7 +435,7 @@ static int cz_smu_construct_toc_for_vddgfx_enter(struct pp_hwmgr *hwmgr) ...@@ -435,7 +435,7 @@ static int cz_smu_construct_toc_for_vddgfx_enter(struct pp_hwmgr *hwmgr)
static int cz_smu_construct_toc_for_vddgfx_exit(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc_for_vddgfx_exit(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr; struct TOC *toc = (struct TOC *)cz_smu->toc_buffer.kaddr;
toc->JobList[JOB_GFX_RESTORE] = (uint8_t)cz_smu->toc_entry_used_count; toc->JobList[JOB_GFX_RESTORE] = (uint8_t)cz_smu->toc_entry_used_count;
...@@ -477,7 +477,7 @@ static int cz_smu_construct_toc_for_vddgfx_exit(struct pp_hwmgr *hwmgr) ...@@ -477,7 +477,7 @@ static int cz_smu_construct_toc_for_vddgfx_exit(struct pp_hwmgr *hwmgr)
static int cz_smu_construct_toc_for_power_profiling(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc_for_power_profiling(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
cz_smu->toc_entry_power_profiling_index = cz_smu->toc_entry_used_count; cz_smu->toc_entry_power_profiling_index = cz_smu->toc_entry_used_count;
...@@ -489,7 +489,7 @@ static int cz_smu_construct_toc_for_power_profiling(struct pp_hwmgr *hwmgr) ...@@ -489,7 +489,7 @@ static int cz_smu_construct_toc_for_power_profiling(struct pp_hwmgr *hwmgr)
static int cz_smu_construct_toc_for_bootup(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc_for_bootup(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
cz_smu->toc_entry_initialize_index = cz_smu->toc_entry_used_count; cz_smu->toc_entry_initialize_index = cz_smu->toc_entry_used_count;
...@@ -517,7 +517,7 @@ static int cz_smu_construct_toc_for_bootup(struct pp_hwmgr *hwmgr) ...@@ -517,7 +517,7 @@ static int cz_smu_construct_toc_for_bootup(struct pp_hwmgr *hwmgr)
static int cz_smu_construct_toc_for_clock_table(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc_for_clock_table(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
cz_smu->toc_entry_clock_table = cz_smu->toc_entry_used_count; cz_smu->toc_entry_clock_table = cz_smu->toc_entry_used_count;
...@@ -530,7 +530,7 @@ static int cz_smu_construct_toc_for_clock_table(struct pp_hwmgr *hwmgr) ...@@ -530,7 +530,7 @@ static int cz_smu_construct_toc_for_clock_table(struct pp_hwmgr *hwmgr)
static int cz_smu_construct_toc(struct pp_hwmgr *hwmgr) static int cz_smu_construct_toc(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
cz_smu->toc_entry_used_count = 0; cz_smu->toc_entry_used_count = 0;
cz_smu_initialize_toc_empty_job_list(hwmgr); cz_smu_initialize_toc_empty_job_list(hwmgr);
...@@ -546,7 +546,7 @@ static int cz_smu_construct_toc(struct pp_hwmgr *hwmgr) ...@@ -546,7 +546,7 @@ static int cz_smu_construct_toc(struct pp_hwmgr *hwmgr)
static int cz_smu_populate_firmware_entries(struct pp_hwmgr *hwmgr) static int cz_smu_populate_firmware_entries(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
uint32_t firmware_type; uint32_t firmware_type;
uint32_t i; uint32_t i;
int ret; int ret;
...@@ -588,7 +588,7 @@ static int cz_smu_populate_single_scratch_entry( ...@@ -588,7 +588,7 @@ static int cz_smu_populate_single_scratch_entry(
uint32_t ulsize_byte, uint32_t ulsize_byte,
struct cz_buffer_entry *entry) struct cz_buffer_entry *entry)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
long long mc_addr = long long mc_addr =
((long long)(cz_smu->smu_buffer.mc_addr_high) << 32) ((long long)(cz_smu->smu_buffer.mc_addr_high) << 32)
| cz_smu->smu_buffer.mc_addr_low; | cz_smu->smu_buffer.mc_addr_low;
...@@ -611,7 +611,7 @@ static int cz_smu_populate_single_scratch_entry( ...@@ -611,7 +611,7 @@ static int cz_smu_populate_single_scratch_entry(
static int cz_download_pptable_settings(struct pp_hwmgr *hwmgr, void **table) static int cz_download_pptable_settings(struct pp_hwmgr *hwmgr, void **table)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
unsigned long i; unsigned long i;
for (i = 0; i < cz_smu->scratch_buffer_length; i++) { for (i = 0; i < cz_smu->scratch_buffer_length; i++) {
...@@ -640,7 +640,7 @@ static int cz_download_pptable_settings(struct pp_hwmgr *hwmgr, void **table) ...@@ -640,7 +640,7 @@ static int cz_download_pptable_settings(struct pp_hwmgr *hwmgr, void **table)
static int cz_upload_pptable_settings(struct pp_hwmgr *hwmgr) static int cz_upload_pptable_settings(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; struct cz_smumgr *cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
unsigned long i; unsigned long i;
for (i = 0; i < cz_smu->scratch_buffer_length; i++) { for (i = 0; i < cz_smu->scratch_buffer_length; i++) {
...@@ -667,10 +667,10 @@ static int cz_upload_pptable_settings(struct pp_hwmgr *hwmgr) ...@@ -667,10 +667,10 @@ static int cz_upload_pptable_settings(struct pp_hwmgr *hwmgr)
static int cz_request_smu_load_fw(struct pp_hwmgr *hwmgr) static int cz_request_smu_load_fw(struct pp_hwmgr *hwmgr)
{ {
struct cz_smumgr *cz_smu = (struct cz_smumgr *)(hwmgr->smumgr->backend); struct cz_smumgr *cz_smu = (struct cz_smumgr *)(hwmgr->smu_backend);
uint32_t smc_address; uint32_t smc_address;
if (!hwmgr->smumgr->reload_fw) { if (!hwmgr->reload_fw) {
pr_info("skip reloading...\n"); pr_info("skip reloading...\n");
return 0; return 0;
} }
...@@ -745,7 +745,7 @@ static int cz_smu_init(struct pp_hwmgr *hwmgr) ...@@ -745,7 +745,7 @@ static int cz_smu_init(struct pp_hwmgr *hwmgr)
if (cz_smu == NULL) if (cz_smu == NULL)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = cz_smu; hwmgr->smu_backend = cz_smu;
cz_smu->toc_buffer.data_size = 4096; cz_smu->toc_buffer.data_size = 4096;
cz_smu->smu_buffer.data_size = cz_smu->smu_buffer.data_size =
...@@ -830,7 +830,7 @@ static int cz_smu_fini(struct pp_hwmgr *hwmgr) ...@@ -830,7 +830,7 @@ static int cz_smu_fini(struct pp_hwmgr *hwmgr)
if (hwmgr == NULL || hwmgr->device == NULL) if (hwmgr == NULL || hwmgr->device == NULL)
return -EINVAL; return -EINVAL;
cz_smu = (struct cz_smumgr *)hwmgr->smumgr->backend; cz_smu = (struct cz_smumgr *)hwmgr->smu_backend;
if (cz_smu) { if (cz_smu) {
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
cz_smu->toc_buffer.handle); cz_smu->toc_buffer.handle);
......
...@@ -166,7 +166,7 @@ static int fiji_setup_pwr_virus(struct pp_hwmgr *hwmgr) ...@@ -166,7 +166,7 @@ static int fiji_setup_pwr_virus(struct pp_hwmgr *hwmgr)
uint32_t reg, data; uint32_t reg, data;
const PWR_Command_Table *pvirus = PwrVirusTable; const PWR_Command_Table *pvirus = PwrVirusTable;
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) { for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) {
switch (pvirus->command) { switch (pvirus->command) {
...@@ -195,7 +195,7 @@ static int fiji_setup_pwr_virus(struct pp_hwmgr *hwmgr) ...@@ -195,7 +195,7 @@ static int fiji_setup_pwr_virus(struct pp_hwmgr *hwmgr)
static int fiji_start_avfs_btc(struct pp_hwmgr *hwmgr) static int fiji_start_avfs_btc(struct pp_hwmgr *hwmgr)
{ {
int result = 0; int result = 0;
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
if (0 != smu_data->avfs.avfs_btc_param) { if (0 != smu_data->avfs.avfs_btc_param) {
if (0 != smu7_send_msg_to_smc_with_parameter(hwmgr, if (0 != smu7_send_msg_to_smc_with_parameter(hwmgr,
...@@ -255,7 +255,7 @@ static int fiji_setup_graphics_level_structure(struct pp_hwmgr *hwmgr) ...@@ -255,7 +255,7 @@ static int fiji_setup_graphics_level_structure(struct pp_hwmgr *hwmgr)
static int fiji_avfs_event_mgr(struct pp_hwmgr *hwmgr, bool smu_started) static int fiji_avfs_event_mgr(struct pp_hwmgr *hwmgr, bool smu_started)
{ {
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
switch (smu_data->avfs.avfs_btc_status) { switch (smu_data->avfs.avfs_btc_status) {
case AVFS_BTC_COMPLETED_PREVIOUSLY: case AVFS_BTC_COMPLETED_PREVIOUSLY:
...@@ -296,7 +296,7 @@ static int fiji_avfs_event_mgr(struct pp_hwmgr *hwmgr, bool smu_started) ...@@ -296,7 +296,7 @@ static int fiji_avfs_event_mgr(struct pp_hwmgr *hwmgr, bool smu_started)
static int fiji_start_smu(struct pp_hwmgr *hwmgr) static int fiji_start_smu(struct pp_hwmgr *hwmgr)
{ {
int result = 0; int result = 0;
struct fiji_smumgr *priv = (struct fiji_smumgr *)(hwmgr->smumgr->backend); struct fiji_smumgr *priv = (struct fiji_smumgr *)(hwmgr->smu_backend);
/* Only start SMC if SMC RAM is not running */ /* Only start SMC if SMC RAM is not running */
if (!(smu7_is_smc_ram_running(hwmgr) if (!(smu7_is_smc_ram_running(hwmgr)
...@@ -375,7 +375,7 @@ static int fiji_smu_init(struct pp_hwmgr *hwmgr) ...@@ -375,7 +375,7 @@ static int fiji_smu_init(struct pp_hwmgr *hwmgr)
if (fiji_priv == NULL) if (fiji_priv == NULL)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = fiji_priv; hwmgr->smu_backend = fiji_priv;
if (smu7_init(hwmgr)) if (smu7_init(hwmgr))
return -EINVAL; return -EINVAL;
......
...@@ -208,7 +208,7 @@ static int iceland_smu_init(struct pp_hwmgr *hwmgr) ...@@ -208,7 +208,7 @@ static int iceland_smu_init(struct pp_hwmgr *hwmgr)
if (iceland_priv == NULL) if (iceland_priv == NULL)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = iceland_priv; hwmgr->smu_backend = iceland_priv;
if (smu7_init(hwmgr)) if (smu7_init(hwmgr))
return -EINVAL; return -EINVAL;
......
...@@ -67,7 +67,7 @@ static int polaris10_setup_pwr_virus(struct pp_hwmgr *hwmgr) ...@@ -67,7 +67,7 @@ static int polaris10_setup_pwr_virus(struct pp_hwmgr *hwmgr)
uint32_t reg, data; uint32_t reg, data;
const PWR_Command_Table *pvirus = pwr_virus_table; const PWR_Command_Table *pvirus = pwr_virus_table;
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) { for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) {
switch (pvirus->command) { switch (pvirus->command) {
...@@ -96,7 +96,7 @@ static int polaris10_setup_pwr_virus(struct pp_hwmgr *hwmgr) ...@@ -96,7 +96,7 @@ static int polaris10_setup_pwr_virus(struct pp_hwmgr *hwmgr)
static int polaris10_perform_btc(struct pp_hwmgr *hwmgr) static int polaris10_perform_btc(struct pp_hwmgr *hwmgr)
{ {
int result = 0; int result = 0;
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
if (0 != smu_data->avfs.avfs_btc_param) { if (0 != smu_data->avfs.avfs_btc_param) {
if (0 != smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_PerformBtc, smu_data->avfs.avfs_btc_param)) { if (0 != smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_PerformBtc, smu_data->avfs.avfs_btc_param)) {
...@@ -174,7 +174,7 @@ static int polaris10_setup_graphics_level_structure(struct pp_hwmgr *hwmgr) ...@@ -174,7 +174,7 @@ static int polaris10_setup_graphics_level_structure(struct pp_hwmgr *hwmgr)
static int static int
polaris10_avfs_event_mgr(struct pp_hwmgr *hwmgr, bool SMU_VFT_INTACT) polaris10_avfs_event_mgr(struct pp_hwmgr *hwmgr, bool SMU_VFT_INTACT)
{ {
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
switch (smu_data->avfs.avfs_btc_status) { switch (smu_data->avfs.avfs_btc_status) {
case AVFS_BTC_COMPLETED_PREVIOUSLY: case AVFS_BTC_COMPLETED_PREVIOUSLY:
...@@ -310,7 +310,7 @@ static int polaris10_start_smu_in_non_protection_mode(struct pp_hwmgr *hwmgr) ...@@ -310,7 +310,7 @@ static int polaris10_start_smu_in_non_protection_mode(struct pp_hwmgr *hwmgr)
static int polaris10_start_smu(struct pp_hwmgr *hwmgr) static int polaris10_start_smu(struct pp_hwmgr *hwmgr)
{ {
int result = 0; int result = 0;
struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(hwmgr->smumgr->backend); struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(hwmgr->smu_backend);
bool SMU_VFT_INTACT; bool SMU_VFT_INTACT;
/* Only start SMC if SMC RAM is not running */ /* Only start SMC if SMC RAM is not running */
...@@ -371,7 +371,7 @@ static int polaris10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -371,7 +371,7 @@ static int polaris10_smu_init(struct pp_hwmgr *hwmgr)
if (smu_data == NULL) if (smu_data == NULL)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = smu_data; hwmgr->smu_backend = smu_data;
if (smu7_init(hwmgr)) if (smu7_init(hwmgr))
return -EINVAL; return -EINVAL;
......
...@@ -159,7 +159,7 @@ int rv_copy_table_from_smc(struct pp_hwmgr *hwmgr, ...@@ -159,7 +159,7 @@ int rv_copy_table_from_smc(struct pp_hwmgr *hwmgr,
uint8_t *table, int16_t table_id) uint8_t *table, int16_t table_id)
{ {
struct rv_smumgr *priv = struct rv_smumgr *priv =
(struct rv_smumgr *)(hwmgr->smumgr->backend); (struct rv_smumgr *)(hwmgr->smu_backend);
PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE, PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE,
"Invalid SMU Table ID!", return -EINVAL;); "Invalid SMU Table ID!", return -EINVAL;);
...@@ -192,7 +192,7 @@ int rv_copy_table_to_smc(struct pp_hwmgr *hwmgr, ...@@ -192,7 +192,7 @@ int rv_copy_table_to_smc(struct pp_hwmgr *hwmgr,
uint8_t *table, int16_t table_id) uint8_t *table, int16_t table_id)
{ {
struct rv_smumgr *priv = struct rv_smumgr *priv =
(struct rv_smumgr *)(hwmgr->smumgr->backend); (struct rv_smumgr *)(hwmgr->smu_backend);
PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE, PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE,
"Invalid SMU Table ID!", return -EINVAL;); "Invalid SMU Table ID!", return -EINVAL;);
...@@ -287,7 +287,7 @@ static int rv_smc_disable_vcn(struct pp_hwmgr *hwmgr) ...@@ -287,7 +287,7 @@ static int rv_smc_disable_vcn(struct pp_hwmgr *hwmgr)
static int rv_smu_fini(struct pp_hwmgr *hwmgr) static int rv_smu_fini(struct pp_hwmgr *hwmgr)
{ {
struct rv_smumgr *priv = struct rv_smumgr *priv =
(struct rv_smumgr *)(hwmgr->smumgr->backend); (struct rv_smumgr *)(hwmgr->smu_backend);
if (priv) { if (priv) {
rv_smc_disable_sdma(hwmgr); rv_smc_disable_sdma(hwmgr);
...@@ -296,8 +296,8 @@ static int rv_smu_fini(struct pp_hwmgr *hwmgr) ...@@ -296,8 +296,8 @@ static int rv_smu_fini(struct pp_hwmgr *hwmgr)
priv->smu_tables.entry[WMTABLE].handle); priv->smu_tables.entry[WMTABLE].handle);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
priv->smu_tables.entry[CLOCKTABLE].handle); priv->smu_tables.entry[CLOCKTABLE].handle);
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
hwmgr->smumgr->backend = NULL; hwmgr->smu_backend = NULL;
} }
return 0; return 0;
...@@ -327,7 +327,7 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr) ...@@ -327,7 +327,7 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = priv; hwmgr->smu_backend = priv;
/* allocate space for watermarks table */ /* allocate space for watermarks table */
smu_allocate_memory(hwmgr->device, smu_allocate_memory(hwmgr->device,
...@@ -340,8 +340,8 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr) ...@@ -340,8 +340,8 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE(kaddr, PP_ASSERT_WITH_CODE(kaddr,
"[rv_smu_init] Out of memory for wmtable.", "[rv_smu_init] Out of memory for wmtable.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
hwmgr->smumgr->backend = NULL; hwmgr->smu_backend = NULL;
return -EINVAL); return -EINVAL);
priv->smu_tables.entry[WMTABLE].version = 0x01; priv->smu_tables.entry[WMTABLE].version = 0x01;
...@@ -367,8 +367,8 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr) ...@@ -367,8 +367,8 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
"[rv_smu_init] Out of memory for CLOCKTABLE.", "[rv_smu_init] Out of memory for CLOCKTABLE.",
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)priv->smu_tables.entry[WMTABLE].handle); (cgs_handle_t)priv->smu_tables.entry[WMTABLE].handle);
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
hwmgr->smumgr->backend = NULL; hwmgr->smu_backend = NULL;
return -EINVAL); return -EINVAL);
priv->smu_tables.entry[CLOCKTABLE].version = 0x01; priv->smu_tables.entry[CLOCKTABLE].version = 0x01;
......
...@@ -391,12 +391,12 @@ static int smu7_populate_single_firmware_entry(struct pp_hwmgr *hwmgr, ...@@ -391,12 +391,12 @@ static int smu7_populate_single_firmware_entry(struct pp_hwmgr *hwmgr,
int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
{ {
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
uint32_t fw_to_load; uint32_t fw_to_load;
int result = 0; int result = 0;
struct SMU_DRAMData_TOC *toc; struct SMU_DRAMData_TOC *toc;
if (!hwmgr->smumgr->reload_fw) { if (!hwmgr->reload_fw) {
pr_info("skip reloading...\n"); pr_info("skip reloading...\n");
return 0; return 0;
} }
...@@ -483,7 +483,7 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) ...@@ -483,7 +483,7 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
/* Check if the FW has been loaded, SMU will not return if loading has not finished. */ /* Check if the FW has been loaded, SMU will not return if loading has not finished. */
int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type) int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type)
{ {
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
uint32_t fw_mask = smu7_get_mask_for_firmware_type(fw_type); uint32_t fw_mask = smu7_get_mask_for_firmware_type(fw_type);
uint32_t ret; uint32_t ret;
...@@ -497,7 +497,7 @@ int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type) ...@@ -497,7 +497,7 @@ int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type)
int smu7_reload_firmware(struct pp_hwmgr *hwmgr) int smu7_reload_firmware(struct pp_hwmgr *hwmgr)
{ {
return hwmgr->smumgr->smumgr_funcs->start_smu(hwmgr); return hwmgr->smumgr_funcs->start_smu(hwmgr);
} }
static int smu7_upload_smc_firmware_data(struct pp_hwmgr *hwmgr, uint32_t length, uint32_t *src, uint32_t limit) static int smu7_upload_smc_firmware_data(struct pp_hwmgr *hwmgr, uint32_t length, uint32_t *src, uint32_t limit)
...@@ -523,7 +523,7 @@ static int smu7_upload_smc_firmware_data(struct pp_hwmgr *hwmgr, uint32_t length ...@@ -523,7 +523,7 @@ static int smu7_upload_smc_firmware_data(struct pp_hwmgr *hwmgr, uint32_t length
int smu7_upload_smu_firmware_image(struct pp_hwmgr *hwmgr) int smu7_upload_smu_firmware_image(struct pp_hwmgr *hwmgr)
{ {
int result = 0; int result = 0;
struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
struct cgs_firmware_info info = {0}; struct cgs_firmware_info info = {0};
...@@ -534,7 +534,7 @@ int smu7_upload_smu_firmware_image(struct pp_hwmgr *hwmgr) ...@@ -534,7 +534,7 @@ int smu7_upload_smu_firmware_image(struct pp_hwmgr *hwmgr)
cgs_get_firmware_info(hwmgr->device, cgs_get_firmware_info(hwmgr->device,
smu7_convert_fw_type_to_cgs(UCODE_ID_SMU_SK), &info); smu7_convert_fw_type_to_cgs(UCODE_ID_SMU_SK), &info);
hwmgr->smumgr->is_kicker = info.is_kicker; hwmgr->is_kicker = info.is_kicker;
result = smu7_upload_smc_firmware_data(hwmgr, info.image_size, (uint32_t *)info.kptr, SMU7_SMC_SIZE); result = smu7_upload_smc_firmware_data(hwmgr, info.image_size, (uint32_t *)info.kptr, SMU7_SMC_SIZE);
...@@ -548,7 +548,7 @@ int smu7_init(struct pp_hwmgr *hwmgr) ...@@ -548,7 +548,7 @@ int smu7_init(struct pp_hwmgr *hwmgr)
uint64_t mc_addr = 0; uint64_t mc_addr = 0;
/* Allocate memory for backend private data */ /* Allocate memory for backend private data */
smu_data = (struct smu7_smumgr *)(hwmgr->smumgr->backend); smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
smu_data->header_buffer.data_size = smu_data->header_buffer.data_size =
((sizeof(struct SMU_DRAMData_TOC) / 4096) + 1) * 4096; ((sizeof(struct SMU_DRAMData_TOC) / 4096) + 1) * 4096;
...@@ -568,7 +568,7 @@ int smu7_init(struct pp_hwmgr *hwmgr) ...@@ -568,7 +568,7 @@ int smu7_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((NULL != smu_data->header), PP_ASSERT_WITH_CODE((NULL != smu_data->header),
"Out of memory.", "Out of memory.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)smu_data->header_buffer.handle); (cgs_handle_t)smu_data->header_buffer.handle);
return -EINVAL); return -EINVAL);
...@@ -591,7 +591,7 @@ int smu7_init(struct pp_hwmgr *hwmgr) ...@@ -591,7 +591,7 @@ int smu7_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((NULL != internal_buf), PP_ASSERT_WITH_CODE((NULL != internal_buf),
"Out of memory.", "Out of memory.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)smu_data->smu_buffer.handle); (cgs_handle_t)smu_data->smu_buffer.handle);
return -EINVAL); return -EINVAL);
...@@ -607,8 +607,8 @@ int smu7_init(struct pp_hwmgr *hwmgr) ...@@ -607,8 +607,8 @@ int smu7_init(struct pp_hwmgr *hwmgr)
int smu7_smu_fini(struct pp_hwmgr *hwmgr) int smu7_smu_fini(struct pp_hwmgr *hwmgr)
{ {
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
hwmgr->smumgr->backend = NULL; hwmgr->smu_backend = NULL;
cgs_rel_firmware(hwmgr->device, CGS_UCODE_ID_SMU); cgs_rel_firmware(hwmgr->device, CGS_UCODE_ID_SMU);
return 0; return 0;
} }
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <drm/amdgpu_drm.h> #include <drm/amdgpu_drm.h>
#include "pp_instance.h"
#include "smumgr.h" #include "smumgr.h"
#include "cgs_common.h" #include "cgs_common.h"
...@@ -46,89 +45,18 @@ MODULE_FIRMWARE("amdgpu/polaris12_smc.bin"); ...@@ -46,89 +45,18 @@ MODULE_FIRMWARE("amdgpu/polaris12_smc.bin");
MODULE_FIRMWARE("amdgpu/vega10_smc.bin"); MODULE_FIRMWARE("amdgpu/vega10_smc.bin");
MODULE_FIRMWARE("amdgpu/vega10_acg_smc.bin"); MODULE_FIRMWARE("amdgpu/vega10_acg_smc.bin");
int smum_early_init(struct pp_instance *handle)
{
struct pp_smumgr *smumgr;
if (handle == NULL)
return -EINVAL;
smumgr = kzalloc(sizeof(struct pp_smumgr), GFP_KERNEL);
if (smumgr == NULL)
return -ENOMEM;
smumgr->device = handle->device;
smumgr->chip_family = handle->chip_family;
smumgr->chip_id = handle->chip_id;
smumgr->usec_timeout = AMD_MAX_USEC_TIMEOUT;
smumgr->reload_fw = 1;
handle->smu_mgr = smumgr;
switch (smumgr->chip_family) {
case AMDGPU_FAMILY_CI:
smumgr->smumgr_funcs = &ci_smu_funcs;
break;
case AMDGPU_FAMILY_CZ:
smumgr->smumgr_funcs = &cz_smu_funcs;
break;
case AMDGPU_FAMILY_VI:
switch (smumgr->chip_id) {
case CHIP_TOPAZ:
smumgr->smumgr_funcs = &iceland_smu_funcs;
break;
case CHIP_TONGA:
smumgr->smumgr_funcs = &tonga_smu_funcs;
break;
case CHIP_FIJI:
smumgr->smumgr_funcs = &fiji_smu_funcs;
break;
case CHIP_POLARIS11:
case CHIP_POLARIS10:
case CHIP_POLARIS12:
smumgr->smumgr_funcs = &polaris10_smu_funcs;
break;
default:
return -EINVAL;
}
break;
case AMDGPU_FAMILY_AI:
switch (smumgr->chip_id) {
case CHIP_VEGA10:
smumgr->smumgr_funcs = &vega10_smu_funcs;
break;
default:
return -EINVAL;
}
break;
case AMDGPU_FAMILY_RV:
switch (smumgr->chip_id) {
case CHIP_RAVEN:
smumgr->smumgr_funcs = &rv_smu_funcs;
break;
default:
return -EINVAL;
}
break;
default:
kfree(smumgr);
return -EINVAL;
}
return 0;
}
int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr) int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable) if (NULL != hwmgr->smumgr_funcs->thermal_avfs_enable)
return hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable(hwmgr); return hwmgr->smumgr_funcs->thermal_avfs_enable(hwmgr);
return 0; return 0;
} }
int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr) int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table) if (NULL != hwmgr->smumgr_funcs->thermal_setup_fan_table)
return hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table(hwmgr); return hwmgr->smumgr_funcs->thermal_setup_fan_table(hwmgr);
return 0; return 0;
} }
...@@ -136,8 +64,8 @@ int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr) ...@@ -136,8 +64,8 @@ int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr) int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->update_sclk_threshold) if (NULL != hwmgr->smumgr_funcs->update_sclk_threshold)
return hwmgr->smumgr->smumgr_funcs->update_sclk_threshold(hwmgr); return hwmgr->smumgr_funcs->update_sclk_threshold(hwmgr);
return 0; return 0;
} }
...@@ -145,74 +73,74 @@ int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr) ...@@ -145,74 +73,74 @@ int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr)
int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type) int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->update_smc_table) if (NULL != hwmgr->smumgr_funcs->update_smc_table)
return hwmgr->smumgr->smumgr_funcs->update_smc_table(hwmgr, type); return hwmgr->smumgr_funcs->update_smc_table(hwmgr, type);
return 0; return 0;
} }
uint32_t smum_get_offsetof(struct pp_hwmgr *hwmgr, uint32_t type, uint32_t member) uint32_t smum_get_offsetof(struct pp_hwmgr *hwmgr, uint32_t type, uint32_t member)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->get_offsetof) if (NULL != hwmgr->smumgr_funcs->get_offsetof)
return hwmgr->smumgr->smumgr_funcs->get_offsetof(type, member); return hwmgr->smumgr_funcs->get_offsetof(type, member);
return 0; return 0;
} }
int smum_process_firmware_header(struct pp_hwmgr *hwmgr) int smum_process_firmware_header(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->process_firmware_header) if (NULL != hwmgr->smumgr_funcs->process_firmware_header)
return hwmgr->smumgr->smumgr_funcs->process_firmware_header(hwmgr); return hwmgr->smumgr_funcs->process_firmware_header(hwmgr);
return 0; return 0;
} }
int smum_get_argument(struct pp_hwmgr *hwmgr) int smum_get_argument(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->get_argument) if (NULL != hwmgr->smumgr_funcs->get_argument)
return hwmgr->smumgr->smumgr_funcs->get_argument(hwmgr); return hwmgr->smumgr_funcs->get_argument(hwmgr);
return 0; return 0;
} }
uint32_t smum_get_mac_definition(struct pp_hwmgr *hwmgr, uint32_t value) uint32_t smum_get_mac_definition(struct pp_hwmgr *hwmgr, uint32_t value)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->get_mac_definition) if (NULL != hwmgr->smumgr_funcs->get_mac_definition)
return hwmgr->smumgr->smumgr_funcs->get_mac_definition(value); return hwmgr->smumgr_funcs->get_mac_definition(value);
return 0; return 0;
} }
int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table) int smum_download_powerplay_table(struct pp_hwmgr *hwmgr, void **table)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->download_pptable_settings) if (NULL != hwmgr->smumgr_funcs->download_pptable_settings)
return hwmgr->smumgr->smumgr_funcs->download_pptable_settings(hwmgr, return hwmgr->smumgr_funcs->download_pptable_settings(hwmgr,
table); table);
return 0; return 0;
} }
int smum_upload_powerplay_table(struct pp_hwmgr *hwmgr) int smum_upload_powerplay_table(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->upload_pptable_settings) if (NULL != hwmgr->smumgr_funcs->upload_pptable_settings)
return hwmgr->smumgr->smumgr_funcs->upload_pptable_settings(hwmgr); return hwmgr->smumgr_funcs->upload_pptable_settings(hwmgr);
return 0; return 0;
} }
int smum_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg) int smum_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg)
{ {
if (hwmgr == NULL || hwmgr->smumgr->smumgr_funcs->send_msg_to_smc == NULL) if (hwmgr == NULL || hwmgr->smumgr_funcs->send_msg_to_smc == NULL)
return -EINVAL; return -EINVAL;
return hwmgr->smumgr->smumgr_funcs->send_msg_to_smc(hwmgr, msg); return hwmgr->smumgr_funcs->send_msg_to_smc(hwmgr, msg);
} }
int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr, int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,
uint16_t msg, uint32_t parameter) uint16_t msg, uint32_t parameter)
{ {
if (hwmgr == NULL || if (hwmgr == NULL ||
hwmgr->smumgr->smumgr_funcs->send_msg_to_smc_with_parameter == NULL) hwmgr->smumgr_funcs->send_msg_to_smc_with_parameter == NULL)
return -EINVAL; return -EINVAL;
return hwmgr->smumgr->smumgr_funcs->send_msg_to_smc_with_parameter( return hwmgr->smumgr_funcs->send_msg_to_smc_with_parameter(
hwmgr, msg, parameter); hwmgr, msg, parameter);
} }
...@@ -356,24 +284,24 @@ int smu_free_memory(void *device, void *handle) ...@@ -356,24 +284,24 @@ int smu_free_memory(void *device, void *handle)
int smum_init_smc_table(struct pp_hwmgr *hwmgr) int smum_init_smc_table(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->init_smc_table) if (NULL != hwmgr->smumgr_funcs->init_smc_table)
return hwmgr->smumgr->smumgr_funcs->init_smc_table(hwmgr); return hwmgr->smumgr_funcs->init_smc_table(hwmgr);
return 0; return 0;
} }
int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr) int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->populate_all_graphic_levels) if (NULL != hwmgr->smumgr_funcs->populate_all_graphic_levels)
return hwmgr->smumgr->smumgr_funcs->populate_all_graphic_levels(hwmgr); return hwmgr->smumgr_funcs->populate_all_graphic_levels(hwmgr);
return 0; return 0;
} }
int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr) int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->populate_all_memory_levels) if (NULL != hwmgr->smumgr_funcs->populate_all_memory_levels)
return hwmgr->smumgr->smumgr_funcs->populate_all_memory_levels(hwmgr); return hwmgr->smumgr_funcs->populate_all_memory_levels(hwmgr);
return 0; return 0;
} }
...@@ -381,16 +309,16 @@ int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr) ...@@ -381,16 +309,16 @@ int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr)
/*this interface is needed by island ci/vi */ /*this interface is needed by island ci/vi */
int smum_initialize_mc_reg_table(struct pp_hwmgr *hwmgr) int smum_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->initialize_mc_reg_table) if (NULL != hwmgr->smumgr_funcs->initialize_mc_reg_table)
return hwmgr->smumgr->smumgr_funcs->initialize_mc_reg_table(hwmgr); return hwmgr->smumgr_funcs->initialize_mc_reg_table(hwmgr);
return 0; return 0;
} }
bool smum_is_dpm_running(struct pp_hwmgr *hwmgr) bool smum_is_dpm_running(struct pp_hwmgr *hwmgr)
{ {
if (NULL != hwmgr->smumgr->smumgr_funcs->is_dpm_running) if (NULL != hwmgr->smumgr_funcs->is_dpm_running)
return hwmgr->smumgr->smumgr_funcs->is_dpm_running(hwmgr); return hwmgr->smumgr_funcs->is_dpm_running(hwmgr);
return true; return true;
} }
...@@ -398,8 +326,8 @@ bool smum_is_dpm_running(struct pp_hwmgr *hwmgr) ...@@ -398,8 +326,8 @@ bool smum_is_dpm_running(struct pp_hwmgr *hwmgr)
int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
struct amd_pp_profile *request) struct amd_pp_profile *request)
{ {
if (hwmgr->smumgr->smumgr_funcs->populate_requested_graphic_levels) if (hwmgr->smumgr_funcs->populate_requested_graphic_levels)
return hwmgr->smumgr->smumgr_funcs->populate_requested_graphic_levels( return hwmgr->smumgr_funcs->populate_requested_graphic_levels(
hwmgr, request); hwmgr, request);
return 0; return 0;
...@@ -407,8 +335,8 @@ int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, ...@@ -407,8 +335,8 @@ int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr) bool smum_is_hw_avfs_present(struct pp_hwmgr *hwmgr)
{ {
if (hwmgr->smumgr->smumgr_funcs->is_hw_avfs_present) if (hwmgr->smumgr_funcs->is_hw_avfs_present)
return hwmgr->smumgr->smumgr_funcs->is_hw_avfs_present(hwmgr); return hwmgr->smumgr_funcs->is_hw_avfs_present(hwmgr);
return false; return false;
} }
...@@ -176,7 +176,7 @@ static int tonga_smu_init(struct pp_hwmgr *hwmgr) ...@@ -176,7 +176,7 @@ static int tonga_smu_init(struct pp_hwmgr *hwmgr)
if (tonga_priv == NULL) if (tonga_priv == NULL)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = tonga_priv; hwmgr->smu_backend = tonga_priv;
if (smu7_init(hwmgr)) if (smu7_init(hwmgr))
return -EINVAL; return -EINVAL;
......
...@@ -224,7 +224,7 @@ int vega10_copy_table_from_smc(struct pp_hwmgr *hwmgr, ...@@ -224,7 +224,7 @@ int vega10_copy_table_from_smc(struct pp_hwmgr *hwmgr,
uint8_t *table, int16_t table_id) uint8_t *table, int16_t table_id)
{ {
struct vega10_smumgr *priv = struct vega10_smumgr *priv =
(struct vega10_smumgr *)(hwmgr->smumgr->backend); (struct vega10_smumgr *)(hwmgr->smu_backend);
PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE, PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE,
"Invalid SMU Table ID!", return -EINVAL); "Invalid SMU Table ID!", return -EINVAL);
...@@ -262,7 +262,7 @@ int vega10_copy_table_to_smc(struct pp_hwmgr *hwmgr, ...@@ -262,7 +262,7 @@ int vega10_copy_table_to_smc(struct pp_hwmgr *hwmgr,
uint8_t *table, int16_t table_id) uint8_t *table, int16_t table_id)
{ {
struct vega10_smumgr *priv = struct vega10_smumgr *priv =
(struct vega10_smumgr *)(hwmgr->smumgr->backend); (struct vega10_smumgr *)(hwmgr->smu_backend);
PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE, PP_ASSERT_WITH_CODE(table_id < MAX_SMU_TABLE,
"Invalid SMU Table ID!", return -EINVAL); "Invalid SMU Table ID!", return -EINVAL);
...@@ -339,7 +339,7 @@ int vega10_get_smc_features(struct pp_hwmgr *hwmgr, ...@@ -339,7 +339,7 @@ int vega10_get_smc_features(struct pp_hwmgr *hwmgr,
int vega10_set_tools_address(struct pp_hwmgr *hwmgr) int vega10_set_tools_address(struct pp_hwmgr *hwmgr)
{ {
struct vega10_smumgr *priv = struct vega10_smumgr *priv =
(struct vega10_smumgr *)(hwmgr->smumgr->backend); (struct vega10_smumgr *)(hwmgr->smu_backend);
if (priv->smu_tables.entry[TOOLSTABLE].table_addr_high || if (priv->smu_tables.entry[TOOLSTABLE].table_addr_high ||
priv->smu_tables.entry[TOOLSTABLE].table_addr_low) { priv->smu_tables.entry[TOOLSTABLE].table_addr_low) {
...@@ -412,7 +412,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -412,7 +412,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
hwmgr->smumgr->backend = priv; hwmgr->smu_backend = priv;
/* allocate space for pptable */ /* allocate space for pptable */
smu_allocate_memory(hwmgr->device, smu_allocate_memory(hwmgr->device,
...@@ -425,7 +425,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -425,7 +425,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE(kaddr, PP_ASSERT_WITH_CODE(kaddr,
"[vega10_smu_init] Out of memory for pptable.", "[vega10_smu_init] Out of memory for pptable.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)handle); (cgs_handle_t)handle);
return -EINVAL); return -EINVAL);
...@@ -451,7 +451,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -451,7 +451,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE(kaddr, PP_ASSERT_WITH_CODE(kaddr,
"[vega10_smu_init] Out of memory for wmtable.", "[vega10_smu_init] Out of memory for wmtable.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle); (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
...@@ -479,7 +479,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -479,7 +479,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE(kaddr, PP_ASSERT_WITH_CODE(kaddr,
"[vega10_smu_init] Out of memory for avfs table.", "[vega10_smu_init] Out of memory for avfs table.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle); (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
...@@ -532,7 +532,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -532,7 +532,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE(kaddr, PP_ASSERT_WITH_CODE(kaddr,
"[vega10_smu_init] Out of memory for avfs fuse table.", "[vega10_smu_init] Out of memory for avfs fuse table.",
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle); (cgs_handle_t)priv->smu_tables.entry[PPTABLE].handle);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
...@@ -561,7 +561,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr) ...@@ -561,7 +561,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
static int vega10_smu_fini(struct pp_hwmgr *hwmgr) static int vega10_smu_fini(struct pp_hwmgr *hwmgr)
{ {
struct vega10_smumgr *priv = struct vega10_smumgr *priv =
(struct vega10_smumgr *)(hwmgr->smumgr->backend); (struct vega10_smumgr *)(hwmgr->smu_backend);
if (priv) { if (priv) {
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
...@@ -575,8 +575,8 @@ static int vega10_smu_fini(struct pp_hwmgr *hwmgr) ...@@ -575,8 +575,8 @@ static int vega10_smu_fini(struct pp_hwmgr *hwmgr)
(cgs_handle_t)priv->smu_tables.entry[TOOLSTABLE].handle); (cgs_handle_t)priv->smu_tables.entry[TOOLSTABLE].handle);
cgs_free_gpu_mem(hwmgr->device, cgs_free_gpu_mem(hwmgr->device,
(cgs_handle_t)priv->smu_tables.entry[AVFSFUSETABLE].handle); (cgs_handle_t)priv->smu_tables.entry[AVFSFUSETABLE].handle);
kfree(hwmgr->smumgr->backend); kfree(hwmgr->smu_backend);
hwmgr->smumgr->backend = NULL; hwmgr->smu_backend = NULL;
} }
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