There were two mistakes in the previous implementation:

The check for AutomaticDCTransition should be inverted.
We recently learned that the kernel should send
PPSMC_MSG_RunningOnAC when the flag is set, and not the
other way around.

The clocks also need to be recomputed, because the code in
the smu7_apply_state_adjust_rules() function selects
different limits on AC and DC.

Fixes: 96da0d86614e ("drm/amd/pm/smu7: Notify SMU7 of DC->AC switch")
Signed-off-by: Timur Kristóf <[email protected]>
---
 .../gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c  | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c 
b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
index be824e3d276b..17ac4c0eb8e2 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -5887,15 +5887,19 @@ static int smu7_power_off_asic(struct pp_hwmgr *hwmgr)
 static void smu7_notify_ac_dc(struct pp_hwmgr *hwmgr)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)(hwmgr->adev);
+       const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 
-       /* Check if the platform already manages the AC/DC switch via dedicated 
GPIO. */
-       if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
+       /*
+        * Check if the platform already manages the AC/DC switch via dedicated 
GPIO.
+        * Otherwise SMU automatically notices DC, but needs to be notified of 
AC.
+        */
+       if (adev->pm.ac_power &&
+           phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
                            PHM_PlatformCaps_AutomaticDCTransition))
-               return;
-
-       /* The SMU automatically notices DC, but needs to be notified when 
switching to AC. */
-       if (adev->pm.ac_power)
                smum_send_msg_to_smc(hwmgr, PPSMC_MSG_RunningOnAC, NULL);
+
+       /* Recompute clocks with updated max_limits. */
+       pp_funcs->pm_compute_clocks(adev->powerplay.pp_handle);
 }
 
 static const struct pp_hwmgr_func smu7_hwmgr_funcs = {
-- 
2.54.0

Reply via email to