[PATCH] drm/amdgpu/smu: rework i2c adpater registration

Wang, Kevin(Yang) Kevin1.Wang at amd.com
Tue Aug 4 17:35:02 UTC 2020


Reviewed-By: Kevin Wang <kevin1.wang at amd.com>

Best Regards
Kevin

> 在 2020年8月5日,上午12:57,Alex Deucher <alexdeucher at gmail.com> 写道:
> 
> Ping?
> 
> 
>> On Thu, Jul 30, 2020 at 3:24 PM Alex Deucher <alexdeucher at gmail.com> wrote:
>> 
>> 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.
>> 
>> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
>> ---
>> drivers/gpu/drm/amd/powerplay/amdgpu_smu.c         | 12 ++++++------
>> drivers/gpu/drm/amd/powerplay/arcturus_ppt.c       | 14 --------------
>> drivers/gpu/drm/amd/powerplay/navi10_ppt.c         | 14 --------------
>> drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c | 14 --------------
>> 4 files changed, 6 insertions(+), 48 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>> index 55463e7a11e2..d03b4852ed5f 100644
>> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
>> @@ -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);
>> diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
>> index f13979687b9e..0147a5b9b06d 100644
>> --- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
>> +++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
>> @@ -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);
>> }
>> 
>> diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
>> index 6aaf483858a0..c33bdc6747f2 100644
>> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
>> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
>> @@ -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);
>> }
>> 
>> diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
>> index f64a1be94cb8..f373e2d0d31c 100644
>> --- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
>> +++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
>> @@ -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);
>> }
>> 
>> --
>> 2.25.4
>> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CKevin1.Wang%40amd.com%7Cf307306bc40840c0307008d838978248%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637321570670378196&sdata=E%2FCo%2FythThCr0i1b9Zu7GL0mrWQkdU%2BENuoT4PPeZko%3D&reserved=0


More information about the amd-gfx mailing list