Commit 2cdc9c20 authored by Wenhui Sheng's avatar Wenhui Sheng Committed by Alex Deucher

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: default avatarWenhui Sheng <Wenhui.Sheng@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: default avatarKevin Wang <kevin1.wang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 41fb666d
...@@ -1350,11 +1350,9 @@ static int smu_hw_init(void *handle) ...@@ -1350,11 +1350,9 @@ static int smu_hw_init(void *handle)
if (ret) if (ret)
goto failed; goto failed;
if (!amdgpu_sriov_vf(adev)) { ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c); if (ret)
if (ret) goto failed;
goto failed;
}
adev->pm.dpm_enabled = true; adev->pm.dpm_enabled = true;
...@@ -1392,9 +1390,7 @@ static int smu_hw_fini(void *handle) ...@@ -1392,9 +1390,7 @@ static int smu_hw_fini(void *handle)
adev->pm.dpm_enabled = false; 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); ret = smu_stop_thermal_control(smu);
if (ret) { if (ret) {
...@@ -1535,9 +1531,7 @@ static int smu_suspend(void *handle) ...@@ -1535,9 +1531,7 @@ static int smu_suspend(void *handle)
adev->pm.dpm_enabled = false; 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); ret = smu_disable_dpm(smu);
if (ret) if (ret)
...@@ -1582,11 +1576,9 @@ static int smu_resume(void *handle) ...@@ -1582,11 +1576,9 @@ static int smu_resume(void *handle)
if (ret) if (ret)
goto failed; goto failed;
if (!amdgpu_sriov_vf(adev)) { ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c);
ret = smu_i2c_eeprom_init(smu, &adev->pm.smu_i2c); if (ret)
if (ret) goto failed;
goto failed;
}
if (smu->is_apu) if (smu->is_apu)
smu_set_gfx_cgpg(&adev->smu, true); smu_set_gfx_cgpg(&adev->smu, true);
......
...@@ -2223,11 +2223,22 @@ static const struct i2c_algorithm arcturus_i2c_eeprom_i2c_algo = { ...@@ -2223,11 +2223,22 @@ static const struct i2c_algorithm arcturus_i2c_eeprom_i2c_algo = {
.functionality = arcturus_i2c_eeprom_i2c_func, .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) static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control)
{ {
struct amdgpu_device *adev = to_amdgpu_device(control); struct amdgpu_device *adev = to_amdgpu_device(control);
int res; 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->owner = THIS_MODULE;
control->class = I2C_CLASS_SPD; control->class = I2C_CLASS_SPD;
control->dev.parent = &adev->pdev->dev; control->dev.parent = &adev->pdev->dev;
...@@ -2243,6 +2254,9 @@ static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control) ...@@ -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) static void arcturus_i2c_eeprom_control_fini(struct i2c_adapter *control)
{ {
if (!arcturus_i2c_adapter_is_added(control))
return;
i2c_del_adapter(control); i2c_del_adapter(control);
} }
......
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