Commit 94e0805b authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

drm/amd/powerplay: correct i2c eeprom init/fini sequence

As data transfer may starts immediately after i2c eeprom init
completed. Thus i2c eeprom should be initialized after SMU
ready. And i2c data transfer should be prohibited when SMU
down. That is the i2c eeprom fini sequence needs to be
updated also.
Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarKenneth Feng <kenneth.feng@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 56ddddaa
...@@ -932,13 +932,6 @@ static int smu_sw_init(void *handle) ...@@ -932,13 +932,6 @@ static int smu_sw_init(void *handle)
return ret; return ret;
} }
if (adev->smu.ppt_funcs->i2c_eeprom_init) {
ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
if (ret)
return ret;
}
return 0; return 0;
} }
...@@ -948,9 +941,6 @@ static int smu_sw_fini(void *handle) ...@@ -948,9 +941,6 @@ static int smu_sw_fini(void *handle)
struct smu_context *smu = &adev->smu; struct smu_context *smu = &adev->smu;
int ret; int ret;
if (adev->smu.ppt_funcs->i2c_eeprom_fini)
smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
kfree(smu->irq_source); kfree(smu->irq_source);
smu->irq_source = NULL; smu->irq_source = NULL;
...@@ -1366,6 +1356,10 @@ static int smu_hw_init(void *handle) ...@@ -1366,6 +1356,10 @@ static int smu_hw_init(void *handle)
if (ret) if (ret)
goto failed; goto failed;
ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
if (ret)
goto failed;
if (!smu->pm_enabled) if (!smu->pm_enabled)
adev->pm.dpm_enabled = false; adev->pm.dpm_enabled = false;
else else
...@@ -1403,6 +1397,8 @@ static int smu_hw_fini(void *handle) ...@@ -1403,6 +1397,8 @@ static int smu_hw_fini(void *handle)
if (!smu->pm_enabled) if (!smu->pm_enabled)
return 0; return 0;
smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
if (!amdgpu_sriov_vf(adev)){ if (!amdgpu_sriov_vf(adev)){
ret = smu_stop_thermal_control(smu); ret = smu_stop_thermal_control(smu);
if (ret) { if (ret) {
...@@ -1542,6 +1538,8 @@ static int smu_suspend(void *handle) ...@@ -1542,6 +1538,8 @@ static int smu_suspend(void *handle)
if (!smu->pm_enabled) if (!smu->pm_enabled)
return 0; return 0;
smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
if(!amdgpu_sriov_vf(adev)) { if(!amdgpu_sriov_vf(adev)) {
ret = smu_disable_dpm(smu); ret = smu_disable_dpm(smu);
if (ret) if (ret)
...@@ -1587,6 +1585,10 @@ static int smu_resume(void *handle) ...@@ -1587,6 +1585,10 @@ static int smu_resume(void *handle)
if (ret) if (ret)
goto failed; goto failed;
ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
if (ret)
goto failed;
if (smu->is_apu) if (smu->is_apu)
smu_set_gfx_cgpg(&adev->smu, true); smu_set_gfx_cgpg(&adev->smu, true);
......
...@@ -580,11 +580,6 @@ int smu_check_fw_status(struct smu_context *smu); ...@@ -580,11 +580,6 @@ int smu_check_fw_status(struct smu_context *smu);
int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled); int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled);
#define smu_i2c_eeprom_init(smu, control) \
((smu)->ppt_funcs->i2c_eeprom_init ? (smu)->ppt_funcs->i2c_eeprom_init((control)) : -EINVAL)
#define smu_i2c_eeprom_fini(smu, control) \
((smu)->ppt_funcs->i2c_eeprom_fini ? (smu)->ppt_funcs->i2c_eeprom_fini((control)) : -EINVAL)
int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed); int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed);
int smu_get_power_limit(struct smu_context *smu, int smu_get_power_limit(struct smu_context *smu,
......
...@@ -214,4 +214,9 @@ static inline int smu_send_smc_msg(struct smu_context *smu, enum smu_message_typ ...@@ -214,4 +214,9 @@ static inline int smu_send_smc_msg(struct smu_context *smu, enum smu_message_typ
#define smu_set_power_source(smu, power_src) \ #define smu_set_power_source(smu, power_src) \
((smu)->ppt_funcs->set_power_source ? (smu)->ppt_funcs->set_power_source((smu), (power_src)) : 0) ((smu)->ppt_funcs->set_power_source ? (smu)->ppt_funcs->set_power_source((smu), (power_src)) : 0)
#define smu_i2c_eeprom_init(smu, control) \
((smu)->ppt_funcs->i2c_eeprom_init ? (smu)->ppt_funcs->i2c_eeprom_init((control)) : 0)
#define smu_i2c_eeprom_fini(smu, control) \
((smu)->ppt_funcs->i2c_eeprom_fini ? (smu)->ppt_funcs->i2c_eeprom_fini((control)) : 0)
#endif #endif
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