diff options
author | Wenhui Sheng <Wenhui.Sheng@amd.com> | 2020-05-26 13:27:11 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2020-05-28 14:00:50 -0400 |
commit | 2cdc9c200c8ab71d970f15186934b5b4687f2372 (patch) | |
tree | 87eb3e07236c94edd0937a8c5245f3fd3f9b9ffe /drivers/gpu | |
parent | 41fb666d5cebddffd1253726f3c191c0353edba5 (diff) |
drm/amd/powerplay: add check before i2c_add_adapter
smu_i2c_eeprom_init may be invoked twice or more
under sroiv mode, while we don't want to add check
if (!amdgpu_sriov_vf) before we invoke smu_i2c_eeprom_init/fini
each time, so we check if i2c adapter is already added
before we invoke i2c_add_adapter
Signed-off-by: Wenhui Sheng <Wenhui.Sheng@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 14 |
2 files changed, 22 insertions, 16 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c index a70282d439ba..69827be50ae1 100644 --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c @@ -1350,11 +1350,9 @@ static int smu_hw_init(void *handle) if (ret) goto failed; - if (!amdgpu_sriov_vf(adev)) { - ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c); - if (ret) - goto failed; - } + ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c); + if (ret) + goto failed; adev->pm.dpm_enabled = true; @@ -1392,9 +1390,7 @@ static int smu_hw_fini(void *handle) adev->pm.dpm_enabled = false; - if (!amdgpu_sriov_vf(adev)) { - smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c); - } + smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c); ret = smu_stop_thermal_control(smu); if (ret) { @@ -1535,9 +1531,7 @@ static int smu_suspend(void *handle) adev->pm.dpm_enabled = false; - if (!amdgpu_sriov_vf(adev)) { - smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c); - } + smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c); ret = smu_disable_dpm(smu); if (ret) @@ -1582,11 +1576,9 @@ static int smu_resume(void *handle) if (ret) goto failed; - if (!amdgpu_sriov_vf(adev)) { - ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c); - 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); diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c index 0b12a5c706ed..67980f50d8ec 100644 --- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c @@ -2223,11 +2223,22 @@ static const struct i2c_algorithm arcturus_i2c_eeprom_i2c_algo = { .functionality = arcturus_i2c_eeprom_i2c_func, }; +static bool arcturus_i2c_adapter_is_added(struct i2c_adapter *control) +{ + struct amdgpu_device *adev = to_amdgpu_device(control); + + return control->dev.parent == &adev->pdev->dev; +} + static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control) { struct amdgpu_device *adev = to_amdgpu_device(control); int res; + /* smu_i2c_eeprom_init may be called twice in sriov */ + if (arcturus_i2c_adapter_is_added(control)) + return 0; + control->owner = THIS_MODULE; control->class = I2C_CLASS_SPD; control->dev.parent = &adev->pdev->dev; @@ -2243,6 +2254,9 @@ static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control) static void arcturus_i2c_eeprom_control_fini(struct i2c_adapter *control) { + if (!arcturus_i2c_adapter_is_added(control)) + return; + i2c_del_adapter(control); } |