]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/amd/powerplay: correct i2c eeprom init/fini sequence
authorEvan Quan <evan.quan@amd.com>
Mon, 13 Apr 2020 05:26:22 +0000 (13:26 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 22 Apr 2020 22:11:45 +0000 (18:11 -0400)
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: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/smu_internal.h

index e8b27fab6aa1d3eb66aa470942910c807e1fa22f..b69e8d6c0a9615eee6a39635a8101402d2dd43d8 100644 (file)
@@ -932,13 +932,6 @@ static int smu_sw_init(void *handle)
                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;
 }
 
@@ -948,9 +941,6 @@ static int smu_sw_fini(void *handle)
        struct smu_context *smu = &adev->smu;
        int ret;
 
-       if (adev->smu.ppt_funcs->i2c_eeprom_fini)
-               smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
-
        kfree(smu->irq_source);
        smu->irq_source = NULL;
 
@@ -1366,6 +1356,10 @@ static int smu_hw_init(void *handle)
        if (ret)
                goto failed;
 
+       ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
+       if (ret)
+               goto failed;
+
        if (!smu->pm_enabled)
                adev->pm.dpm_enabled = false;
        else
@@ -1403,6 +1397,8 @@ static int smu_hw_fini(void *handle)
        if (!smu->pm_enabled)
                return 0;
 
+       smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
+
        if (!amdgpu_sriov_vf(adev)){
                ret = smu_stop_thermal_control(smu);
                if (ret) {
@@ -1542,6 +1538,8 @@ static int smu_suspend(void *handle)
        if (!smu->pm_enabled)
                return 0;
 
+       smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
+
        if(!amdgpu_sriov_vf(adev)) {
                ret = smu_disable_dpm(smu);
                if (ret)
@@ -1587,6 +1585,10 @@ static int smu_resume(void *handle)
        if (ret)
                goto failed;
 
+       ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
+       if (ret)
+               goto failed;
+
        if (smu->is_apu)
                smu_set_gfx_cgpg(&adev->smu, true);
 
index ae2c318dd6fac4d8b6fb5de077d6f5d7b33778dd..30643b9b5b3bb5f065062a39264a438c07fe81fd 100644 (file)
@@ -580,11 +580,6 @@ int smu_check_fw_status(struct smu_context *smu);
 
 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_get_power_limit(struct smu_context *smu,
index 40c35bcc5a0a2c9a358e6773375e156c7a5bc01c..c97444841abcb40e6dd544fe87affc383391e2b0 100644 (file)
@@ -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) \
        ((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