]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/amd/pm: fix possible power mode mismatch between driver and PMFW
authorEvan Quan <evan.quan@amd.com>
Thu, 11 May 2023 07:41:27 +0000 (15:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 May 2023 16:30:22 +0000 (17:30 +0100)
commit bf4823267a817f7c155876a125b94336d7113e77 upstream.

PMFW may boots the ASIC with a different power mode from the system's
real one. Notify PMFW explicitly the power mode the system in. This
is needed only when ACDC switch via gpio is not supported.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c

index 62ea57114a856a6321d9b8c0e1bc3a5a4fd81b8b..485c054b681f678fdf7dcd842c9ede1d806c9b1d 100644 (file)
@@ -727,6 +727,24 @@ static int smu_late_init(void *handle)
                return ret;
        }
 
+       /*
+        * Explicitly notify PMFW the power mode the system in. Since
+        * the PMFW may boot the ASIC with a different mode.
+        * For those supporting ACDC switch via gpio, PMFW will
+        * handle the switch automatically. Driver involvement
+        * is unnecessary.
+        */
+       if (!smu->dc_controlled_by_gpio) {
+               ret = smu_set_power_source(smu,
+                                          adev->pm.ac_power ? SMU_POWER_SOURCE_AC :
+                                          SMU_POWER_SOURCE_DC);
+               if (ret) {
+                       dev_err(adev->dev, "Failed to switch to %s mode!\n",
+                               adev->pm.ac_power ? "AC" : "DC");
+                       return ret;
+               }
+       }
+
        if ((adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 1)) ||
            (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(13, 0, 3)))
                return 0;
index 95da6dd1cc656d429995c20cc44c57ae8bb938d7..ab7e7dc1bf1a81b6d409ae7798dc1c68e4553a52 100644 (file)
@@ -3412,26 +3412,8 @@ static int navi10_post_smu_init(struct smu_context *smu)
                return 0;
 
        ret = navi10_run_umc_cdr_workaround(smu);
-       if (ret) {
+       if (ret)
                dev_err(adev->dev, "Failed to apply umc cdr workaround!\n");
-               return ret;
-       }
-
-       if (!smu->dc_controlled_by_gpio) {
-               /*
-                * For Navi1X, manually switch it to AC mode as PMFW
-                * may boot it with DC mode.
-                */
-               ret = smu_v11_0_set_power_source(smu,
-                                                adev->pm.ac_power ?
-                                                SMU_POWER_SOURCE_AC :
-                                                SMU_POWER_SOURCE_DC);
-               if (ret) {
-                       dev_err(adev->dev, "Failed to switch to %s mode!\n",
-                                       adev->pm.ac_power ? "AC" : "DC");
-                       return ret;
-               }
-       }
 
        return ret;
 }
index 4399416dd9b8f47cadd52b6641edae45a1c6588b..ca0fca7da29e03532fcf21c22bc8586e48bc2cb8 100644 (file)
@@ -1768,6 +1768,7 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = {
        .enable_mgpu_fan_boost = smu_v13_0_7_enable_mgpu_fan_boost,
        .get_power_limit = smu_v13_0_7_get_power_limit,
        .set_power_limit = smu_v13_0_set_power_limit,
+       .set_power_source = smu_v13_0_set_power_source,
        .get_power_profile_mode = smu_v13_0_7_get_power_profile_mode,
        .set_power_profile_mode = smu_v13_0_7_set_power_profile_mode,
        .set_tool_table_location = smu_v13_0_set_tool_table_location,