drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Tue, 3 Sep 2019 20:47:40 +0000 (16:47 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Sep 2019 19:23:58 +0000 (14:23 -0500)
Protect from concurrent SMU accesses.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Reviewed-and-tested-by: Guchun Chen <guchun.chen@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amd_powerplay.c

index fa636cb462c10b54029597b798dd0f84137c8a49..fa8ad7db2b3a1f933ea698646dc0a537acffdbfb 100644 (file)
@@ -1531,6 +1531,7 @@ static int pp_asic_reset_mode_2(void *handle)
 static int pp_smu_i2c_bus_access(void *handle, bool acquire)
 {
        struct pp_hwmgr *hwmgr = handle;
+       int ret = 0;
 
        if (!hwmgr || !hwmgr->pm_en)
                return -EINVAL;
@@ -1540,7 +1541,11 @@ static int pp_smu_i2c_bus_access(void *handle, bool acquire)
                return -EINVAL;
        }
 
-       return hwmgr->hwmgr_func->smu_i2c_bus_access(hwmgr, acquire);
+       mutex_lock(&hwmgr->smu_lock);
+       ret = hwmgr->hwmgr_func->smu_i2c_bus_access(hwmgr, acquire);
+       mutex_unlock(&hwmgr->smu_lock);
+
+       return ret;
 }
 
 static const struct amd_pm_funcs pp_dpm_funcs = {