Commit 66f3db4b authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu/smu: rework i2c adpater registration

The i2c init/fini functions just register the i2c adapter.
There is no need to call them during hw init/fini.  They only
need to be called once per driver init/fini.  The previous
behavior broke runtime pm because we unregistered the i2c
adapter during suspend.
Tested-by: default avatarTom St Denis <tom.stdenis@amd.com>
Reviewed-by: default avatarKevin Wang <kevin1.wang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c4dfb549
......@@ -579,6 +579,10 @@ static int smu_smc_table_sw_init(struct smu_context *smu)
if (ret)
return ret;
ret = smu_i2c_init(smu, &smu->adev->pm.smu_i2c);
if (ret)
return ret;
return 0;
}
......@@ -586,6 +590,8 @@ static int smu_smc_table_sw_fini(struct smu_context *smu)
{
int ret;
smu_i2c_fini(smu, &smu->adev->pm.smu_i2c);
ret = smu_free_memory_pool(smu);
if (ret)
return ret;
......@@ -845,10 +851,6 @@ static int smu_smc_hw_setup(struct smu_context *smu)
return ret;
}
ret = smu_i2c_init(smu, &adev->pm.smu_i2c);
if (ret)
return ret;
ret = smu_disable_umc_cdr_12gbps_workaround(smu);
if (ret) {
dev_err(adev->dev, "Workaround failed to disable UMC CDR feature on 12Gbps SKU!\n");
......@@ -1047,8 +1049,6 @@ static int smu_smc_hw_cleanup(struct smu_context *smu)
struct amdgpu_device *adev = smu->adev;
int ret = 0;
smu_i2c_fini(smu, &adev->pm.smu_i2c);
cancel_work_sync(&smu->throttling_logging_work);
ret = smu_disable_thermal_alert(smu);
......
......@@ -2080,22 +2080,11 @@ static const struct i2c_algorithm arcturus_i2c_algo = {
.functionality = arcturus_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_control_init(struct smu_context *smu, 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;
......@@ -2111,9 +2100,6 @@ static int arcturus_i2c_control_init(struct smu_context *smu, struct i2c_adapter
static void arcturus_i2c_control_fini(struct smu_context *smu, struct i2c_adapter *control)
{
if (!arcturus_i2c_adapter_is_added(control))
return;
i2c_del_adapter(control);
}
......
......@@ -2457,22 +2457,11 @@ static const struct i2c_algorithm navi10_i2c_algo = {
.functionality = navi10_i2c_func,
};
static bool navi10_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 navi10_i2c_control_init(struct smu_context *smu, 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 (navi10_i2c_adapter_is_added(control))
return 0;
control->owner = THIS_MODULE;
control->class = I2C_CLASS_SPD;
control->dev.parent = &adev->pdev->dev;
......@@ -2488,9 +2477,6 @@ static int navi10_i2c_control_init(struct smu_context *smu, struct i2c_adapter *
static void navi10_i2c_control_fini(struct smu_context *smu, struct i2c_adapter *control)
{
if (!navi10_i2c_adapter_is_added(control))
return;
i2c_del_adapter(control);
}
......
......@@ -2630,22 +2630,11 @@ static const struct i2c_algorithm sienna_cichlid_i2c_algo = {
.functionality = sienna_cichlid_i2c_func,
};
static bool sienna_cichlid_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 sienna_cichlid_i2c_control_init(struct smu_context *smu, 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 (sienna_cichlid_i2c_adapter_is_added(control))
return 0;
control->owner = THIS_MODULE;
control->class = I2C_CLASS_SPD;
control->dev.parent = &adev->pdev->dev;
......@@ -2661,9 +2650,6 @@ static int sienna_cichlid_i2c_control_init(struct smu_context *smu, struct i2c_a
static void sienna_cichlid_i2c_control_fini(struct smu_context *smu, struct i2c_adapter *control)
{
if (!sienna_cichlid_i2c_adapter_is_added(control))
return;
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