mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 18:19:28 +09:00
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>
This commit is contained in:
committed by
Alex Deucher
parent
41fb666d5c
commit
2cdc9c200c
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user