drm/amdgpu/smu: rework i2c adpater registration
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 30 Jul 2020 19:21:33 +0000 (15:21 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Aug 2020 20:50:23 +0000 (16:50 -0400)
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: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c

index 8c624f1f33baf691b7039627602da9a64a7701f9..ceef149d3410bda5c866f5988360ae5ee7227095 100644 (file)
@@ -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;
@@ -844,10 +850,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");
@@ -1046,8 +1048,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);
index 3b9182c8c53f8f2e779695417a209786c386a7f6..3b2ecb52a36fc2347a123978f5d5a49b5861118d 100644 (file)
@@ -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);
 }
 
index 6aaf483858a0f64f82087d3fc9e31697f4d835f4..c33bdc6747f299f83f6c0ab493b9563b518ab804 100644 (file)
@@ -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);
 }
 
index f64a1be94cb8cd710a82899069ceed186ecd3caf..f373e2d0d31ca43b94350f7e665da52fadb7b28f 100644 (file)
@@ -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);
 }