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

drm/amd/pp: Add hwmgr_sw_init/fini functioins

Clean up pp ip functions
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 844de65e
...@@ -75,8 +75,7 @@ int phm_set_power_state(struct pp_hwmgr *hwmgr, ...@@ -75,8 +75,7 @@ int phm_set_power_state(struct pp_hwmgr *hwmgr,
int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr) int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr)
{ {
int ret = 1; int ret = -EINVAL;;
bool enabled;
PHM_FUNC_CHECK(hwmgr); PHM_FUNC_CHECK(hwmgr);
if (smum_is_dpm_running(hwmgr)) { if (smum_is_dpm_running(hwmgr)) {
...@@ -87,17 +86,12 @@ int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr) ...@@ -87,17 +86,12 @@ int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr)
if (NULL != hwmgr->hwmgr_func->dynamic_state_management_enable) if (NULL != hwmgr->hwmgr_func->dynamic_state_management_enable)
ret = hwmgr->hwmgr_func->dynamic_state_management_enable(hwmgr); ret = hwmgr->hwmgr_func->dynamic_state_management_enable(hwmgr);
enabled = ret == 0;
cgs_notify_dpm_enabled(hwmgr->device, enabled);
return ret; return ret;
} }
int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr) int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr)
{ {
int ret = -1; int ret = -EINVAL;
bool enabled;
PHM_FUNC_CHECK(hwmgr); PHM_FUNC_CHECK(hwmgr);
...@@ -109,10 +103,6 @@ int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr) ...@@ -109,10 +103,6 @@ int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr)
if (hwmgr->hwmgr_func->dynamic_state_management_disable) if (hwmgr->hwmgr_func->dynamic_state_management_disable)
ret = hwmgr->hwmgr_func->dynamic_state_management_disable(hwmgr); ret = hwmgr->hwmgr_func->dynamic_state_management_disable(hwmgr);
enabled = ret == 0 ? false : true;
cgs_notify_dpm_enabled(hwmgr->device, enabled);
return ret; return ret;
} }
......
...@@ -76,7 +76,7 @@ static void hwmgr_init_workload_prority(struct pp_hwmgr *hwmgr) ...@@ -76,7 +76,7 @@ static void hwmgr_init_workload_prority(struct pp_hwmgr *hwmgr)
int hwmgr_early_init(struct pp_hwmgr *hwmgr) int hwmgr_early_init(struct pp_hwmgr *hwmgr)
{ {
if (hwmgr == NULL) if (!hwmgr)
return -EINVAL; return -EINVAL;
hwmgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; hwmgr->usec_timeout = AMD_MAX_USEC_TIMEOUT;
...@@ -170,17 +170,51 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr) ...@@ -170,17 +170,51 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
return 0; return 0;
} }
int hwmgr_sw_init(struct pp_hwmgr *hwmgr)
{
if (!hwmgr|| !hwmgr->smumgr_funcs || !hwmgr->smumgr_funcs->smu_init)
return -EINVAL;
phm_register_irq_handlers(hwmgr);
return hwmgr->smumgr_funcs->smu_init(hwmgr);
}
int hwmgr_sw_fini(struct pp_hwmgr *hwmgr)
{
if (hwmgr && hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->smu_fini)
hwmgr->smumgr_funcs->smu_fini(hwmgr);
return 0;
}
int hwmgr_hw_init(struct pp_hwmgr *hwmgr) int hwmgr_hw_init(struct pp_hwmgr *hwmgr)
{ {
int ret = 0; int ret = 0;
if (hwmgr == NULL) if (!hwmgr || !hwmgr->smumgr_funcs)
return -EINVAL; return -EINVAL;
if (hwmgr->pptable_func == NULL || if (hwmgr->smumgr_funcs->start_smu) {
hwmgr->pptable_func->pptable_init == NULL || ret = hwmgr->smumgr_funcs->start_smu(hwmgr);
hwmgr->hwmgr_func->backend_init == NULL) if (ret) {
return -EINVAL; pr_err("smc start failed\n");
return -EINVAL;
}
}
if (!hwmgr->pm_en)
return 0;
if (!hwmgr->pptable_func ||
!hwmgr->pptable_func->pptable_init ||
!hwmgr->hwmgr_func->backend_init) {
hwmgr->pm_en = false;
((struct amdgpu_device *)hwmgr->adev)->pm.dpm_enabled = false;
pr_info("dpm not supported \n");
return 0;
}
ret = hwmgr->pptable_func->pptable_init(hwmgr); ret = hwmgr->pptable_func->pptable_init(hwmgr);
if (ret) if (ret)
...@@ -214,14 +248,13 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr) ...@@ -214,14 +248,13 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr)
if (hwmgr->pptable_func->pptable_fini) if (hwmgr->pptable_func->pptable_fini)
hwmgr->pptable_func->pptable_fini(hwmgr); hwmgr->pptable_func->pptable_fini(hwmgr);
err: err:
pr_err("amdgpu: powerplay initialization failed\n");
return ret; return ret;
} }
int hwmgr_hw_fini(struct pp_hwmgr *hwmgr) int hwmgr_hw_fini(struct pp_hwmgr *hwmgr)
{ {
if (hwmgr == NULL) if (!hwmgr || !hwmgr->pm_en)
return -EINVAL; return 0;
phm_stop_thermal_controller(hwmgr); phm_stop_thermal_controller(hwmgr);
psm_set_boot_states(hwmgr); psm_set_boot_states(hwmgr);
...@@ -236,12 +269,12 @@ int hwmgr_hw_fini(struct pp_hwmgr *hwmgr) ...@@ -236,12 +269,12 @@ int hwmgr_hw_fini(struct pp_hwmgr *hwmgr)
return psm_fini_power_state_table(hwmgr); return psm_fini_power_state_table(hwmgr);
} }
int hwmgr_hw_suspend(struct pp_hwmgr *hwmgr) int hwmgr_suspend(struct pp_hwmgr *hwmgr)
{ {
int ret = 0; int ret = 0;
if (hwmgr == NULL) if (!hwmgr || !hwmgr->pm_en)
return -EINVAL; return 0;
phm_disable_smc_firmware_ctf(hwmgr); phm_disable_smc_firmware_ctf(hwmgr);
ret = psm_set_boot_states(hwmgr); ret = psm_set_boot_states(hwmgr);
...@@ -255,13 +288,23 @@ int hwmgr_hw_suspend(struct pp_hwmgr *hwmgr) ...@@ -255,13 +288,23 @@ int hwmgr_hw_suspend(struct pp_hwmgr *hwmgr)
return ret; return ret;
} }
int hwmgr_hw_resume(struct pp_hwmgr *hwmgr) int hwmgr_resume(struct pp_hwmgr *hwmgr)
{ {
int ret = 0; int ret = 0;
if (hwmgr == NULL) if (!hwmgr)
return -EINVAL; return -EINVAL;
if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) {
if (hwmgr->smumgr_funcs->start_smu(hwmgr)) {
pr_err("smc start failed\n");
return -EINVAL;
}
}
if (!hwmgr->pm_en)
return 0;
ret = phm_setup_asic(hwmgr); ret = phm_setup_asic(hwmgr);
if (ret) if (ret)
return ret; return ret;
...@@ -270,9 +313,6 @@ int hwmgr_hw_resume(struct pp_hwmgr *hwmgr) ...@@ -270,9 +313,6 @@ int hwmgr_hw_resume(struct pp_hwmgr *hwmgr)
if (ret) if (ret)
return ret; return ret;
ret = phm_start_thermal_controller(hwmgr); ret = phm_start_thermal_controller(hwmgr);
if (ret)
return ret;
ret |= psm_set_performance_states(hwmgr); ret |= psm_set_performance_states(hwmgr);
if (ret) if (ret)
return ret; return ret;
......
...@@ -782,10 +782,13 @@ struct pp_hwmgr { ...@@ -782,10 +782,13 @@ struct pp_hwmgr {
}; };
int hwmgr_early_init(struct pp_hwmgr *hwmgr); int hwmgr_early_init(struct pp_hwmgr *hwmgr);
int hwmgr_sw_init(struct pp_hwmgr *hwmgr);
int hwmgr_sw_fini(struct pp_hwmgr *hwmgr);
int hwmgr_hw_init(struct pp_hwmgr *hwmgr); int hwmgr_hw_init(struct pp_hwmgr *hwmgr);
int hwmgr_hw_fini(struct pp_hwmgr *hwmgr); int hwmgr_hw_fini(struct pp_hwmgr *hwmgr);
int hwmgr_hw_suspend(struct pp_hwmgr *hwmgr); int hwmgr_suspend(struct pp_hwmgr *hwmgr);
int hwmgr_hw_resume(struct pp_hwmgr *hwmgr); int hwmgr_resume(struct pp_hwmgr *hwmgr);
int hwmgr_handle_task(struct pp_hwmgr *hwmgr, int hwmgr_handle_task(struct pp_hwmgr *hwmgr,
enum amd_pp_task task_id, enum amd_pp_task task_id,
enum amd_pm_state_type *user_state); enum amd_pm_state_type *user_state);
......
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