]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/pm/si: Notify the SMC when switching to AC
authorJeremy Klarenbeek <jeremy.klarenbeek99@gmail.com>
Tue, 19 May 2026 08:41:58 +0000 (10:41 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 14:48:23 +0000 (10:48 -0400)
There are some platforms that don't have a dedicated
GPIO line to manage the AC/DC switch. In this case,
the SI SMC automatically notices when switching to DC,
but needs to be notified when switching to AC.

Fixup and use si_notify_hw_of_powersource() which was
previously hidden behind an "#if 0".

This fixes some SI laptop GPUs to be able to use their
performance power states after switching from DC to AC.

Some affected GPUs are:
FirePro W4170M - Dell Precision M2800
Radeon HD 8790M - Dell Latitude E6540

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Co-developed-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: Jeremy Klarenbeek <jeremy.klarenbeek99@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c

index be94d98c61b7393ae26a77b7e29f4fe5cd7e6e28..8079da7c53350e95cc288e61708d8ab0edc6cbca 100644 (file)
@@ -3888,16 +3888,18 @@ static void si_notify_hardware_vpu_recovery_event(struct amdgpu_device *adev)
 }
 #endif
 
-#if 0
-static int si_notify_hw_of_powersource(struct amdgpu_device *adev, bool ac_power)
+static void si_notify_hw_of_powersource(void *handle)
 {
-       if (ac_power)
-               return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ?
-                       0 : -EINVAL;
+       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-       return 0;
+       /* Check if the platform already manages the AC/DC switch via dedicated GPIO. */
+       if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
+               return;
+
+       /* The SMU automatically notices DC, but needs to be notified when switching to AC. */
+       if (adev->pm.ac_power)
+               amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC);
 }
-#endif
 
 static PPSMC_Result si_send_msg_to_smc_with_parameter(struct amdgpu_device *adev,
                                                      PPSMC_Msg msg, u32 parameter)
@@ -8163,6 +8165,7 @@ static const struct amd_pm_funcs si_dpm_funcs = {
        .get_vce_clock_state = amdgpu_get_vce_clock_state,
        .read_sensor = &si_dpm_read_sensor,
        .pm_compute_clocks = amdgpu_legacy_dpm_compute_clocks,
+       .notify_ac_dc = si_notify_hw_of_powersource,
 };
 
 static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {